opencode-subscription-monitor 0.1.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/LICENSE +21 -0
- package/README.md +96 -0
- package/dist/index.js +12934 -0
- package/package.json +51 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 zenobi.us
|
|
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
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# OpenCode 订阅监控插件
|
|
2
|
+
|
|
3
|
+
在 OpenCode 中直接监控 GitHub Copilot 和 OpenAI 的订阅配额。
|
|
4
|
+
|
|
5
|
+
## 功能特性
|
|
6
|
+
|
|
7
|
+
- **GitHub Copilot 监控**: 追踪席位分配、使用指标和采纳率
|
|
8
|
+
- **OpenAI API 监控**: 监控 Token 使用量、请求数和速率限制
|
|
9
|
+
- **自定义工具**: AI 可调用的配额查询工具
|
|
10
|
+
- **斜杠命令**: `/quota` 和 `/refresh-quota` 快速访问
|
|
11
|
+
- **自动刷新**: 启动和新会话时自动刷新数据
|
|
12
|
+
- **统一认证**: 自动读取 OpenCode 的登录授权,无需额外配置
|
|
13
|
+
|
|
14
|
+
## 安装
|
|
15
|
+
|
|
16
|
+
### 方式一:全局安装
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
cp -r dist ~/.config/opencode/plugin/subscription-monitor/
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### 方式二:项目级安装
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
cp -r dist .opencode/plugin/subscription-monitor/
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## 认证配置
|
|
29
|
+
|
|
30
|
+
插件会自动读取 OpenCode 的授权信息(`~/.local/share/opencode/auth.json`),如果你已经在 OpenCode 中登录过 GitHub Copilot 或 OpenAI,无需额外配置。
|
|
31
|
+
|
|
32
|
+
### GitHub Copilot
|
|
33
|
+
|
|
34
|
+
**方式一(推荐)**: 在 OpenCode 中登录 GitHub Copilot,插件会自动使用该授权。
|
|
35
|
+
|
|
36
|
+
**方式二**: 手动设置环境变量:
|
|
37
|
+
```bash
|
|
38
|
+
export GITHUB_TOKEN="ghp_xxxx" # 需要 read:org 和 manage_billing:copilot 权限
|
|
39
|
+
export GITHUB_ORG="your-org" # 你的 GitHub 组织名称
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
> ⚠️ **注意**: Copilot API 仅支持 Business/Enterprise 订阅,个人订阅无法通过 API 查询。
|
|
43
|
+
|
|
44
|
+
### OpenAI
|
|
45
|
+
|
|
46
|
+
**方式一(推荐)**: 在 OpenCode 中登录 OpenAI,插件会自动使用该授权。
|
|
47
|
+
|
|
48
|
+
**方式二**: 手动设置环境变量:
|
|
49
|
+
```bash
|
|
50
|
+
export OPENAI_API_KEY="sk-xxxx"
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## 使用方法
|
|
54
|
+
|
|
55
|
+
### 斜杠命令
|
|
56
|
+
|
|
57
|
+
| 命令 | 说明 |
|
|
58
|
+
|------|------|
|
|
59
|
+
| `/quota` | 显示订阅配额摘要 |
|
|
60
|
+
| `/refresh-quota` | 刷新所有配额数据 |
|
|
61
|
+
|
|
62
|
+
### 自定义工具
|
|
63
|
+
|
|
64
|
+
| 工具名称 | 说明 |
|
|
65
|
+
|----------|------|
|
|
66
|
+
| `check_copilot_quota` | 查询 GitHub Copilot 订阅配额和使用情况 |
|
|
67
|
+
| `check_openai_usage` | 查询 OpenAI API 使用量和速率限制 |
|
|
68
|
+
| `refresh_subscription_quotas` | 刷新所有订阅配额数据 |
|
|
69
|
+
| `get_subscription_summary` | 获取所有配额的简洁摘要 |
|
|
70
|
+
|
|
71
|
+
### 示例提示词
|
|
72
|
+
|
|
73
|
+
- "查看我的 Copilot 使用情况"
|
|
74
|
+
- "今天用了多少 OpenAI Token?"
|
|
75
|
+
- "显示订阅摘要"
|
|
76
|
+
- "刷新配额数据"
|
|
77
|
+
|
|
78
|
+
## 开发
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
npm install
|
|
82
|
+
npm run build
|
|
83
|
+
npm run typecheck
|
|
84
|
+
npm run lint
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## API 限制
|
|
88
|
+
|
|
89
|
+
| 服务 | 限制说明 |
|
|
90
|
+
|------|----------|
|
|
91
|
+
| GitHub Copilot | 仅 Business/Enterprise 订阅。需要 `read:org` + `manage_billing:copilot` 权限 |
|
|
92
|
+
| OpenAI | 使用数据可能有 24 小时延迟,速率限制是实时的 |
|
|
93
|
+
|
|
94
|
+
## 许可证
|
|
95
|
+
|
|
96
|
+
MIT
|