@ekworp/opencode-mystatus 0.0.0-stage → 1.2.7

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 javazys
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,228 @@
1
- # Temporary Holding Version
1
+ # opencode-mystatus
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![npm version](https://img.shields.io/npm/v/%40ekworp%2Fopencode-mystatus.svg)](https://www.npmjs.com/package/@ekworp/opencode-mystatus)
4
+ [![npm downloads](https://img.shields.io/npm/dm/%40ekworp%2Fopencode-mystatus)](https://www.npmjs.com/package/@ekworp/opencode-mystatus)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+
7
+ An [OpenCode](https://opencode.ai) plugin to query account quota usage for multiple AI platforms.
8
+
9
+ [中文文档](./README.zh-CN.md)
10
+
11
+ ![Check AI Quota in One Click](./assets/mystatus-banner-en.jpeg)
12
+
13
+ ## Supported Platforms
14
+
15
+ | Platform | Account Type | Data Source |
16
+ | ------------ | ----------------- | ---------------------------------------------- |
17
+ | OpenAI | Plus / Team / Pro | `~/.local/share/opencode/auth.json` |
18
+ | Zhipu AI | Coding Plan | `~/.local/share/opencode/auth.json` |
19
+ | Z.ai | Coding Plan | `~/.local/share/opencode/auth.json` |
20
+ | GitHub Copilot | Individual / Business | `~/.local/share/opencode/auth.json` |
21
+ | Google Cloud | Antigravity | `~/.config/opencode/antigravity-accounts.json` |
22
+
23
+ ## Installation
24
+
25
+ ### Let an LLM do it
26
+
27
+ Paste this into any LLM agent (Claude Code, OpenCode, Cursor, etc.):
28
+
29
+ ```
30
+ Install the opencode-mystatus plugin by following: https://raw.githubusercontent.com/vbgate/opencode-mystatus/main/README.md
31
+ ```
32
+
33
+ <details>
34
+ <summary><b>Instructions for LLM agents</b></summary>
35
+
36
+ To install this plugin, perform these steps:
37
+
38
+ 1. Add `"@ekworp/opencode-mystatus"` to the `plugins` array in `~/.config/opencode/opencode.json`:
39
+
40
+ ```json
41
+ {
42
+ "$schema": "https://opencode.ai/config.json",
43
+ "plugins": ["@ekworp/opencode-mystatus"]
44
+ }
45
+ ```
46
+
47
+ 2. Optionally copy `command/mystatus.md` to `~/.config/opencode/commands/` to enable `/mystatus`.
48
+
49
+ 3. Restart OpenCode.
50
+
51
+ </details>
52
+
53
+ ### Manual Installation
54
+
55
+ 1. Add the plugin and slash command to your `~/.config/opencode/opencode.json`:
56
+
57
+ ```json
58
+ {
59
+ "$schema": "https://opencode.ai/config.json",
60
+ "plugins": ["@ekworp/opencode-mystatus"]
61
+ }
62
+ ```
63
+
64
+ 2. Optionally copy `command/mystatus.md` to `~/.config/opencode/commands/` to enable `/mystatus`.
65
+ 3. Restart OpenCode
66
+
67
+ ### From Local Files
68
+
69
+ Copy the plugin files to your project's OpenCode directory:
70
+
71
+ 1. Copy `plugin/mystatus.ts` and `plugin/lib/` to `.opencode/plugins/`
72
+ 2. Install the project dependencies with `pnpm install`.
73
+ 3. Optionally copy `command/mystatus.md` to `.opencode/commands/` to enable `/mystatus`.
74
+ 4. Restart OpenCode
75
+
76
+ ### GitHub Release
77
+
78
+ Every `v*` tag publishes a single-file V2 plugin build to GitHub Releases:
79
+
80
+ ```text
81
+ https://github.com/ekworp/opencode-mystatus/releases/latest/download/opencode-mystatus.js
82
+ ```
83
+
84
+ Download the file to `.opencode/plugins/mystatus.js` before starting OpenCode. The
85
+ release file still expects OpenCode V2 to provide `@opencode/plugin`.
86
+
87
+ ## Usage
88
+
89
+ ### Option 1: Slash Command
90
+
91
+ Use the `/mystatus` command to get complete quota information:
92
+
93
+ ```
94
+ /mystatus
95
+ ```
96
+
97
+ ### Option 2: Natural Language
98
+
99
+ Simply ask in natural language, for example:
100
+
101
+ - "Check my OpenAI quota"
102
+ - "How much Codex quota do I have left?"
103
+ - "Show my AI account status"
104
+
105
+ OpenCode will automatically use the mystatus tool to answer your question.
106
+
107
+ ## Output Example
108
+
109
+ ```
110
+ ## OpenAI Account Quota
111
+
112
+ Account: user@example.com (team)
113
+
114
+ 3-hour limit
115
+ ██████████████████████████████ 85% remaining
116
+ Resets in: 2h 30m
117
+
118
+ ## Zhipu AI Account Quota
119
+
120
+ Account: 9c89****AQVM (Coding Plan)
121
+
122
+ 5-hour token limit
123
+ ██████████████████████████████ 95% remaining
124
+ Used: 0.5M / 10.0M
125
+ Resets in: 4h
126
+
127
+ ## Z.ai Account Quota
128
+
129
+ Account: 9c89****AQVM (Z.ai)
130
+
131
+ 5-hour token limit
132
+ ██████████████████████████████ 95% remaining
133
+ Used: 0.5M / 10.0M
134
+ Resets in: 4h
135
+
136
+ ## GitHub Copilot Account Quota
137
+
138
+ Account: GitHub Copilot (individual)
139
+
140
+ Premium ████░░░░░░░░░░░░░░░░ 24% (229/300)
141
+
142
+ Quota resets: 19d 0h (2026-02-01)
143
+
144
+ ## Google Cloud Account Quota
145
+
146
+ ### user@gmail.com
147
+
148
+ G3 Pro 4h 59m ████████████████████ 100%
149
+ G3 Image 4h 59m ████████████████████ 100%
150
+ G3 Flash 4h 59m ████████████████████ 100%
151
+ Claude 2d 9h ░░░░░░░░░░░░░░░░░░░░ 0%
152
+ ```
153
+
154
+ ## Features
155
+
156
+ - Query quota usage across multiple AI platforms in one command
157
+ - Visual progress bars showing remaining quota
158
+ - Reset time countdown
159
+ - Multi-language support (Chinese / English)
160
+ - Multiple Google Cloud accounts support
161
+ - API key masking for security
162
+
163
+ ## Configuration
164
+
165
+ No additional configuration required. The plugin automatically reads credentials from:
166
+
167
+ - **OpenAI, Zhipu AI, Z.ai & GitHub Copilot**: `~/.local/share/opencode/auth.json`
168
+ - **Google Cloud**: `~/.config/opencode/antigravity-accounts.json`
169
+
170
+ ### Google Cloud Setup
171
+
172
+ To query Google Cloud (Antigravity) account quota, you need to install the [opencode-antigravity-auth](https://github.com/NoeFabris/opencode-antigravity-auth) plugin first to authenticate your Google account.
173
+
174
+ ## Security
175
+
176
+ This plugin is safe to use:
177
+
178
+ **Local Files Accessed (read-only):**
179
+
180
+ - `~/.local/share/opencode/auth.json` - OpenCode's official auth storage
181
+ - `~/.config/opencode/antigravity-accounts.json` - Antigravity plugin's account storage
182
+
183
+ **API Endpoints (all official):**
184
+
185
+ - `https://chatgpt.com/backend-api/wham/usage` - OpenAI official quota API
186
+ - `https://bigmodel.cn/api/monitor/usage/quota/limit` - Zhipu AI official quota API
187
+ - `https://api.z.ai/api/monitor/usage/quota/limit` - Z.ai official quota API
188
+ - `https://api.github.com/copilot_internal/user` - GitHub Copilot official API
189
+ - `https://oauth2.googleapis.com/token` - Google official OAuth API
190
+ - `https://cloudcode-pa.googleapis.com/v1internal:fetchAvailableModels` - Google Cloud official API
191
+
192
+ **Privacy:**
193
+
194
+ - No data is stored, uploaded, or cached by this plugin
195
+ - Sensitive information (API keys) is automatically masked in output
196
+ - Source code is fully open for review
197
+
198
+ ## Google Cloud Models
199
+
200
+ The plugin displays quota for these models:
201
+
202
+ | Display Name | Model Key |
203
+ | ------------ | ---------------------------------------------- |
204
+ | G3 Pro | `gemini-3-pro-high` / `gemini-3-pro-low` |
205
+ | G3 Image | `gemini-3-pro-image` |
206
+ | G3 Flash | `gemini-3-flash` |
207
+ | Claude | `claude-opus-4-5-thinking` / `claude-opus-4-5` |
208
+
209
+ ## Development
210
+
211
+ ```bash
212
+ # Install dependencies
213
+ pnpm install
214
+
215
+ # Check the code
216
+ pnpm run typecheck
217
+ pnpm run lint
218
+
219
+ # Build the TypeScript distribution
220
+ pnpm run build
221
+ ```
222
+
223
+ Git hooks run the lint and typecheck automatically before commits.
224
+ They are installed by `pnpm install` through Husky.
225
+
226
+ ## License
227
+
228
+ MIT
@@ -0,0 +1,226 @@
1
+ # opencode-mystatus
2
+
3
+ [![npm version](https://img.shields.io/npm/v/%40ekworp%2Fopencode-mystatus.svg)](https://www.npmjs.com/package/@ekworp/opencode-mystatus)
4
+ [![npm 总下载量](https://img.shields.io/npm/dm/%40ekworp%2Fopencode-mystatus)](https://www.npmjs.com/package/@ekworp/opencode-mystatus)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+
7
+ [OpenCode](https://opencode.ai) 插件,用于查询多个 AI 平台的账号额度使用情况。
8
+
9
+ [English](./README.md)
10
+
11
+ ![AI额度一键查](./assets/mystatus-banner-zh.jpeg)
12
+
13
+ ## 支持的平台
14
+
15
+ | 平台 | 账号类型 | 数据来源 |
16
+ | ------------ | ----------------- | ---------------------------------------------- |
17
+ | OpenAI | Plus / Team / Pro | `~/.local/share/opencode/auth.json` |
18
+ | 智谱 AI | Coding Plan | `~/.local/share/opencode/auth.json` |
19
+ | Z.ai | Coding Plan | `~/.local/share/opencode/auth.json` |
20
+ | GitHub Copilot | Individual / Business | `~/.local/share/opencode/auth.json` |
21
+ | Google Cloud | Antigravity | `~/.config/opencode/antigravity-accounts.json` |
22
+
23
+ ## 安装
24
+
25
+ ### 让 AI 帮你安装
26
+
27
+ 将以下内容粘贴到任意 AI 代理(Claude Code、OpenCode、Cursor 等):
28
+
29
+ ```
30
+ Install the opencode-mystatus plugin by following: https://raw.githubusercontent.com/vbgate/opencode-mystatus/main/README.md
31
+ ```
32
+
33
+ <details>
34
+ <summary><b>AI 代理安装指令</b></summary>
35
+
36
+ 安装此插件需要执行以下步骤:
37
+
38
+ 1. 在 `~/.config/opencode/opencode.json` 的 `plugins` 数组中添加 `"@ekworp/opencode-mystatus"`:
39
+
40
+ ```json
41
+ {
42
+ "$schema": "https://opencode.ai/config.json",
43
+ "plugins": ["@ekworp/opencode-mystatus"]
44
+ }
45
+ ```
46
+
47
+ 2. 如需启用 `/mystatus`,将 `command/mystatus.md` 复制到 `~/.config/opencode/commands/`。
48
+ 3. 重启 OpenCode。
49
+
50
+ </details>
51
+
52
+ ### 手动安装
53
+
54
+ 1. 在 `~/.config/opencode/opencode.json` 中添加插件和斜杠命令:
55
+
56
+ ```json
57
+ {
58
+ "$schema": "https://opencode.ai/config.json",
59
+ "plugins": ["@ekworp/opencode-mystatus"]
60
+ }
61
+ ```
62
+
63
+ 2. 如需启用 `/mystatus`,将 `command/mystatus.md` 复制到 `~/.config/opencode/commands/`。
64
+ 3. 重启 OpenCode
65
+
66
+ ### 从本地文件安装
67
+
68
+ 将插件文件复制到 OpenCode 配置目录:
69
+
70
+ 1. 将 `plugin/mystatus.ts` 和 `plugin/lib/` 复制到项目的 `.opencode/plugins/`
71
+ 2. 执行 `pnpm install` 安装依赖。
72
+ 3. 如需启用 `/mystatus`,将 `command/mystatus.md` 复制到 `.opencode/commands/`。
73
+ 4. 重启 OpenCode
74
+
75
+ ### GitHub Release
76
+
77
+ 每个 `v*` 标签都会在 GitHub Release 中发布单文件 V2 插件:
78
+
79
+ ```text
80
+ https://github.com/ekworp/opencode-mystatus/releases/latest/download/opencode-mystatus.js
81
+ ```
82
+
83
+ 启动 OpenCode 前,将文件下载到项目的 `.opencode/plugins/mystatus.js`。
84
+ 该文件依赖 OpenCode V2 提供的 `@opencode/plugin`。
85
+
86
+ ## 使用方法
87
+
88
+ ### 方式一:斜杠命令
89
+
90
+ 使用 `/mystatus` 命令获取完整的额度信息:
91
+
92
+ ```
93
+ /mystatus
94
+ ```
95
+
96
+ ### 方式二:自然语言
97
+
98
+ 直接用自然语言提问,例如:
99
+
100
+ - "帮我查看 Codex 的额度"
101
+ - "我的 OpenAI 还剩多少额度?"
102
+ - "查看 AI 账号状态"
103
+
104
+ OpenCode 会自动调用 mystatus 工具来回答你的问题。
105
+
106
+ ## 输出示例
107
+
108
+ ```
109
+ ## OpenAI 账号额度
110
+
111
+ Account: user@example.com (team)
112
+
113
+ 3小时限额
114
+ ██████████████████████████████ 剩余 85%
115
+ 重置: 2小时30分钟后
116
+
117
+ ## 智谱 AI 账号额度
118
+
119
+ Account: 9c89****AQVM (Coding Plan)
120
+
121
+ 5 小时 Token 限额
122
+ ██████████████████████████████ 剩余 95%
123
+ 已用: 0.5M / 10.0M
124
+ 重置: 4小时后
125
+
126
+ ## Z.ai 账号额度
127
+
128
+ Account: 9c89****AQVM (Z.ai)
129
+
130
+ 5 小时 Token 限额
131
+ ██████████████████████████████ 剩余 95%
132
+ 已用: 0.5M / 10.0M
133
+ 重置: 4小时后
134
+
135
+ ## GitHub Copilot Account Quota
136
+
137
+ Account: GitHub Copilot (individual)
138
+
139
+ Premium ████░░░░░░░░░░░░░░░░ 24% (229/300)
140
+
141
+ Quota resets: 19d 0h (2026-02-01)
142
+
143
+ ## Google Cloud 账号额度
144
+
145
+ ### user@gmail.com
146
+
147
+ G3 Pro 4h 59m ████████████████████ 100%
148
+ G3 Image 4h 59m ████████████████████ 100%
149
+ G3 Flash 4h 59m ████████████████████ 100%
150
+ Claude 2d 9h ░░░░░░░░░░░░░░░░░░░░ 0%
151
+ ```
152
+
153
+ ## 功能特性
154
+
155
+ - 一条命令查询多个 AI 平台的额度使用情况
156
+ - 可视化进度条显示剩余额度
157
+ - 重置时间倒计时
158
+ - 多语言支持(中文 / 英文)
159
+ - 支持多个 Google Cloud 账号
160
+ - API Key 脱敏显示,保护安全
161
+
162
+ ## 配置
163
+
164
+ 无需额外配置。插件自动从以下位置读取认证信息:
165
+
166
+ - **OpenAI、智谱 AI、Z.ai 和 GitHub Copilot**: `~/.local/share/opencode/auth.json`
167
+ - **Google Cloud**: `~/.config/opencode/antigravity-accounts.json`
168
+
169
+ ### Google Cloud 设置
170
+
171
+ 如需查询 Google Cloud (Antigravity) 账号额度,需要先安装 [opencode-antigravity-auth](https://github.com/NoeFabris/opencode-antigravity-auth) 插件来完成 Google 账号认证。
172
+
173
+ ## 安全性
174
+
175
+ 本插件可以安全放心使用:
176
+
177
+ **读取的本地文件(只读):**
178
+
179
+ - `~/.local/share/opencode/auth.json` - OpenCode 官方认证存储
180
+ - `~/.config/opencode/antigravity-accounts.json` - Antigravity 插件的账号存储
181
+
182
+ **请求的 API 接口(均为官方接口):**
183
+
184
+ - `https://chatgpt.com/backend-api/wham/usage` - OpenAI 官方额度查询接口
185
+ - `https://bigmodel.cn/api/monitor/usage/quota/limit` - 智谱 AI 官方额度查询接口
186
+ - `https://api.z.ai/api/monitor/usage/quota/limit` - Z.ai 官方额度查询接口
187
+ - `https://api.github.com/copilot_internal/user` - GitHub Copilot 官方 API
188
+ - `https://oauth2.googleapis.com/token` - Google 官方 OAuth 接口
189
+ - `https://cloudcode-pa.googleapis.com/v1internal:fetchAvailableModels` - Google Cloud 官方接口
190
+
191
+ **隐私保护:**
192
+
193
+ - 插件不会保存、上传或缓存任何用户数据
194
+ - 敏感信息(API Key)在输出时自动脱敏显示
195
+ - 源代码完全开源,可随时审查
196
+
197
+ ## Google Cloud 模型
198
+
199
+ 插件显示以下模型的额度:
200
+
201
+ | 显示名称 | 模型 Key |
202
+ | -------- | ---------------------------------------------- |
203
+ | G3 Pro | `gemini-3-pro-high` / `gemini-3-pro-low` |
204
+ | G3 Image | `gemini-3-pro-image` |
205
+ | G3 Flash | `gemini-3-flash` |
206
+ | Claude | `claude-opus-4-5-thinking` / `claude-opus-4-5` |
207
+
208
+ ## 开发
209
+
210
+ ```bash
211
+ # 安装依赖
212
+ pnpm install
213
+
214
+ # 检查代码
215
+ pnpm run typecheck
216
+ pnpm run lint
217
+
218
+ # 编译 TypeScript
219
+ pnpm run build
220
+ ```
221
+
222
+ Git hook 会在提交前自动执行 lint 与类型检查,执行 `pnpm install` 时由 Husky 自动安装。
223
+
224
+ ## 许可证
225
+
226
+ MIT
@@ -0,0 +1,5 @@
1
+ ---
2
+ description: Query quota usage for all AI accounts
3
+ ---
4
+
5
+ Use the mystatus tool to query quota usage. Return the result as-is without modification.
@@ -0,0 +1,21 @@
1
+ /**
2
+ * GitHub Copilot Premium Requests Quota Module
3
+ *
4
+ * [Input]: GitHub token from ~/.local/share/opencode/auth.json (github-copilot provider)
5
+ * [Output]: Formatted quota usage information with progress bars
6
+ * [Location]: Called by mystatus.ts to handle GitHub Copilot accounts
7
+ * [Sync]: mystatus.ts, types.ts, utils.ts, i18n.ts
8
+ *
9
+ * [Updated]: Jan 2026 - Handle new OpenCode official partnership auth flow
10
+ * The new OAuth tokens (gho_) need to be exchanged for Copilot session tokens
11
+ * before calling the internal quota API.
12
+ */
13
+ import type { CopilotAuthData, QueryResult } from "./types";
14
+ export type { CopilotAuthData };
15
+ /**
16
+ * Query GitHub Copilot account quota
17
+ * @param authData GitHub Copilot authentication data (optional if using PAT config)
18
+ * @returns Query result, null if no account configured
19
+ */
20
+ export declare function queryCopilotUsage(authData: CopilotAuthData | undefined): Promise<QueryResult | null>;
21
+ //# sourceMappingURL=copilot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copilot.d.ts","sourceRoot":"","sources":["../../../plugin/lib/copilot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,OAAO,KAAK,EACV,eAAe,EAGf,WAAW,EACZ,MAAM,SAAS,CAAC;AAmcjB,YAAY,EAAE,eAAe,EAAE,CAAC;AAEhC;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,eAAe,GAAG,SAAS,GACpC,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAuC7B"}