dsh-quotacat 0.0.0-stage → 0.2.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 +68 -2
- package/cordis.patch.yml +17 -0
- package/dist/client.js +823 -0
- package/dist/index.js +591 -0
- package/package.json +67 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 QuotaCat contributors
|
|
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,69 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-quotacat
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
QuotaCat for DeepSeek Harness — LLM 服务商用量与额度监控插件。
|
|
4
|
+
|
|
5
|
+
当前支持 **GLM Coding Plan**(5h 窗口 / 月度 MCP / 套餐等级 / 24h 工具调用),更多 provider 持续接入中。
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## 功能
|
|
9
|
+
|
|
10
|
+
- **输入框统计条 pill**:`额度 62%`,百分比按用量分级变色(绿 <60 / 黄 <85 / 红 ≥85),点击弹出详情面板
|
|
11
|
+
- **详情面板**:套餐等级、5 小时 token 窗口、本月 MCP 工具用量细分、重置时间,手动刷新
|
|
12
|
+
- **`quota` agent 工具**:对话中直接问"额度还剩多少"即可触发
|
|
13
|
+
- **右下角悬浮球**:🐱 常驻指示 + 展开面板(旧入口,可按需关闭)
|
|
14
|
+
|
|
15
|
+
## 零配置
|
|
16
|
+
|
|
17
|
+
插件自动通过宿主凭据服务解析 `ZAI_CODING_CN_API_KEY`(DSH 登录 GLM Coding Plan 时自动存入),无需手动配置 API Key。备选顺序:插件配置 `apiKey` → 宿主凭据 → 环境变量(`QUOTACAT_API_KEY` / `GLM_API_KEY` / `ZHIPU_API_KEY`)。
|
|
18
|
+
|
|
19
|
+
## 指示器跟随模型
|
|
20
|
+
|
|
21
|
+
监听宿主 `llm/stream` 事件,按会话记录实际使用的 provider;pill 在当前模型不属于 GLM 家族时半透明置灰。
|
|
22
|
+
|
|
23
|
+
> 已知局限:客户端无法感知"模型选择器"的当前值,只能跟随实际发生的调用。这是向 DSH 社区提案的方向之一(`conversation.model.changed` 事件 / `model-state` 客户端服务)。
|
|
24
|
+
|
|
25
|
+
## 开发
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install
|
|
29
|
+
npm run check # typecheck + build
|
|
30
|
+
npm test # placePanel 定位纯函数 + slot 注册单测
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### 提交规范(Conventional Commits)
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
<type>: <英文祈使句主题,不加句号>
|
|
37
|
+
|
|
38
|
+
<body 可选:bullet 说明 what/why>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
类型限定 `feat` / `fix` / `docs` / `test` / `refactor` / `chore` / `perf`;主题与正文一律英文;一个提交只做一件事。
|
|
42
|
+
|
|
43
|
+
本地安装到 profile(`~/.dsh/profiles/desktop/package.json`):
|
|
44
|
+
|
|
45
|
+
```json
|
|
46
|
+
{ "dependencies": { "dsh-quotacat": "file:<本项目路径>" } }
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
再在 profile 的 `cordis.patch.yml` 加插件行(见 `cordis.patch.yml`)。
|
|
50
|
+
|
|
51
|
+
## 结构
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
src/index.ts host 侧:GLM 查询/缓存/HTTP 路由/quota 工具
|
|
55
|
+
src/glm.ts GLM API 客户端
|
|
56
|
+
src/shared/api.ts 类型与路由常量(host/client 共用)
|
|
57
|
+
src/client.tsx 浏览器模块入口(ModuleLoader 格式)
|
|
58
|
+
src/client/main.tsx client 装配:locale + composer dock pill
|
|
59
|
+
src/client/QuotaCatFooter.ts pill + 详情面板
|
|
60
|
+
src/client/anchoredPosition.ts 面板定位纯函数(含单测)
|
|
61
|
+
src/client/registerQuota.ts slot 注册
|
|
62
|
+
src/client/runtime.ts React/react-dom/require 运行时注入容器
|
|
63
|
+
src/client/model.ts host API 封装
|
|
64
|
+
src/client/styles.ts 主题变量样式(对齐宿主 stat-dialog 规格)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## License
|
|
68
|
+
|
|
69
|
+
MIT
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# dsh-quotacat bundle patch — one row that is simultaneously the host
|
|
2
|
+
# plugin (node half, package main -> dist/index.js) and the browser roster
|
|
3
|
+
# entry (dsh.client declaration -> dist/client.js).
|
|
4
|
+
- insert:
|
|
5
|
+
- id: quotacat
|
|
6
|
+
name: dsh-quotacat
|
|
7
|
+
config:
|
|
8
|
+
# GLM API Key:默认自动获取(宿主登录凭据 → 环境变量),一般无需填写;
|
|
9
|
+
# 此字段仅作显式覆盖用
|
|
10
|
+
apiKey: ''
|
|
11
|
+
# 自动刷新间隔(分钟),0 = 只在打开面板/调用工具时拉取
|
|
12
|
+
refreshMinutes: 10
|
|
13
|
+
baseURL: 'https://open.bigmodel.cn'
|
|
14
|
+
# 额度阈值提醒:5h 用量达到阈值时在面板标记一次,回落到阈值下方后复位
|
|
15
|
+
notificationEnabled: true
|
|
16
|
+
# 阈值 [0.5, 0.95],默认 0.8
|
|
17
|
+
notificationThreshold: 0.8
|