Skip to content

Commit eb5bbbd

Browse files
authored
Merge pull request #18 from slkiser/15-bug-not-reading-github-copilot-premium-request-usage-correctly-v3
Fix Copilot premium request usage parsing
2 parents 750fef2 + 976af5a commit eb5bbbd

6 files changed

Lines changed: 758 additions & 451 deletions

File tree

README.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Token reporting commands are the `/tokens_*` family (there is no `/token` comman
6969

7070
| Provider | Config ID | Auth Source |
7171
| ------------------ | -------------------- | --------------------------------------------- |
72-
| GitHub Copilot | `copilot` | OpenCode auth (automatic) |
72+
| GitHub Copilot | `copilot` | OpenCode auth (automatic), PAT for org billing |
7373
| OpenAI (Plus/Pro) | `openai` | OpenCode auth (automatic) |
7474
| Qwen Code (OAuth) | `qwen-code` | OpenCode auth via `opencode-qwencode-auth` |
7575
| Firmware AI | `firmware` | OpenCode auth or API key |
@@ -116,26 +116,33 @@ npm run build
116116
<details>
117117
<summary><strong>GitHub Copilot</strong></summary>
118118

119-
**Setup:** Works automatically if OpenCode has Copilot configured and logged in.
119+
**Setup:** Personal Copilot usage works automatically when OpenCode has Copilot configured and logged in.
120120

121-
**Optional:** For more reliable quota reporting, provide a fine-grained PAT:
121+
**Personal usage:** No extra setup required. The plugin uses OpenCode auth to query your user billing report.
122122

123-
1. Create a fine-grained PAT at GitHub with **Account permissions > Plan > Read**
124-
2. Create `copilot-quota-token.json` under OpenCode's runtime config directory (see `opencode debug paths`):
123+
**Organization usage:** Create `copilot-quota-token.json` under OpenCode's runtime config directory (see `opencode debug paths`).
124+
125+
Organization example:
125126

126127
```json
127128
{
128129
"token": "github_pat_...",
129-
"tier": "pro"
130+
"tier": "business",
131+
"organization": "your-org-slug"
130132
}
131133
```
132134

133-
`username` is optional (kept for backwards compatibility). If provided, it is used only as a fallback for legacy GitHub REST paths.
135+
For organization-managed Copilot plans such as `business` or `enterprise`, `organization` is required. `username` is optional and is only used as the `?user=` filter on the organization report.
134136

135-
Both fine-grained PATs (`github_pat_...`) and classic PATs (`ghp_...`) should work. Fine-grained PATs must include **Account permissions > Plan > Read**.
137+
- **Organization PAT permission:** fine-grained PAT with **Organization permissions > Administration > Read**.
136138

137139
Tier options: `free`, `pro`, `pro+`, `business`, `enterprise`
138140

141+
If both OpenCode Copilot auth and `copilot-quota-token.json` are present, the plugin uses the PAT config first.
142+
143+
For personal plans, a PAT is optional. Use it only if you want an explicit tier override for quota totals.
144+
145+
Run `/quota_status` and check `copilot_quota_auth` to confirm `pat_state`, `pat_organization`, candidate paths checked, and `effective_source`/`override`.
139146
</details>
140147

141148
<details>
@@ -386,7 +393,8 @@ After configuration, instruct the user to:
386393

387394
- **Toast not showing**: Run `/quota_status` to diagnose
388395
- **Google Antigravity not working**: Ensure `opencode-antigravity-auth` plugin is installed and accounts are configured
389-
- **Copilot quota unreliable**: Consider setting up a fine-grained PAT (see Provider-Specific Setup above)
396+
- **Copilot quota unreliable**: For personal plans, OpenCode auth should work without extra setup; add `copilot-quota-token.json` only if you need a PAT-based override
397+
- **Copilot organization-managed usage missing**: Add `"organization": "your-org-slug"` to `copilot-quota-token.json` so the plugin uses the organization billing report
390398

391399
</details>
392400

0 commit comments

Comments
 (0)