dsh-quotacat 0.0.0-stage → 0.3.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 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,103 @@
1
- # Temporary Holding Version
1
+ # dsh-quotacat
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
+ QuotaCat for DeepSeek Harness — LLM 服务商用量与额度监控插件。
4
+
5
+ 已支持:
6
+
7
+ - **GLM Coding Plan**:5h 窗口 / 月度 MCP / 套餐等级 / 24h 工具调用
8
+ - **DeepSeek API**(计费账户):余额 / 赠送金 / 账户状态
9
+
10
+ 更多 provider 持续接入中。
11
+
12
+ ## 功能
13
+
14
+ ### 输入框统计条额度 pill
15
+
16
+ 在输入框下方统计条(轮次/步数、tok/s、缓存命中那一行)的末尾追加一个额度 pill:
17
+
18
+ - 显示当前服务商的 5 小时窗口用量百分比,按用量分级变色(绿 <60% / 黄 <85% / 红 ≥85%)
19
+ - **跟随当前模型**:GLM 显示 5h 百分比,DeepSeek 显示 API 余额;切换到未支持的服务商时半透明置灰
20
+ - 点击弹出详情面板(与宿主统计 pill 同款交互:固定定位、Esc/点外部关闭):
21
+ - 套餐等级、5h 窗口(用量/重置时间,跨天带日期)
22
+ - 24 小时滚动工具调用 + 本月 MCP 工具细分
23
+ - 手动刷新、数据更新时间
24
+
25
+ ### 阈值提醒
26
+
27
+ 5h 用量达到阈值(默认 80%,可调 50–95%)时弹出全局提醒 Toast,回落到阈值下方后自动复位(同一窗口只提醒一次)。阈值与开关可在设置视图里调整。
28
+
29
+ ### `quota` agent 工具
30
+
31
+ 对话中直接问「额度还剩多少」「5h 窗口什么时候重置」,agent 自动调用 `quota` 工具返回结果。
32
+
33
+ ### 设置
34
+
35
+ pill 弹框内切换设置视图:刷新频率(1–60 分钟或仅手动)、阈值提醒开关与阈值。配置热生效,无需重启。
36
+
37
+ ## 零配置
38
+
39
+ 无需手动配置 API Key:
40
+
41
+ - **GLM Coding Plan**:自动解析 `ZAI_CODING_CN_API_KEY`(DSH 登录时自动存入)
42
+ - **DeepSeek API**:解析 `DEEPSEEK_API_KEY`(API 计费账户的 key;订阅登录无公开余额接口)
43
+ - 兜底顺序:宿主凭据 → 环境变量(对应各家的 `*_API_KEY`)
44
+
45
+ ## 安装
46
+
47
+ ```bash
48
+ # 在 DSH profile 目录(~/.dsh/profiles/<profile>)里:
49
+ pnpm add dsh-quotacat
50
+ ```
51
+
52
+ 再在 profile 的 `cordis.patch.yml` 末尾追加:
53
+
54
+ ```yaml
55
+ - insert:
56
+ - id: quotacat
57
+ name: dsh-quotacat
58
+ ```
59
+
60
+ 重启 DSH 生效。
61
+
62
+ ## 指示器跟随模型的已知局限
63
+
64
+ DSH 客户端目前无法感知「模型选择器」的当前值,插件只能跟随**实际发生**的模型调用(监听 `llm/stream` 事件,按会话记录)。同时开多个会话使用不同模型时,pill 显示最近活跃的一家。
65
+
66
+ ## 开发
67
+
68
+ ```bash
69
+ npm install
70
+ npm run check # typecheck + build
71
+ npm test # placePanel 定位纯函数 + slot 注册单测
72
+ ```
73
+
74
+ ### 提交规范(Conventional Commits)
75
+
76
+ ```
77
+ <type>: <英文祈使句主题,不加句号>
78
+
79
+ <body 可选:bullet 说明 what/why>
80
+ ```
81
+
82
+ 类型限定 `feat` / `fix` / `docs` / `test` / `refactor` / `chore` / `perf`;主题与正文一律英文;一个提交只做一件事。
83
+
84
+ ### 结构
85
+
86
+ ```
87
+ src/index.ts host 侧:查询/缓存/HTTP 路由/quota 工具/阈值
88
+ src/glm.ts GLM API 客户端(额度 + 24h 工具用量)
89
+ src/shared/api.ts 类型与路由常量(host/client 共用)
90
+ src/client.tsx 浏览器模块入口(ModuleLoader 格式)
91
+ src/client/main.tsx client 装配:locale + pill + toast
92
+ src/client/QuotaCatFooter.ts pill + 详情/设置双视图弹框
93
+ src/client/QuotaAlertToast.ts 阈值提醒 Toast
94
+ src/client/anchoredPosition.ts 面板定位纯函数(含单测)
95
+ src/client/registerQuota.ts slot 注册
96
+ src/client/runtime.ts React/react-dom/require 运行时注入容器
97
+ src/client/model.ts host API 封装
98
+ src/client/styles.ts 主题变量样式(对齐宿主 stat-dialog 规格)
99
+ ```
100
+
101
+ ## License
102
+
103
+ MIT
@@ -0,0 +1,14 @@
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
+ # 自动刷新间隔(分钟),0 = 只在打开面板/调用工具时拉取
9
+ refreshMinutes: 10
10
+ baseURL: 'https://open.bigmodel.cn'
11
+ # 额度阈值提醒:5h 用量达到阈值时在面板标记一次,回落到阈值下方后复位
12
+ notificationEnabled: true
13
+ # 阈值 [0.5, 0.95],默认 0.8
14
+ notificationThreshold: 0.8