@specode/pi-subscription-usage 1.3.1 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +114 -84
- package/README.zh-CN.md +114 -84
- package/package.json +5 -3
- package/src/format.ts +1 -0
- package/src/providers/antigravity.ts +372 -0
- package/src/providers/claude-bridge.ts +118 -0
- package/src/query.ts +167 -6
- package/src/types.ts +3 -1
- package/src/usage.ts +61 -6
package/README.md
CHANGED
|
@@ -1,140 +1,170 @@
|
|
|
1
|
-
#
|
|
1
|
+
# pi-subscription-usage
|
|
2
2
|
|
|
3
|
-
[English](README.md) | [简体中文](README.zh-CN.md)
|
|
3
|
+
[English](./README.md) | [简体中文](./README.zh-CN.md)
|
|
4
4
|
|
|
5
|
-
A Pi extension that shows
|
|
5
|
+
A [Pi](https://github.com/earendil-works/pi-mono) extension that shows your active provider's subscription quota in the footer status bar and a full breakdown via `/usage`.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Footer status bar:
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
```text
|
|
10
|
+
5h 99% ↻2h13m · 1w 85% ↻3d4h
|
|
11
|
+
```
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
- **OpenCode Go** — 5-hour, weekly, and monthly windows.
|
|
13
|
-
- **Grok** — weekly and/or monthly quota using only Pi's `xai` / `xai-auth` OAuth credentials, with account identity verification. A weekly `currentPeriod` with an omitted `creditUsagePercent` is treated as 0% used (proto3 omits zero after reset). Unified SuperGrok billing is still probed from the default monthly endpoint, but that probe is no longer required when the weekly window is already displayable. Windows use the same `5h / 1w / 1m` status format as other providers.
|
|
14
|
-
- **Kimi Coding** — 5-hour and weekly windows, plus the membership plan reported by the usage API.
|
|
13
|
+
`/usage` output:
|
|
15
14
|
|
|
16
|
-
|
|
15
|
+
```text
|
|
16
|
+
OpenAI Codex
|
|
17
|
+
Shared Across Models:
|
|
18
|
+
5h Window ████████████ 99% left · resets 08/27 12:13
|
|
19
|
+
1w Window ██████████░░ 85% left · resets 08/30 14:00
|
|
20
|
+
|
|
21
|
+
gpt-5.6-spark:
|
|
22
|
+
5h Window █░░░░░░░░░░░ 10% left · resets 08/27 11:40
|
|
23
|
+
|
|
24
|
+
Account:
|
|
25
|
+
Email user@example.com
|
|
26
|
+
Plan Pro
|
|
27
|
+
Resets Left 2
|
|
28
|
+
Extra Credit none
|
|
29
|
+
```
|
|
17
30
|
|
|
18
|
-
##
|
|
31
|
+
## Supported Providers
|
|
19
32
|
|
|
20
|
-
|
|
33
|
+
To sign in, run `/login`, pick `Sign in with an account` (Account below) or `Sign in with an API key` (API key below), then pick the name shown in the table.
|
|
21
34
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
35
|
+
| Provider | `/login` option | Quota shown | Reset credits | Extra extension |
|
|
36
|
+
| --- | --- | --- | --- | --- |
|
|
37
|
+
| OpenAI (ChatGPT) | Account → `OpenAI`, and Account → `OpenAI Codex (legacy)` | ChatGPT plan limits, current app limits | Yes (`Account Resets`) | |
|
|
38
|
+
| OpenAI Codex | Account → `OpenAI Codex (legacy)` | `5h`, `1w`, model-specific windows, account email | Yes (`Resets Left`) | |
|
|
39
|
+
| OpenCode Go | API key → `OpenCode Go` | `5h`, `1w`, `1m` | — | |
|
|
40
|
+
| xAI Grok | Account → `xAI` | `1w` and/or `1m` | — | |
|
|
41
|
+
| Kimi Coding | Account → `Kimi For Coding` | `5h`, `1w`, membership level | — | |
|
|
42
|
+
| Antigravity | Account → `Antigravity` | Gemini (`5h`, `1w`), Claude and GPT (`5h`, `1w`), Gemini 4 Argon (`1w`), plan, email, project | — | [`pi-antigravity`](https://www.npmjs.com/package/pi-antigravity) |
|
|
43
|
+
| Claude (Claude Code) | None; signed in through Claude Code | `5h`, `1w` | — | [`pi-claude-bridge`](https://www.npmjs.com/package/pi-claude-bridge) 0.9.3 or later |
|
|
25
44
|
|
|
26
|
-
|
|
45
|
+
### Provider Notes
|
|
27
46
|
|
|
28
|
-
|
|
29
|
-
pi install npm:@specode/pi-subscription-usage
|
|
30
|
-
```
|
|
47
|
+
#### OpenAI (ChatGPT)
|
|
31
48
|
|
|
32
|
-
|
|
49
|
+
Sign in to both `OpenAI` and `OpenAI Codex (legacy)` with the same ChatGPT account and workspace, then keep chatting with an `OpenAI` model. OpenAI rejects the `OpenAI` sign-in on its usage endpoints, so the extension uses the `OpenAI Codex (legacy)` sign-in only to read usage. `/usage` lists website `Plan limits` separately from the current app's limits (`App Allowance` shows the configured cap share, not remaining quota), and the footer tracks `Plan limits`.
|
|
33
50
|
|
|
34
|
-
|
|
35
|
-
pi install /absolute/path/to/pi-subscription-usage
|
|
36
|
-
```
|
|
51
|
+
#### xAI Grok
|
|
37
52
|
|
|
38
|
-
|
|
53
|
+
Sign in with your SuperGrok account (Account → `xAI`). Signing in with an xAI API key does not show subscription quota. If you use the third-party `pi-xai-oauth` extension instead, its sign-in works too.
|
|
39
54
|
|
|
40
|
-
|
|
55
|
+
#### Antigravity
|
|
41
56
|
|
|
42
|
-
|
|
57
|
+
Requires [`pi-antigravity`](https://www.npmjs.com/package/pi-antigravity) by Rahul Arya ([GitHub](https://github.com/Rahularya01/pi-antigravity)). Install it with `pi install npm:pi-antigravity`; `Antigravity` then appears under `Sign in with an account` in `/login`. Quota is split into three separate shared pools: Gemini models (`5h` and `1w`), Claude and GPT models (`5h` and `1w`), and Gemini 4 Argon (`1w`). The footer shows the pool of the model you are using: Claude and GPT-OSS models show the Claude and GPT pool, Gemini 4 Argon shows the Argon pool, and other Gemini models show the Gemini pool. Quota data requires a paid Google AI subscription; free-tier accounts show `Unsupported` in `/usage` and display nothing in the footer instead of an error.
|
|
43
58
|
|
|
44
|
-
|
|
45
|
-
/usage
|
|
46
|
-
```
|
|
59
|
+
Tested with `pi-antigravity` 0.11.0. Every earlier version back to 0.1.0 registers the same provider id, Google endpoint, and credential format, so they are expected to work too.
|
|
47
60
|
|
|
48
|
-
|
|
61
|
+
Several packages have similar names. The extension recognizes the `antigravity` provider id and reads quota from Google's Cloud Code API with the credential Pi resolves for it, so the package must register that id and serve models from Google's endpoint. Install only one package that registers `antigravity`. As of October 31, 2026:
|
|
49
62
|
|
|
50
|
-
|
|
63
|
+
| Package | Result |
|
|
64
|
+
| --- | --- |
|
|
65
|
+
| `pi-antigravity` | Works |
|
|
66
|
+
| `@gwylook/pi-antigravity`, `@dereknex/pi-antigravity` (forks of `pi-antigravity`), `@heyhuynhgiabuu/pi-oauth-antigravity`, `@raquezha/antigravity`, `pi-provider-antigravity` | Same provider id, Google endpoint, and credential format; expected to work, untested |
|
|
67
|
+
| `@estebanforge/pi-antigravity-bridge`, `@thoth-agents/pi-antigravity-bridge` | Register `antigravity` but run models through a local Antigravity bridge (`agy-bridge://`): unsupported, so the footer stays empty and `/usage` explains why |
|
|
68
|
+
| `@cortexkit/pi-antigravity-auth` (`google`), `pi-antigravity-acp-provider` and `@dapidev/pi-antigravity-pure` (`antigravity-acp`), `@ackneal/pi-agy-bridge` (`agy`) | Register a different provider id; not supported |
|
|
51
69
|
|
|
52
|
-
|
|
53
|
-
2. Model-specific sections
|
|
54
|
-
3. `Account`
|
|
70
|
+
#### Claude (Claude Code)
|
|
55
71
|
|
|
56
|
-
|
|
72
|
+
Requires [`pi-claude-bridge`](https://www.npmjs.com/package/pi-claude-bridge) by elidickinson ([GitHub](https://github.com/elidickinson/pi-claude-bridge)), version 0.9.3 or later. 0.9.3 is the first version that passes Claude Code's usage reports on to Pi. Install it with `pi install npm:pi-claude-bridge` and sign in to Claude Code itself; there is no Pi login. Usage covers models under the `claude-bridge` provider; Claude models served by Antigravity use the Antigravity pool above.
|
|
57
73
|
|
|
58
|
-
The
|
|
74
|
+
The bridge has no usage endpoint to query: Claude Code attaches your plan usage to its responses, and the extension reads that report. So the footer stays empty in each new session until the first report arrives, `/usage` shows the last reported values with the time they were reported instead of fetching, and a window whose reset time has passed shows as unused until the next report. The extension never reads Claude Code's credentials.
|
|
59
75
|
|
|
60
|
-
|
|
76
|
+
Tested with `pi-claude-bridge` 0.9.3 and Claude Code 2.1.311, the version bundled with the bridge's Agent SDK. If you point the bridge at your own `claude` executable (`pathToClaudeCodeExecutable`), older Claude Code versions are untested.
|
|
61
77
|
|
|
62
|
-
|
|
78
|
+
Several packages have similar names. The extension recognizes the `claude-bridge` provider id, so the package must both register that id and pass usage reports on. As of October 31, 2026:
|
|
63
79
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
80
|
+
| Package | Result |
|
|
81
|
+
| --- | --- |
|
|
82
|
+
| `pi-claude-bridge` 0.9.3 or later | Works |
|
|
83
|
+
| `@viniciosrab/pi-claude-bridge` 0.9.4-fork.3 | Same usage code as 0.9.3; expected to work, untested |
|
|
84
|
+
| `pi-claude-bridge` before 0.9.3, `@fractaal/pi-claude-bridge`, `@yassimba/pi-claude-bridge`, `@agimon-ai/po-claude-bridge` | Register `claude-bridge` but never pass usage on: the footer stays empty and `/usage` keeps showing `Waiting` |
|
|
85
|
+
| `@vanillagreen/pi-claude-bridge`, `pi-claude-subscription`, `pi-claude-directsdk`, `@ramtinj95/pi-claude-delegation` | Register a different provider id; not supported |
|
|
86
|
+
|
|
87
|
+
The npm package `claude-bridge`, without the `pi-` prefix, is an unrelated proxy server for the Claude Code CLI; `pi install npm:claude-bridge` installs the wrong package. Run `pi list` to check which package you have.
|
|
88
|
+
|
|
89
|
+
## Installation
|
|
90
|
+
|
|
91
|
+
From npm:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
pi install npm:@specode/pi-subscription-usage
|
|
68
95
|
```
|
|
69
96
|
|
|
70
|
-
|
|
97
|
+
From GitHub:
|
|
71
98
|
|
|
72
|
-
|
|
73
|
-
|
|
99
|
+
```bash
|
|
100
|
+
pi install git:github.com/specode/pi-subscription-usage
|
|
101
|
+
```
|
|
74
102
|
|
|
75
|
-
|
|
103
|
+
From a local directory for development:
|
|
76
104
|
|
|
77
|
-
|
|
105
|
+
```bash
|
|
106
|
+
pi install /path/to/pi-subscription-usage
|
|
107
|
+
```
|
|
78
108
|
|
|
79
|
-
|
|
109
|
+
## Usage
|
|
80
110
|
|
|
81
|
-
|
|
111
|
+
Sign in through `/login` as described above, then select a model from that provider. From then on:
|
|
82
112
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
4. Uses a unique request ID and reuses it across retries.
|
|
113
|
+
- The footer status bar shows the active quota windows and refreshes after each turn and every 5 minutes (using a 5-minute cache).
|
|
114
|
+
- Running `/usage` always fetches fresh data for the active provider and shows progress bars, reset times (`MM/DD HH:mm`), and account details.
|
|
115
|
+
- Claude is the exception: its quota is never fetched, only read from Claude Code's responses (see [Claude (Claude Code)](#claude-claude-code)).
|
|
87
116
|
|
|
88
|
-
|
|
117
|
+
### Reset Credits (OpenAI and Codex)
|
|
89
118
|
|
|
90
|
-
|
|
119
|
+
When your OpenAI or Codex account has redeemable rate-limit reset tickets, `/usage` offers to use one:
|
|
91
120
|
|
|
92
|
-
-
|
|
93
|
-
-
|
|
121
|
+
- `Cancel (Default)` is selected by default, and an explicit confirmation is required before a ticket is consumed.
|
|
122
|
+
- Before redeeming, the extension checks that the active model and account have not changed and that the runtime token matches Pi's stored OAuth login.
|
|
123
|
+
- In OpenAI mode, a ticket resets server-defined account windows rather than specifically clearing the current app's limits.
|
|
124
|
+
- Redeeming a reset ticket is the only write operation in this extension.
|
|
94
125
|
|
|
95
|
-
|
|
126
|
+
## Configuration
|
|
96
127
|
|
|
97
|
-
|
|
128
|
+
Percentages show remaining quota by default. To show used quota instead, create `~/.pi/agent/subscription-usage.json` (global) or `.pi/subscription-usage.json` (trusted project override):
|
|
98
129
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
- Credentials are sent only to the corresponding official domains. Custom proxies and custom base URLs are rejected.
|
|
105
|
-
- Account reset redemption (OpenAI / Codex) is the only write operation. It is shown only when redeemable credits exist and always requires explicit confirmation.
|
|
130
|
+
```json
|
|
131
|
+
{
|
|
132
|
+
"displayMode": "used"
|
|
133
|
+
}
|
|
134
|
+
```
|
|
106
135
|
|
|
107
|
-
|
|
136
|
+
| Value | Description |
|
|
137
|
+
| --- | --- |
|
|
138
|
+
| `"remaining"` | Show remaining quota percentage (default) |
|
|
139
|
+
| `"used"` | Show used quota percentage |
|
|
108
140
|
|
|
109
|
-
|
|
141
|
+
Run `/reload` after changing the config file. `displayMode` applies to the footer status bar, `/usage` progress bars, and status events.
|
|
110
142
|
|
|
111
|
-
|
|
112
|
-
- A Node.js version that can run TypeScript files directly for the test suite.
|
|
143
|
+
## Privacy and Safety
|
|
113
144
|
|
|
114
|
-
|
|
145
|
+
- Credentials come only from Pi's own login (provider registry). The extension never reads browser cookies or other tools' credential files (for example, Grok never reads `~/.grok/auth.json`, and Claude usage comes from the bridge's responses, not Claude Code's keychain entry).
|
|
146
|
+
- Requests go only to each provider's official endpoints. Custom proxies and custom base URLs are refused.
|
|
147
|
+
- Tokens are never written to caches, session files, the status bar, or error messages.
|
|
148
|
+
- The extension does not modify model requests.
|
|
149
|
+
- Several provider usage endpoints are undocumented. If an endpoint changes, the extension shows an error rather than guessing.
|
|
150
|
+
|
|
151
|
+
## Development
|
|
115
152
|
|
|
116
153
|
```bash
|
|
154
|
+
# Run tests (requires Node.js with native TypeScript support)
|
|
117
155
|
npm test
|
|
118
|
-
```
|
|
119
156
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
```bash
|
|
157
|
+
# Check package contents
|
|
123
158
|
npm run pack:check
|
|
124
|
-
```
|
|
125
159
|
|
|
126
|
-
Load the extension directly without installing
|
|
127
|
-
|
|
128
|
-
```bash
|
|
160
|
+
# Load the extension directly in Pi without installing
|
|
129
161
|
pi --no-extensions --offline -e ./index.ts --list-models
|
|
130
162
|
```
|
|
131
163
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
OpenAI app usage also depends on an undocumented ChatGPT endpoint. OpenAI rejects Sign in with ChatGPT tokens on these ChatGPT usage and reset endpoints (HTTP 401), so the companion Codex login is required: run `/login openai-codex` once with the same account/workspace. It is used only to read usage; keep OpenAI as the active model. Without it, check usage at https://chatgpt.com/settings/usage. An account/workspace mismatch, missing registration, or missing windows produces an error rather than displaying another account's quota. `App Allowance` is the configured share the app may use, not its remaining percentage. `Source` identifies this as the matching app in Pi's Codex account; matching application IDs is not independent cryptographic verification of both token identities.
|
|
164
|
+
### Status Events for Theme and Extension Authors
|
|
135
165
|
|
|
136
|
-
|
|
166
|
+
The extension emits structured events on `subscription-usage/status/v1` so custom themes or status extensions can render quota data without parsing the footer string. Windows are ordered `5h` -> `1w` -> `1m` -> other. Ready payloads include `displayMode` and, for each window, `displayPercent`, `remainingPercent`, `usedPercent`, and `resetCountdown`.
|
|
137
167
|
|
|
138
168
|
## License
|
|
139
169
|
|
|
140
|
-
[MIT](LICENSE). See [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) for adapted
|
|
170
|
+
[MIT](./LICENSE). See [THIRD_PARTY_NOTICES.md](./THIRD_PARTY_NOTICES.md) for adapted sources and licenses.
|
package/README.zh-CN.md
CHANGED
|
@@ -1,140 +1,170 @@
|
|
|
1
|
-
#
|
|
1
|
+
# pi-subscription-usage
|
|
2
2
|
|
|
3
|
-
[English](README.md) | [简体中文](README.zh-CN.md)
|
|
3
|
+
[English](./README.md) | [简体中文](./README.zh-CN.md)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
一个 [Pi](https://github.com/earendil-works/pi-mono) 扩展:在底部状态栏显示当前订阅还剩多少额度,输入 `/usage` 查看完整明细。
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
底部状态栏效果:
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
```text
|
|
10
|
+
5h 99% ↻2h13m · 1w 85% ↻3d4h
|
|
11
|
+
```
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
- **OpenCode Go**:5 小时、每周和每月窗口。
|
|
13
|
-
- **Grok**:每周和/或每月额度;只使用 Pi 的 `xai` / `xai-auth` OAuth 凭据,并先验证账户身份。若 weekly `currentPeriod` 存在但省略了 `creditUsagePercent`,按已用 0% 处理(proto3 在周期重置后会省略 0)。统一账单账户仍会探测默认月度接口,但 weekly 窗口已经可展示时,月度探测失败不再让整次查询失败。窗口与其他提供商一样使用 `5h / 1w / 1m` 状态格式。
|
|
14
|
-
- **Kimi Coding**:5 小时和每周窗口,以及额度接口返回的会员套餐。
|
|
13
|
+
`/usage` 输出示例:
|
|
15
14
|
|
|
16
|
-
|
|
15
|
+
```text
|
|
16
|
+
OpenAI Codex
|
|
17
|
+
Shared Across Models:
|
|
18
|
+
5h Window ████████████ 99% left · resets 08/27 12:13
|
|
19
|
+
1w Window ██████████░░ 85% left · resets 08/30 14:00
|
|
20
|
+
|
|
21
|
+
gpt-5.6-spark:
|
|
22
|
+
5h Window █░░░░░░░░░░░ 10% left · resets 08/27 11:40
|
|
23
|
+
|
|
24
|
+
Account:
|
|
25
|
+
Email user@example.com
|
|
26
|
+
Plan Pro
|
|
27
|
+
Resets Left 2
|
|
28
|
+
Extra Credit none
|
|
29
|
+
```
|
|
17
30
|
|
|
18
|
-
##
|
|
31
|
+
## 支持的提供商
|
|
19
32
|
|
|
20
|
-
|
|
33
|
+
登录方法:输入 `/login`,先选 `Sign in with an account`(下表记为 Account)或 `Sign in with an API key`(下表记为 API key),再在列表里选下表中的名称。Pi 界面只有英文,这里的选项名称都按界面原文写。
|
|
21
34
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
35
|
+
| 提供商 | `/login` 中选择 | 显示内容 | 重置券 | 额外扩展 |
|
|
36
|
+
| --- | --- | --- | --- | --- |
|
|
37
|
+
| OpenAI (ChatGPT) | Account → `OpenAI`,以及 Account → `OpenAI Codex (legacy)` | ChatGPT 套餐限额、当前应用限额 | 支持(`Account Resets`) | |
|
|
38
|
+
| OpenAI Codex | Account → `OpenAI Codex (legacy)` | `5h`、`1w`、模型专属窗口、账号邮箱 | 支持(`Resets Left`) | |
|
|
39
|
+
| OpenCode Go | API key → `OpenCode Go` | `5h`、`1w`、`1m` | — | |
|
|
40
|
+
| xAI Grok | Account → `xAI` | `1w` 和/或 `1m` | — | |
|
|
41
|
+
| Kimi Coding | Account → `Kimi For Coding` | `5h`、`1w`、会员等级 | — | |
|
|
42
|
+
| Antigravity | Account → `Antigravity` | Gemini(`5h`、`1w`)、Claude 与 GPT(`5h`、`1w`)、Gemini 4 Argon(`1w`)、套餐、邮箱、项目 | — | [`pi-antigravity`](https://www.npmjs.com/package/pi-antigravity) |
|
|
43
|
+
| Claude (Claude Code) | 无需在 Pi 登录,使用 Claude Code 的登录 | `5h`、`1w` | — | [`pi-claude-bridge`](https://www.npmjs.com/package/pi-claude-bridge) 0.9.3 及以上 |
|
|
25
44
|
|
|
26
|
-
|
|
45
|
+
### 提供商说明
|
|
27
46
|
|
|
28
|
-
|
|
29
|
-
pi install npm:@specode/pi-subscription-usage
|
|
30
|
-
```
|
|
47
|
+
#### OpenAI (ChatGPT)
|
|
31
48
|
|
|
32
|
-
|
|
49
|
+
用同一个 ChatGPT 账号和工作区,分别登录 `OpenAI` 和 `OpenAI Codex (legacy)`,平时对话继续用 `OpenAI` 下的模型就行。OpenAI 的用量接口不认 `OpenAI` 这个登录,所以扩展只借 `OpenAI Codex (legacy)` 的登录来读额度。`/usage` 会将网页端的套餐总限额(`Plan limits`)与当前应用限额分开显示(`App Allowance` 表示该应用的配额上限比例,而非剩余额度),底部状态栏显示 `Plan limits`。
|
|
33
50
|
|
|
34
|
-
|
|
35
|
-
pi install /absolute/path/to/pi-subscription-usage
|
|
36
|
-
```
|
|
51
|
+
#### xAI Grok
|
|
37
52
|
|
|
38
|
-
|
|
53
|
+
用 SuperGrok 账号登录(Account → `xAI`)。用 xAI 的 API Key 登录看不到订阅额度。如果你装的是第三方扩展 `pi-xai-oauth`,用它登录也可以。
|
|
39
54
|
|
|
40
|
-
|
|
55
|
+
#### Antigravity
|
|
41
56
|
|
|
42
|
-
|
|
57
|
+
需要 Rahul Arya 发布的 [`pi-antigravity`](https://www.npmjs.com/package/pi-antigravity)([GitHub](https://github.com/Rahularya01/pi-antigravity))。用 `pi install npm:pi-antigravity` 安装,之后 `/login` 的 `Sign in with an account` 列表里才会出现 `Antigravity`。额度分为三个独立的共享池:Gemini 模型(`5h` 与 `1w`)、Claude 与 GPT 模型(`5h` 与 `1w`)、Gemini 4 Argon(`1w`)。底部状态栏显示当前所用模型对应的额度池:用 Claude 或 GPT-OSS 模型时显示 Claude 与 GPT 池,用 Gemini 4 Argon 时显示 Argon 池,其他 Gemini 模型显示 Gemini 池。额度数据只对 Google AI 付费订阅开放;免费账号在 `/usage` 里显示 `Unsupported`,底部状态栏不显示内容,不会报错。
|
|
43
58
|
|
|
44
|
-
|
|
45
|
-
/usage
|
|
46
|
-
```
|
|
59
|
+
已用 `pi-antigravity` 0.11.0 测试。0.1.0 以来的各个版本注册的 provider id、Google 接口地址和凭据格式都相同,预计同样可用。
|
|
47
60
|
|
|
48
|
-
|
|
61
|
+
npm 上有好几个名字相近的包。扩展按 `antigravity` 这个 provider id 识别,并用 Pi 为它提供的凭据向 Google 的 Cloud Code 接口查询额度,所以所用的包既要注册这个 id,模型也要走 Google 的接口。注册 `antigravity` 的包只装一个。截至 2026 年 10 月 31 日:
|
|
49
62
|
|
|
50
|
-
|
|
63
|
+
| 包 | 结果 |
|
|
64
|
+
| --- | --- |
|
|
65
|
+
| `pi-antigravity` | 可用 |
|
|
66
|
+
| `@gwylook/pi-antigravity`、`@dereknex/pi-antigravity`(`pi-antigravity` 的 fork)、`@heyhuynhgiabuu/pi-oauth-antigravity`、`@raquezha/antigravity`、`pi-provider-antigravity` | provider id、Google 接口地址和凭据格式都相同,预计可用,未测试 |
|
|
67
|
+
| `@estebanforge/pi-antigravity-bridge`、`@thoth-agents/pi-antigravity-bridge` | 注册了 `antigravity`,但模型经由本地 Antigravity 桥(`agy-bridge://`)运行:不支持,底部状态栏为空,`/usage` 会说明原因 |
|
|
68
|
+
| `@cortexkit/pi-antigravity-auth`(`google`)、`pi-antigravity-acp-provider` 与 `@dapidev/pi-antigravity-pure`(`antigravity-acp`)、`@ackneal/pi-agy-bridge`(`agy`) | 注册的是别的 provider id,不支持 |
|
|
51
69
|
|
|
52
|
-
|
|
53
|
-
2. 各模型专属分组
|
|
54
|
-
3. `Account`
|
|
70
|
+
#### Claude (Claude Code)
|
|
55
71
|
|
|
56
|
-
|
|
72
|
+
需要 elidickinson 发布的 [`pi-claude-bridge`](https://www.npmjs.com/package/pi-claude-bridge)([GitHub](https://github.com/elidickinson/pi-claude-bridge))0.9.3 及以上版本,0.9.3 是第一个把 Claude Code 的用量数据转交给 Pi 的版本。用 `pi install npm:pi-claude-bridge` 安装,并在 Claude Code 里登录,Pi 这边不用登录。这里指 `claude-bridge` 提供商下的模型;通过 Antigravity 使用的 Claude 模型按上文的 Antigravity 额度池显示。
|
|
57
73
|
|
|
58
|
-
|
|
74
|
+
bridge 没有可查询的用量接口:Claude Code 会在回复中附带当前套餐用量,扩展读取的就是这份数据。因此每个新会话要等收到第一份用量数据,底部状态栏才有内容;`/usage` 不会重新查询,只显示最近一次收到的数值和对应时间;如果某个窗口的重置时间已过,在收到下一份数据之前按未使用显示。扩展不会读取 Claude Code 的凭据。
|
|
59
75
|
|
|
60
|
-
|
|
76
|
+
已用 `pi-claude-bridge` 0.9.3 和 Claude Code 2.1.311(bridge 所带 Agent SDK 内置的版本)测试。如果你让 bridge 改用自己安装的 `claude` 可执行文件(`pathToClaudeCodeExecutable`),较旧的 Claude Code 版本未经测试。
|
|
61
77
|
|
|
62
|
-
|
|
78
|
+
npm 上有好几个名字相近的包。扩展按 `claude-bridge` 这个 provider id 识别,所以所用的包既要注册这个 id,也要转交用量数据。截至 2026 年 10 月 31 日:
|
|
63
79
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
80
|
+
| 包 | 结果 |
|
|
81
|
+
| --- | --- |
|
|
82
|
+
| `pi-claude-bridge` 0.9.3 及以上 | 可用 |
|
|
83
|
+
| `@viniciosrab/pi-claude-bridge` 0.9.4-fork.3 | 用量相关代码与 0.9.3 相同,预计可用,未测试 |
|
|
84
|
+
| `pi-claude-bridge` 0.9.3 以前的版本、`@fractaal/pi-claude-bridge`、`@yassimba/pi-claude-bridge`、`@agimon-ai/po-claude-bridge` | 注册了 `claude-bridge`,但不转交用量:底部状态栏一直为空,`/usage` 一直显示 `Waiting` |
|
|
85
|
+
| `@vanillagreen/pi-claude-bridge`、`pi-claude-subscription`、`pi-claude-directsdk`、`@ramtinj95/pi-claude-delegation` | 注册的是别的 provider id,不支持 |
|
|
86
|
+
|
|
87
|
+
不带 `pi-` 前缀的 npm 包 `claude-bridge` 是一个与此无关的 Claude Code CLI 代理服务器,`pi install npm:claude-bridge` 会装错包。可以用 `pi list` 确认装的是哪个。
|
|
88
|
+
|
|
89
|
+
## 安装
|
|
90
|
+
|
|
91
|
+
从 npm 安装:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
pi install npm:@specode/pi-subscription-usage
|
|
68
95
|
```
|
|
69
96
|
|
|
70
|
-
|
|
97
|
+
从 GitHub 安装:
|
|
71
98
|
|
|
72
|
-
|
|
73
|
-
-
|
|
99
|
+
```bash
|
|
100
|
+
pi install git:github.com/specode/pi-subscription-usage
|
|
101
|
+
```
|
|
74
102
|
|
|
75
|
-
|
|
103
|
+
从本地目录安装(开发调试):
|
|
76
104
|
|
|
77
|
-
|
|
105
|
+
```bash
|
|
106
|
+
pi install /path/to/pi-subscription-usage
|
|
107
|
+
```
|
|
78
108
|
|
|
79
|
-
|
|
109
|
+
## 使用说明
|
|
80
110
|
|
|
81
|
-
|
|
111
|
+
按上面的方法登录,再选一个该提供商的模型,之后:
|
|
82
112
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
4. 使用唯一请求 ID,并在重试时复用同一个 ID。
|
|
113
|
+
- 底部状态栏会自动显示当前额度窗口,在每轮对话结束后及每 5 分钟刷新一次(带 5 分钟缓存)。
|
|
114
|
+
- 执行 `/usage` 会跳过缓存直接拉取最新数据,显示进度条、重置时间(`MM/DD HH:mm`)及账号信息。
|
|
115
|
+
- Claude 例外:不会主动查询额度,只读取 Claude Code 回复中附带的数据(见 [Claude (Claude Code)](#claude-claude-code))。
|
|
87
116
|
|
|
88
|
-
|
|
117
|
+
### 使用重置券(OpenAI 与 Codex)
|
|
89
118
|
|
|
90
|
-
|
|
119
|
+
OpenAI 或 Codex 账号里有可用的限额重置券时,`/usage` 会提供使用入口:
|
|
91
120
|
|
|
92
|
-
-
|
|
93
|
-
-
|
|
121
|
+
- 确认弹窗默认选中 `Cancel (Default)`,必须手动确认才会消耗重置券。
|
|
122
|
+
- 提交兑换前,扩展会检查当前模型和账号是否发生变动,并核对运行时令牌是否与 Pi 保存的 OAuth 登录信息一致。
|
|
123
|
+
- 在 OpenAI 模式下,重置券作用于服务端定义的账户级窗口,不一定单独清空当前应用的限额。
|
|
124
|
+
- 兑换重置券是本扩展唯一的写操作。
|
|
94
125
|
|
|
95
|
-
|
|
126
|
+
## 配置
|
|
96
127
|
|
|
97
|
-
|
|
128
|
+
百分比默认显示剩余额度。如需改为显示已用额度,可在 `~/.pi/agent/subscription-usage.json`(全局)或 `.pi/subscription-usage.json`(受信任项目的局部覆盖)中配置:
|
|
98
129
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
- 凭据只会发送到对应的官方域名;自定义代理和自定义基础 URL 会被拒绝。
|
|
105
|
-
- 账户重置兑换(OpenAI / Codex)是唯一的写操作。只有存在可兑换次数时才会显示,并且始终要求明确确认。
|
|
130
|
+
```json
|
|
131
|
+
{
|
|
132
|
+
"displayMode": "used"
|
|
133
|
+
}
|
|
134
|
+
```
|
|
106
135
|
|
|
107
|
-
|
|
136
|
+
| 配置值 | 说明 |
|
|
137
|
+
| --- | --- |
|
|
138
|
+
| `"remaining"` | 显示剩余额度百分比(默认) |
|
|
139
|
+
| `"used"` | 显示已用额度百分比 |
|
|
108
140
|
|
|
109
|
-
|
|
141
|
+
修改配置文件后执行 `/reload` 生效。`displayMode` 同时作用于底部状态栏、`/usage` 进度条和状态事件。
|
|
110
142
|
|
|
111
|
-
|
|
112
|
-
- 能够直接运行 TypeScript 文件的 Node.js 版本,用于执行测试。
|
|
143
|
+
## 隐私与安全
|
|
113
144
|
|
|
114
|
-
|
|
145
|
+
- 仅从 Pi 自身的登录注册表读取凭据,不读取浏览器 Cookie 或其他工具的凭据文件(例如 Grok 不会读取 `~/.grok/auth.json`;Claude 用量来自 bridge 返回的数据,不读取 Claude Code 存在钥匙串里的凭据)。
|
|
146
|
+
- 仅向各提供商的官方接口发起请求,拒绝自定义代理和自定义 Base URL。
|
|
147
|
+
- 令牌不会写入缓存、会话文件、状态栏或报错信息。
|
|
148
|
+
- 不修改任何模型请求。
|
|
149
|
+
- 部分提供商的用量接口属于未公开接口;若接口变更,扩展会直接报错提示,不会猜测或伪造数据。
|
|
150
|
+
|
|
151
|
+
## 本地开发
|
|
115
152
|
|
|
116
153
|
```bash
|
|
154
|
+
# 运行测试(需要原生支持 TypeScript 的 Node.js 版本)
|
|
117
155
|
npm test
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
检查 npm 包内容:
|
|
121
156
|
|
|
122
|
-
|
|
157
|
+
# 检查打包文件列表
|
|
123
158
|
npm run pack:check
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
不安装、直接加载扩展:
|
|
127
159
|
|
|
128
|
-
|
|
160
|
+
# 不安装直接加载扩展验证
|
|
129
161
|
pi --no-extensions --offline -e ./index.ts --list-models
|
|
130
162
|
```
|
|
131
163
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
OpenAI 应用额度也依赖未公开的 ChatGPT 接口。OpenAI 会拒绝 Sign in with ChatGPT 令牌访问这些 ChatGPT 用量和重置接口(HTTP 401),因此必须配套 Codex 登录:用同一账户/工作区执行一次 `/login openai-codex`。它只用于读取用量,当前模型仍可保持 OpenAI。未登录时,可在 https://chatgpt.com/settings/usage 查看用量。账户/工作区不匹配、找不到应用注册或额度窗口时会报告错误,不展示其他账户的额度。`App Allowance` 表示允许应用使用的套餐份额,不是剩余额度百分比。`Source` 明确标注这是 Pi Codex 登录账户内匹配应用的数据;应用 ID 匹配不是对两套令牌身份的独立验签证明。
|
|
164
|
+
### 主题与状态栏扩展接入
|
|
135
165
|
|
|
136
|
-
|
|
166
|
+
扩展会在 `subscription-usage/status/v1` 事件通道发布结构化状态事件,供自定义主题或状态栏扩展直接渲染额度数据,无需解析状态栏文本。窗口固定按 `5h` -> `1w` -> `1m` -> 其他顺序排列;就绪事件包含 `displayMode`,每个窗口提供 `displayPercent`、`remainingPercent`、`usedPercent` 和 `resetCountdown`。
|
|
137
167
|
|
|
138
168
|
## 许可证
|
|
139
169
|
|
|
140
|
-
|
|
170
|
+
[MIT](./LICENSE)。改编的第三方源码及许可证信息见 [THIRD_PARTY_NOTICES.md](./THIRD_PARTY_NOTICES.md)。
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@specode/pi-subscription-usage",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Show subscription quota for OpenAI, Codex, OpenCode Go, Grok, and
|
|
3
|
+
"version": "1.5.0",
|
|
4
|
+
"description": "Show subscription quota for OpenAI, Codex, OpenCode Go, Grok, Kimi, Antigravity, and Claude (via pi-claude-bridge), plus OpenAI and Codex account reset credits in Pi",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "Specode",
|
|
@@ -22,7 +22,9 @@
|
|
|
22
22
|
"codex",
|
|
23
23
|
"opencode",
|
|
24
24
|
"grok",
|
|
25
|
-
"kimi"
|
|
25
|
+
"kimi",
|
|
26
|
+
"antigravity",
|
|
27
|
+
"claude"
|
|
26
28
|
],
|
|
27
29
|
"files": [
|
|
28
30
|
"index.ts",
|
package/src/format.ts
CHANGED
|
@@ -79,6 +79,7 @@ export function formatProviderState(
|
|
|
79
79
|
let status = "Query Failed";
|
|
80
80
|
if (state.status === "auth-unavailable") status = "Auth Unavailable";
|
|
81
81
|
else if (state.status === "unsupported") status = "Unsupported";
|
|
82
|
+
else if (state.status === "pending") status = "Waiting";
|
|
82
83
|
return `${state.providerName}\n ${status}: ${state.message}`;
|
|
83
84
|
}
|
|
84
85
|
|