pi-subs
Subscription usage panel for pi: OpenCode Go, Kimi For Coding, OpenAI Codex, Command Code, Claude Pro/Max, GitHub Copilot, Z.AI, OpenRouter — as a widget and status line in pi TUI and pi Web.
Package details
Install pi-subs from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:pi-subs- Package
pi-subs- Version
0.1.0- Published
- Aug 31, 2026
- Downloads
- 134/mo · 9/wk
- Author
- wonton1984
- License
- MIT
- Types
- extension
- Size
- 91.2 KB
- Dependencies
- 0 dependencies · 1 peer
Pi manifest JSON
{
"extensions": [
"./src/index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
⌁ pi-subs — 订阅用量面板(pi coding agent)
在 pi coding agent 的 pi Web 与 TUI 中,聚合显示你的各个订阅的实时用量。
支持的订阅:
| 订阅 | 数据源 | 认证方式 |
|---|---|---|
| OpenCode Go / Zen | opencode.ai/zen/go/v1/usage |
pi 内 /login 或 API key |
| Kimi For Coding | api.kimi.com/coding/v1/usages |
pi 内 /login 或 API key |
| OpenAI Codex | chatgpt.com/backend-api/wham/usage |
pi 内 /login(OAuth 自动刷新) |
| Command Code | api.commandcode.ai/alpha/* |
pi 内 /login |
| Claude Pro / Max | api.anthropic.com/api/oauth/usage |
pi 内 /login(OAuth) |
| GitHub Copilot | api.github.com/copilot_internal/user |
pi 内 /login(OAuth) |
| Z.AI / GLM Coding Plan | {baseUrl}/api/monitor/usage/quota/limit |
pi 内 /login |
| OpenRouter | openrouter.ai/api/v1/key |
API key |
未登录的订阅自动隐藏,只显示你实际在用的。
界面
- 状态栏(底部一行):显示全部已登录订阅,当前会话所用订阅带
▸高亮; 配置为current时只显示当前订阅,off时隐藏。 - widget(可选,默认开):一行一个订阅的详细面板(进度条 / 用量 / 重置倒计时),
pi Web 中默认折叠,点击输入框上方的
subs按钮展开。 - 未登录的订阅不出现在任何位置;请求失败显示
✗并回退到最近一次成功数据(带 ⌛ 标记)。
命令:
/subs 强制刷新并显示摘要
/subs status 各订阅详细状态
/subs off / on 开关面板(写入配置)
安装
pi install npm:pi-subs
# 或从 GitHub:
pi install git:github.com/wonton1984/pi-subs
# 本地试用:
pi -e ./pi-subs
需要 Pi ≥ 0.84(用到 ctx.ui.setWidget 与 modelRegistry.getProviderAuth)。
在 pi Web 中已开的旧会话需要 /reload(或在 pi Web 输入 /reload)才会加载新装的扩展。
配置 ~/.pi/agent/pi-subs.json(可选)
{
"refreshMinutes": 10,
"widget": true,
"statusline": "all",
"widgetPlacement": "aboveEditor",
"providers": {
"opencode": true, "kimi": true, "codex": true, "commandcode": true,
"claude": true, "copilot": true, "zai": true, "openrouter": true
}
}
statusline:"all"(全部订阅一行,当前高亮)/"current"(只显示当前订阅)/"off"refreshMinutes: 自动刷新间隔(1–1440,默认 10;连续失败时指数退避,上限 1 小时)providers: 按订阅开关
隐私与安全
- 用量查询直连各服务商官方端点,凭证只发往对应官方域名。
- 错误信息会先脱敏(Bearer token、API key 模式)再显示。
- 最近一次成功数据缓存于
~/.pi/agent/pi-subs-cache.json,仅本机使用。
已知限制
- Claude 的用量接口未公开文档化,对部分账号有激进限频(anthropics/claude-code#30930); 失败时面板显示缓存数据。
- Codex 用量接口
wham/usage较新,如服务商调整需更新解析器。 - 状态栏各订阅的取值为主窗口(5h 滚动窗 / 周配额 / 月度 credits,视订阅而定)。
致谢
- pi-commandcode-provider(MIT, Pat Woz)— Command Code 配额抓取与解析
- @narumitw/pi-usage(MIT, narumiruna)— OpenCode / Kimi / Codex / Copilot / Z.AI / OpenRouter 的响应解析器
License
MIT