An open API service indexing awesome lists of open source software.

https://github.com/opgginc/opencode-bar

Effortless token usage tracker for OpenCode
https://github.com/opgginc/opencode-bar

antigravity claude-code copilot gemini mac-app opencode

Last synced: about 1 month ago
JSON representation

Effortless token usage tracker for OpenCode

Awesome Lists containing this project

README

          

## Monthly Changelog (February 2026)

### Highlights
- Released **OpenCode Bar v2.0.0** with multi-provider monitoring and the modernized menu bar architecture ([#12](https://github.com/opgginc/opencode-bar/pull/12)).
- Added major provider coverage across app and CLI: **Kimi for Coding**, **Z.AI Coding Plan**, **Chutes AI**, **Synthetic**, **Nano-GPT**, **Brave Search**, and **Tavily** ([#34](https://github.com/opgginc/opencode-bar/pull/34), [#43](https://github.com/opgginc/opencode-bar/pull/43), [#51](https://github.com/opgginc/opencode-bar/pull/51), [#65](https://github.com/opgginc/opencode-bar/pull/65), [#66](https://github.com/opgginc/opencode-bar/pull/66), [#76](https://github.com/opgginc/opencode-bar/pull/76), [#85](https://github.com/opgginc/opencode-bar/pull/85)).
- Expanded **Codex** and **Gemini CLI** support with Codex LB account discovery, Spark window grouping/fallback parsing, auto-detection, per-model windows, and account-aware labels ([#74](https://github.com/opgginc/opencode-bar/pull/74), [#75](https://github.com/opgginc/opencode-bar/pull/75), [#77](https://github.com/opgginc/opencode-bar/pull/77), [#63](https://github.com/opgginc/opencode-bar/pull/63)).
- Improved **Claude** quota clarity with extra usage breakdowns, reset fixes, and account separation by email while excluding unavailable OpenCode sources ([#72](https://github.com/opgginc/opencode-bar/pull/72), [#89](https://github.com/opgginc/opencode-bar/pull/89), [#95](https://github.com/opgginc/opencode-bar/pull/95)).
- Added the `opencodebar` CLI with provider status/list/detail commands, JSON output support, and improved dual-percentage formatting ([#32](https://github.com/opgginc/opencode-bar/pull/32), [#92](https://github.com/opgginc/opencode-bar/pull/92)).
- Added subscription-aware billing controls and safer cleanup behavior with per-provider plan settings and orphaned plan handling ([#68](https://github.com/opgginc/opencode-bar/pull/68)).
- Improved auth and reliability: cookie-based Copilot authentication, auth source labels, dynamic OpenCode binary/auth path discovery, mixed-schema auth decoding, and stronger fallback handling ([#31](https://github.com/opgginc/opencode-bar/pull/31), [#55](https://github.com/opgginc/opencode-bar/pull/55), [#30](https://github.com/opgginc/opencode-bar/pull/30), [#26](https://github.com/opgginc/opencode-bar/pull/26), [#69](https://github.com/opgginc/opencode-bar/pull/69)).
- Polished menu bar UX with status bar provider icons, compact icon width, aligned panel styling, clearer pace/wait messaging, and improved over-quota alert behavior ([#87](https://github.com/opgginc/opencode-bar/pull/87), [#80](https://github.com/opgginc/opencode-bar/pull/80), [#79](https://github.com/opgginc/opencode-bar/pull/79), [#54](https://github.com/opgginc/opencode-bar/pull/54), [#96](https://github.com/opgginc/opencode-bar/pull/96)).
- Hardened update/release operations with Sparkle migration and relaunch fixes, x86 support, and repo-level pre-commit quality checks ([#21](https://github.com/opgginc/opencode-bar/pull/21), [#24](https://github.com/opgginc/opencode-bar/pull/24), [#39](https://github.com/opgginc/opencode-bar/pull/39), [#61](https://github.com/opgginc/opencode-bar/pull/61)).

### Key Feature PRs
- [#96](https://github.com/opgginc/opencode-bar/pull/96) Adjust overquota alert behavior (by [@kargnas](https://github.com/kargnas))
- [#95](https://github.com/opgginc/opencode-bar/pull/95) Separate Claude accounts by email and disable unavailable OpenCode source (by [@kargnas](https://github.com/kargnas))
- [#92](https://github.com/opgginc/opencode-bar/pull/92) Implement CLI formatter dual percentage display (by [@kargnas](https://github.com/kargnas))
- [#91](https://github.com/opgginc/opencode-bar/pull/91) Fix Codex usage prediction percentage (by [@kargnas](https://github.com/kargnas))
- [#89](https://github.com/opgginc/opencode-bar/pull/89) Fix Claude Sonnet usage reset (by [@kargnas](https://github.com/kargnas))
- [#88](https://github.com/opgginc/opencode-bar/pull/88) Support Nano-GPT 60M monthly plan weekly token window (by [@Daltonganger](https://github.com/Daltonganger))
- [#87](https://github.com/opgginc/opencode-bar/pull/87) Display provider icons in status bar text (by [@kargnas](https://github.com/kargnas))
- [#85](https://github.com/opgginc/opencode-bar/pull/85) Add Brave/Tavily search quota tracking and refresh modes (by [@Daltonganger](https://github.com/Daltonganger))
- [#83](https://github.com/opgginc/opencode-bar/pull/83) Replace hardcoded OpenCode path with dynamic binary discovery (by [@Shaglock](https://github.com/Shaglock))
- [#81](https://github.com/opgginc/opencode-bar/pull/81) Align menu bar usage metrics with weekly priority (by [@kargnas](https://github.com/kargnas))
- [#80](https://github.com/opgginc/opencode-bar/pull/80) Reduce status bar icon width on macOS menu bar (by [@kargnas](https://github.com/kargnas))
- [#79](https://github.com/opgginc/opencode-bar/pull/79) Align status panel styling (by [@kargnas](https://github.com/kargnas))
- [#77](https://github.com/opgginc/opencode-bar/pull/77) Add Codex Spark window grouping and fallback parsing (by [@kargnas](https://github.com/kargnas))
- [#76](https://github.com/opgginc/opencode-bar/pull/76) Add Nano-GPT provider across app and CLI (by [@Daltonganger](https://github.com/Daltonganger))
- [#75](https://github.com/opgginc/opencode-bar/pull/75) Add Gemini CLI auto-detection (by [@kargnas](https://github.com/kargnas))
- [#74](https://github.com/opgginc/opencode-bar/pull/74) Add Codex LB account discovery to status bar menu (by [@kargnas](https://github.com/kargnas))
- [#72](https://github.com/opgginc/opencode-bar/pull/72) Add Claude extra usage breakdown in UI and models (by [@kargnas](https://github.com/kargnas))
- [#69](https://github.com/opgginc/opencode-bar/pull/69) Fix auth.json decoding for mixed provider schemas (by [@kargnas](https://github.com/kargnas))
- [#68](https://github.com/opgginc/opencode-bar/pull/68) Fix orphaned subscription cleanup (by [@kargnas](https://github.com/kargnas))
- [#67](https://github.com/opgginc/opencode-bar/pull/67) Group model quotas by reset window and add dividers (by [@kargnas](https://github.com/kargnas))
- [#66](https://github.com/opgginc/opencode-bar/pull/66) Register Z.AI and Chutes providers in CLI (by [@kargnas](https://github.com/kargnas))
- [#65](https://github.com/opgginc/opencode-bar/pull/65) Show Z.AI 5h and MCP quotas (by [@kargnas](https://github.com/kargnas))
- [#63](https://github.com/opgginc/opencode-bar/pull/63) Render Gemini grouped models on separate rows (by [@kargnas](https://github.com/kargnas))
- [#61](https://github.com/opgginc/opencode-bar/pull/61) Add x86 support (by [@kargnas](https://github.com/kargnas))
- [#56](https://github.com/opgginc/opencode-bar/pull/56) Add opencode-gemini-auth support (by [@kargnas](https://github.com/kargnas))
- [#55](https://github.com/opgginc/opencode-bar/pull/55) Add auth source labels and debug summary (by [@kargnas](https://github.com/kargnas))
- [#54](https://github.com/opgginc/opencode-bar/pull/54) Fix used-up pace messaging and wait time formatting (by [@kargnas](https://github.com/kargnas))
- [#51](https://github.com/opgginc/opencode-bar/pull/51) Add Synthetic quota provider (by [@ch1y1z1](https://github.com/ch1y1z1))
- [#43](https://github.com/opgginc/opencode-bar/pull/43) Add Chutes AI provider support (by [@Daltonganger](https://github.com/Daltonganger))
- [#49](https://github.com/opgginc/opencode-bar/pull/49) Add `~/.codex/auth.json` fallback for Codex native client (by [@kargnas](https://github.com/kargnas))
- [#39](https://github.com/opgginc/opencode-bar/pull/39) Add pre-commit hooks (SwiftLint + action-validator) (by [@kargnas](https://github.com/kargnas))
- [#34](https://github.com/opgginc/opencode-bar/pull/34) Add Z.AI Coding Plan provider support (by [@hellokiseokopgg](https://github.com/hellokiseokopgg))
- [#32](https://github.com/opgginc/opencode-bar/pull/32) Add `opencodebar` CLI for provider usage queries (by [@kargnas](https://github.com/kargnas))
- [#31](https://github.com/opgginc/opencode-bar/pull/31) Implement cookie-based Copilot authentication (by [@kargnas](https://github.com/kargnas))
- [#30](https://github.com/opgginc/opencode-bar/pull/30) Fix dynamic OpenCode CLI binary search (by [@kargnas](https://github.com/kargnas))
- [#26](https://github.com/opgginc/opencode-bar/pull/26) Add fallback paths for auth.json discovery (by [@kargnas](https://github.com/kargnas))
- [#24](https://github.com/opgginc/opencode-bar/pull/24) Ensure Sparkle relaunches app after update (by [@kargnas](https://github.com/kargnas))
- [#21](https://github.com/opgginc/opencode-bar/pull/21) Add app bundle migration for Sparkle updates (by [@kargnas](https://github.com/kargnas))
- [#17](https://github.com/opgginc/opencode-bar/pull/17) Add error reporting UI for provider failures (by [@kargnas](https://github.com/kargnas))
- [#16](https://github.com/opgginc/opencode-bar/pull/16) Rename app bundle from CopilotMonitor to OpenCode Bar (by [@kargnas](https://github.com/kargnas))
- [#12](https://github.com/opgginc/opencode-bar/pull/12) OpenCode Bar v2.0.0 multi-provider monitoring release (by [@kargnas](https://github.com/kargnas))

---


OpenCode Bar Screenshot
OpenCode Bar Screenshot


Automatically monitor all your AI provider usage from OpenCode in real-time from the macOS menu bar.



Release


License

Platform
Swift

---

## Installation

### Homebrew (Easy)

```bash
brew install --cask opgginc/tap/opencode-bar
```

### Download

Download the latest `.dmg` file from the [**Releases**](https://github.com/opgginc/opencode-bar/releases/latest) page.

## Overview

**OpenCode Bar** automatically detects and monitors all AI providers registered in your [OpenCode](https://opencode.ai) configuration. No manual setup required - just install and see your usage across all providers in one unified dashboard.

### Supported Providers (Auto-detected from OpenCode)

| Provider | Type | Key Metrics |
|----------|------|-------------|
| **OpenRouter** | Pay-as-you-go | Credits balance, daily/weekly/monthly cost |
| **OpenCode Zen** | Pay-as-you-go | Daily history (30 days), model breakdown |
| **GitHub Copilot Add-on** | Pay-as-you-go | Usage-based billing after exceeding quota |
| **Claude** | Quota-based | 5h/7d usage windows, Sonnet/Opus breakdown |
| **Codex** | Quota-based | Primary/Secondary quotas, plan type |
| **Gemini CLI** | Quota-based | Per-model quotas, multi-account support with email labels and account ID details |
| **Nano-GPT** | Quota-based | Weekly input tokens quota, USD/NANO balance |
| **Kimi for Coding (Kimi K2.5)** | Quota-based | Usage limits, membership level, reset time |
| **Z.AI Coding Plan** | Quota-based | Token/MCP quotas, model usage, tool usage (24h) |
| **Brave Search** | Quota-based | Monthly search quota, reset schedule |
| **Tavily** | Quota-based | Monthly search quota, plan usage |
| **Synthetic** | Quota-based | 5h usage limit, request limits, reset time |
| **Antigravity** | Quota-based | Local cache reverse parsing (`state.vscdb`), no localhost dependency |
| **Chutes AI** | Quota-based | Daily quota limits (300/2000/5000), credits balance |
| **GitHub Copilot** | Quota-based | Daily history, overage tracking |

### OpenCode Plugins
- **Antigravity/Gemini**
- `NoeFabris/opencode-antigravity-auth` (writes `~/.config/opencode/antigravity-accounts.json`)
- `jenslys/opencode-gemini-auth` (writes `google.oauth` in OpenCode `auth.json`)
- Gemini CLI OAuth creds (writes `~/.gemini/oauth_creds.json` for email/account ID metadata; overlaps are merged with Antigravity accounts)
- **Claude**: `anomalyco/opencode-anthropic-auth`

### Standalone tools
- **Codex**: `Soju06/codex-lb` (writes `~/.codex-lb/`)

### Other AI agents beyond OpenCode that supports auto-detection
- **Codex**
- **Codex for Mac** - Auto-detected through `~/.codex/auth.json`
- **Codex CLI** - Auto-detected through `~/.codex/auth.json`
- **Claude Code CLI** - Keychain-based authentication detection

## Features

### Automatic Provider Detection
- **Zero Configuration**: Reads your OpenCode `auth.json` automatically
- **Multi-path Support**: Searches `$XDG_DATA_HOME/opencode`, `~/.local/share/opencode`, and `~/Library/Application Support/opencode`
- **Dynamic Updates**: New providers appear as you add them to OpenCode
- **Smart Categorization**: Pay-as-you-go vs Quota-based providers displayed separately

### Real-time Monitoring
- **Menu Bar Dashboard**: View all provider usage at a glance
- **Visual Indicators**: Color-coded progress (green → yellow → orange → red)
- **Detailed Submenus**: Click any provider for in-depth metrics
- **Auth Source Labels**: See where each account token was detected (OpenCode, VS Code, Keychain, etc.)
- **Gemini Account Labels**: Shows `Gemini CLI (email)` when email is available, with fallback to `Gemini CLI #N`

### Usage History & Predictions
- **Daily Tracking**: View request counts and overage costs
- **EOM Prediction**: Estimates end-of-month totals using weighted averages
- **Add-on Cost Tracking**: Shows additional costs when exceeding limits

### Subscription Settings (Quota-based Providers Only)
- **Per-Provider Plans**: Configure your subscription tier for quota-based providers
- **Cost Tracking**: Accurate monthly cost calculation based on your plan
- **Orphaned Plan Cleanup**: Detect and reset stale subscription entries that no longer match accounts

### Convenience
- **Launch at Login**: Start automatically with macOS
- **Parallel Fetching**: All providers update simultaneously for speed
- **Auto Updates**: Seamless background updates via Sparkle framework

## Development

### Build from Source

```bash
# Clone the repository
git clone https://github.com/opgginc/opencode-bar.git
cd opencode-bar

# Build
xcodebuild -project CopilotMonitor/CopilotMonitor.xcodeproj \
-scheme CopilotMonitor -configuration Debug build

# Open the app (auto-detect path)
open "$(xcodebuild -project CopilotMonitor/CopilotMonitor.xcodeproj -scheme CopilotMonitor -configuration Debug -showBuildSettings 2>/dev/null | sed -n 's/^[[:space:]]*BUILT_PRODUCTS_DIR = //p' | head -n 1)/OpenCode Bar.app"
```

**Requirements:**
- macOS 13.0+
- Xcode 15.0+ (for building from source)
- [OpenCode](https://opencode.ai) installed with authenticated providers

## Usage

### Menu Bar App

1. **Install OpenCode**: Make sure you have OpenCode installed and authenticated with your providers
2. **Launch the app**: Run OpenCode Bar
3. **View usage**: Click the menu bar icon to see all your provider usage
4. **GitHub Copilot** (optional): Automatically detected via browser cookies (Chrome, Brave, Arc, Edge supported)

### Command Line Interface (CLI)

OpenCode Bar includes a powerful CLI for querying provider usage programmatically.

#### Installation

```bash
# Option 1: Install via menu bar app
# Click "Install CLI" from the Settings menu

# Option 2: Manual installation
bash scripts/install-cli.sh

# Verify installation
opencodebar --help
```

#### Commands

```bash
# Show all providers and their usage (default command)
opencodebar status

# List all available providers
opencodebar list

# Get detailed info for a specific provider
opencodebar provider claude
opencodebar provider gemini_cli

# Output as JSON (for scripting)
opencodebar status --json
opencodebar provider claude --json
opencodebar list --json
```

#### Table Output Example

```bash
$ opencodebar status
Provider Type Usage Key Metrics
─────────────────────────────────────────────────────────────────────────────────
Claude Quota-based 77% 23/100 remaining
Codex Quota-based 0% 100/100 remaining
Gemini CLI (user1@gmail.com) Quota-based 0% 100% remaining
Gemini CLI (user2@company.com) Quota-based 15% 85% remaining
Kimi for Coding Quota-based 26% 74/100 remaining
OpenCode Zen Pay-as-you-go - $12.50 spent
OpenRouter Pay-as-you-go - $37.42 spent
```

#### JSON Output Example

```bash
$ opencodebar status --json
{
"claude": {
"type": "quota-based",
"remaining": 23,
"entitlement": 100,
"usagePercentage": 77,
"overagePermitted": false
},
"gemini_cli": {
"type": "quota-based",
"remaining": 85,
"entitlement": 100,
"usagePercentage": 15,
"overagePermitted": false,
"accounts": [
{
"index": 0,
"email": "user1@gmail.com",
"accountId": "100663739661147150906",
"remainingPercentage": 100,
"modelBreakdown": {
"gemini-2.5-pro": 100,
"gemini-2.5-flash": 100
}
},
{
"index": 1,
"email": "user2@company.com",
"accountId": "109876543210987654321",
"remainingPercentage": 85,
"modelBreakdown": {
"gemini-2.5-pro": 85,
"gemini-2.5-flash": 90
}
}
]
},
"openrouter": {
"type": "pay-as-you-go",
"cost": 37.42
}
}
```

#### Use Cases

- **Monitoring**: Integrate with monitoring systems to track API usage
- **Automation**: Build scripts that respond to quota thresholds
- **CI/CD**: Check provider quotas before running expensive operations
- **Reporting**: Generate usage reports for billing and analysis

#### Exit Codes

| Code | Meaning |
|------|---------|
| 0 | Success |
| 1 | General error |
| 2 | Authentication failed |
| 3 | Network error |
| 4 | Invalid arguments |

### Menu Structure

```
─────────────────────────────
Pay-as-you-go: $37.61
OpenRouter $37.42 ▸
OpenCode Zen $0.19 ▸
─────────────────────────────
Quota Status: $219/m
Copilot 0% ▸
Claude: 60%, 100% ▸
Codex 100% ▸
Z.AI Coding Plan 99% ▸
Gemini CLI (user1@gmail.com) 100% ▸
─────────────────────────────
Predicted EOM: $451
─────────────────────────────
Refresh (⌘R)
Auto Refresh ▸
Settings ▸
─────────────────────────────
Version 2.1.0
Quit (⌘Q)
```

#### Menu Group Titles

| Group | Format | Description |
|-------|--------|-------------|
| **Pay-as-you-go** | `Pay-as-you-go: $XX.XX` | Sum of all pay-as-you-go provider costs (OpenRouter + OpenCode Zen) |
| **Quota Status** | `Quota Status: $XXX/m` | Shows total monthly subscription cost if any quota-based providers have subscription settings configured. If no subscriptions are set, shows just "Quota Status". |

##### Status Bar Options

- **Menu Bar Display**: Choose one of `Total Cost`, `Icon Only`, or `Only Show`.
- **Critical Badge**: Toggle on/off to show or hide the critical-usage badge.
- **Show Provider Icon**: Toggle on/off to append the selected provider icon in the status bar.

> **Status Bar Icon Behavior**:
> The primary OpenCode Bar status icon always stays visible. Provider icons are rendered as an additional icon next to the primary icon (not a replacement).
>
> **Gemini Icon Sizing**:
> Gemini uses a slightly larger icon size than other providers in both menu rows and the status bar to match the official visual balance.

> **Note**: Subscription settings are only available for quota-based providers. Pay-as-you-go providers do not have subscription options since they charge based on actual usage.
>
> **Terminology**:
> `Status Bar Percent` means the single representative percentage shown in the macOS top status bar text.
> `Dropdown Detail Percents` means the multi-window percentages shown in provider rows inside the opened dropdown menu.
>
> **Status Bar Percent Rule**: `Status Bar Percent` uses one fixed priority:
> `Weekly` → `Monthly` → `Daily` → `Hourly` → fallback aggregate.
> If multiple values exist in the same priority window, the highest value is shown (for example, Claude weekly picks max of 7d/Sonnet/Opus).
> In `Recent Quota Change Only`, provider selection is based on change, but the shown percentage is the provider's current priority-based usage.
>
> **Dropdown Detail Percents Rule**: top-level menu rows keep multi-window percentages when available.

## How It Works

1. **Token Discovery**: Reads authentication tokens from OpenCode's `auth.json` (with multi-path fallback)
2. **Cookie Detection**: Finds GitHub Copilot sessions from Chrome, Brave, Arc, or Edge (with profile support)
3. **Parallel Fetching**: Queries all provider APIs simultaneously
4. **Smart Caching**: Falls back to cached data on network errors
5. **Graceful Degradation**: Shows available providers even if some fail

### Privacy & Security

- **Local Only**: All data stays on your machine
- **No Third-party Servers**: Direct communication with provider APIs
- **Read-only Access**: Uses existing OpenCode tokens (no additional permissions)
- **Browser Cookie Access**: GitHub Copilot reads session cookies from your default browser (read-only, no passwords stored)

## Troubleshooting

### "No providers found" or auth.json not detected
The app searches for `auth.json` in these locations (in order):
1. `$XDG_DATA_HOME/opencode/auth.json` (if XDG_DATA_HOME is set)
2. `~/.local/share/opencode/auth.json` (default)
3. `~/Library/Application Support/opencode/auth.json` (macOS fallback)

### GitHub Copilot not showing
- Make sure you're signed into GitHub in a supported browser (Chrome, Brave, Arc, or Edge)
- The app reads session cookies from browser profiles—no manual login required
- Check that your browser has active GitHub cookies (try visiting github.com)

### OpenCode CLI commands failing
The app dynamically searches for the `opencode` binary in:
- Current PATH (`which opencode`)
- Login shell PATH
- Common install locations: `~/.opencode/bin/opencode`, `/usr/local/bin/opencode`, etc.

## Contributing

Contributions are welcome! Please submit a Pull Request.

### Development Setup

1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. **Setup Git Hooks** (run once after clone):
```bash
make setup
```
This configures pre-commit hooks for:
- **SwiftLint**: Checks Swift code style on staged `.swift` files
- **action-validator**: Validates GitHub Actions workflow files
4. Make your Changes
5. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
- Pre-commit hooks will automatically check your code
- Fix any violations or use `git commit --no-verify` to bypass (not recommended)
6. Push to the Branch (`git push origin feature/AmazingFeature`)
7. Open a Pull Request

### Code Quality

This project uses SwiftLint and action-validator to maintain code quality:

- **Pre-commit Hook**: Runs on `git commit` (setup via `make setup`)
- SwiftLint for `.swift` files
- action-validator for `.github/workflows/*.yml` files
- **GitHub Actions**: Runs on all pushes and pull requests
- **Manual Check**: `make lint` (or `make lint-swift`, `make lint-actions`)

## License

MIT License - See [LICENSE](LICENSE) file for details.

## Related

- [OpenCode](https://opencode.ai) - The AI coding assistant that powers this monitor
- [GitHub Copilot](https://github.com/features/copilot)

## Credits

- [OP.GG](https://op.gg)
- [Sangrak Choi](https://kargn.as)

---


Made with tiredness for AI power users