dsh-ollama-usage 0.1.11 → 0.1.12
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/README.en.md +137 -0
- package/README.md +39 -17
- package/package.json +9 -3
package/README.en.md
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# ⚡ dsh-ollama-usage
|
|
4
|
+
|
|
5
|
+
**Ollama Cloud usage & remaining-quota visualization · a DeepSeek Harness plugin**
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/dsh-ollama-usage)
|
|
8
|
+
[](https://www.npmjs.com/package/dsh-ollama-usage)
|
|
9
|
+
[](LICENSE)
|
|
10
|
+
[](package.json)
|
|
11
|
+
[](https://github.com/SeverusZh/dsh-ollama-usage/releases)
|
|
12
|
+
[](https://github.com/SeverusZh/dsh-ollama-usage)
|
|
13
|
+
[](https://github.com/deepseek-ai/deepseek-harness)
|
|
14
|
+
[](https://awesome-dsh-plugin.com)
|
|
15
|
+
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
Ollama Cloud usage & remaining-quota visualization for DeepSeek Harness —
|
|
19
|
+
5-hour session + weekly quota, always-visible sidebar bars, a full panel on the
|
|
20
|
+
plugin's own detail page, persisted credentials & snapshots, auto-refresh.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## ✨ 功能特性 / Features
|
|
25
|
+
|
|
26
|
+
| Capability | Description |
|
|
27
|
+
| --- | --- |
|
|
28
|
+
| 🎯 **Session usage (per 5 hours)** | Ollama Cloud's 5-hour session quota, pinned at the top showing "used X% · remaining Y%" |
|
|
29
|
+
| 📅 **Weekly usage** | This week's quota progress, shown next to the session usage |
|
|
30
|
+
| 🎨 **Sidebar dual bars** | Minimal, transparent style: session 5h in **light purple** + weekly in **deep purple**, each with a percentage, details on hover, refreshed every 60 seconds (auto-hidden on narrow layouts) |
|
|
31
|
+
| 🖥️ **Full panel on the plugin detail page** | Rendered between the description and component rows of the "Plugin list → dsh-ollama-usage" page: session/week usage bars, session and weekly reset countdowns, and the last 5 session-usage history entries |
|
|
32
|
+
| 💾 **Persistence** | The API Key and usage snapshot are written to `$DSH_HOME/storages/ollama-usage/usage.json` (mode 600, 24 history entries kept), restored automatically across conversations / restarts |
|
|
33
|
+
| 🔄 **Auto-refresh** | The host queries every 10 minutes (even when the page is closed); an invalidated Key (401) is cleared automatically with a prompt |
|
|
34
|
+
| 🔑 **Login guidance** | When not signed in, one click opens [ollama.com/settings](https://ollama.com/settings) to sign in and [settings/keys](https://ollama.com/settings/keys) to create an API Key; compatible with the legacy CLI's `~/.ollama/auth.json` |
|
|
35
|
+
|
|
36
|
+
The quota progress data comes from Ollama's official endpoint `GET https://ollama.com/api/balance`
|
|
37
|
+
(the `remaining_percent` and `resets_at` of `included.session` / `included.weekly`), matching the
|
|
38
|
+
[ollama.com/settings](https://ollama.com/settings) page.
|
|
39
|
+
|
|
40
|
+
> **v0.1.11 fix**: in 2026-10 Ollama changed `GET /api/usage` to return only hourly/daily
|
|
41
|
+
> request-volume buckets and no longer include `limits.session` / `limits.weekly`, so older
|
|
42
|
+
> versions parsed both percentages as `null` — the panel showed "no data" and the sidebar bars
|
|
43
|
+
> showed "—". Quota progress now comes from `/api/balance` (`used = 100 - remaining_percent`),
|
|
44
|
+
> and the reset countdown uses the real `resets_at` sent by the endpoint.
|
|
45
|
+
|
|
46
|
+
## 📦 安装 / Install
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
dsh plugin --profile web add dsh-ollama-usage
|
|
50
|
+
dsh --profile web
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
> Alternatively, add `dsh-ollama-usage` to the profile `package.json`'s
|
|
54
|
+
> `dsh.profile.bundles` manually and restart.
|
|
55
|
+
|
|
56
|
+
## 🚀 使用 / Usage
|
|
57
|
+
|
|
58
|
+
1. Open **Plugin list → dsh-ollama-usage** (the panel is rendered between the description and component rows of that page);
|
|
59
|
+
2. When not signed in, follow the panel guidance: sign in at [ollama.com](https://ollama.com/settings) →
|
|
60
|
+
create an API Key at [settings/keys](https://ollama.com/settings/keys) →
|
|
61
|
+
paste it and click **Check** (or run `ollama signin` in a terminal and click **Re-check local credentials**);
|
|
62
|
+
3. On success it is persisted; expand the sidebar to see the dual bars at the bottom, and the panel shows details and history at any time;
|
|
63
|
+
4. When no longer needed, click **Clear stored Key** to remove the local credential (history is kept).
|
|
64
|
+
|
|
65
|
+
## 🔒 数据与隐私 / Privacy
|
|
66
|
+
|
|
67
|
+
- Only a Bearer-carrying query request is sent to `https://ollama.com/api/balance`;
|
|
68
|
+
- The Key is stored in plaintext locally in `$DSH_HOME/storages/ollama-usage/usage.json` (mode 600,
|
|
69
|
+
a trust level equal to `~/.ollama/auth.json`), and can be cleared at any time.
|
|
70
|
+
|
|
71
|
+
## 🏗️ 架构 / Architecture
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
┌──────────────────────────┐ ┌─────────────────────────────┐
|
|
75
|
+
│ browser (client bundle) │ RPC │ host (lib/index.js) │
|
|
76
|
+
│ lib/client.js │◄──────►│ webServer /ollama-usage │
|
|
77
|
+
│ · sidebar dual bars │ 信封协议 │ · fetch api/balance(Bearer)│
|
|
78
|
+
│ · settings panel │ │ · $DSH_HOME 持久化(0600) │
|
|
79
|
+
│ · login guidance │ │ · 10min auto-refresh │
|
|
80
|
+
└──────────────────────────┘ └─────────────────────────────┘
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
- Host entry `lib/index.js`: ESM, exports `name` + the default plugin; `webServer` prefix route +
|
|
84
|
+
the Connection RPC envelope protocol (`check` / `snapshot` / `forget` / `auth-state`).
|
|
85
|
+
- Client entry `lib/client.js`: a `window.__ModuleLoader__.load` bundle that talks to the host via
|
|
86
|
+
`connection.rpc.call('/ollama-usage', endpoint, payload)`.
|
|
87
|
+
- Wiring: `cordis.patch.yml` (Loader row) + the `dsh.bundle.patch` / `dsh.client` declarations in
|
|
88
|
+
`package.json`.
|
|
89
|
+
|
|
90
|
+
## 🧩 兼容性 / Compatibility
|
|
91
|
+
|
|
92
|
+
Since DSH 0.2.1 the compatibility gate prefers `engines.dsh`. This plugin declares **`engines.dsh: ">=0.1.7-rc.1"`** (no upper bound), keeps the `@deepseek-ai/dsh-home-paths` peer at `>=0.1.7-rc.1`, and has been checked on:
|
|
93
|
+
|
|
94
|
+
| DSH version | Status |
|
|
95
|
+
| --- | --- |
|
|
96
|
+
| 0.1.5-rc.1 | ✅ Tested |
|
|
97
|
+
| 0.1.5-rc.2 | ✅ Tested |
|
|
98
|
+
| 0.1.6-alpha.2 | ✅ Tested |
|
|
99
|
+
| 0.1.7-rc.1 | ✅ Tested |
|
|
100
|
+
| 0.1.7-rc.2 | ✅ Tested |
|
|
101
|
+
| 0.2.0-rc.1 | ✅ Tested |
|
|
102
|
+
| 0.2.1-rc.1 | ✅ Gate + probes |
|
|
103
|
+
| 0.2.1-rc.2 | ✅ Gate |
|
|
104
|
+
|
|
105
|
+
> Only versions that were **actually run** are listed; untested versions are omitted.
|
|
106
|
+
|
|
107
|
+
v0.1.12 targets DSH **≥0.1.5-rc.1** (the `@deepseek-ai/dsh-*` peer was relaxed to `>=0.1.7-rc.1`), verified on **0.1.5-rc.1 / 0.1.5-rc.2 / 0.1.6-alpha.2 / 0.1.7-rc.1 / 0.1.7-rc.2 / 0.2.0-rc.1** (all RPC envelope probes pass; on 0.1.7-rc.2 the `/ollama-usage/snapshot` endpoint returns as measured; on 0.2.0-rc.1 it passes the new compatibility gate and loads normally; on 0.2.1-rc.1 the gate and RPC envelope probes pass, and 0.2.1-rc.2 passes the gate); for older DSH (0.1.0-rc.5 ~ rc.8) use the last compatible npm version, **0.1.5**.
|
|
108
|
+
|
|
109
|
+
## 🛠️ 开发 / Develop
|
|
110
|
+
|
|
111
|
+
### 测试 / Tests
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
npm test # bridge-smoke → balance-parse → rpc-envelope-alpha4
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
- `test/bridge-smoke.mjs` (17 checks): route registration, the no-token / 401 branches, persistence
|
|
118
|
+
read/write and cleanup, snapshot / forget / auth-state, and validation of malformed envelopes and
|
|
119
|
+
request methods.
|
|
120
|
+
- `test/balance-parse.mjs`: a `/api/balance` parsing regression (no network, a fetch stub). It drives
|
|
121
|
+
`check` with real response bodies and asserts the 5h / weekly percentage conversion, `resets_at`
|
|
122
|
+
passthrough, persistence and history appending, plus the unlimited-plan / non-JSON / 401 / 403 /
|
|
123
|
+
network-error branches.
|
|
124
|
+
- `test/rpc-envelope-alpha4.mjs`: every endpoint passes alpha.4's Connection RPC envelope validator.
|
|
125
|
+
|
|
126
|
+
### 构建与发布 / Build & Publish
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
npm install # 安装依赖(@deepseek-ai/dsh-home-paths)
|
|
130
|
+
npm test # 冒烟测试(见上)
|
|
131
|
+
npm pack # 本地打包检查
|
|
132
|
+
npm publish # 发布到 npm
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## 📄 许可证 / License
|
|
136
|
+
|
|
137
|
+
[MIT](LICENSE) © 2026 dsh-ollama-usage contributors
|
package/README.md
CHANGED
|
@@ -4,10 +4,16 @@
|
|
|
4
4
|
|
|
5
5
|
**Ollama Cloud 用量余量可视化 · DeepSeek Harness 插件**
|
|
6
6
|
|
|
7
|
-
[](https://www.npmjs.com/package/dsh-ollama-usage)
|
|
8
|
+
[](https://www.npmjs.com/package/dsh-ollama-usage)
|
|
9
|
+
[](LICENSE)
|
|
10
|
+
[](package.json)
|
|
11
|
+
[](https://github.com/SeverusZh/dsh-ollama-usage/releases)
|
|
12
|
+
[](https://github.com/SeverusZh/dsh-ollama-usage)
|
|
13
|
+
[](https://github.com/deepseek-ai/deepseek-harness)
|
|
14
|
+
[](https://awesome-dsh-plugin.com)
|
|
15
|
+
|
|
16
|
+
</div>
|
|
11
17
|
|
|
12
18
|
可视化你的 **Ollama Cloud** 用量余量 —— 每 5 小时会话用量 + 周用量,
|
|
13
19
|
侧边栏极简双横条常驻显示,插件详情页完整面板,Key 与快照持久化,自动刷新。
|
|
@@ -16,14 +22,9 @@
|
|
|
16
22
|
5-hour session + weekly quota, always-visible sidebar bars, a full panel on the
|
|
17
23
|
plugin's own detail page, persisted credentials & snapshots, auto-refresh.*
|
|
18
24
|
|
|
19
|
-
</div>
|
|
20
|
-
|
|
21
25
|
---
|
|
22
26
|
|
|
23
|
-
|
|
24
|
-
> v0.1.11 targets DSH **≥0.1.5-rc.1**, verified on **0.1.5-rc.1 / 0.1.5-rc.2 / 0.1.6-alpha.2 / 0.1.7-rc.1 / 0.1.7-rc.2 / 0.2.0-rc.1**; for older DSH releases use the last compatible npm version **0.1.5**.
|
|
25
|
-
|
|
26
|
-
## ✨ 功能特性 Features
|
|
27
|
+
## ✨ 功能特性 / Features
|
|
27
28
|
|
|
28
29
|
| 能力 | 说明 |
|
|
29
30
|
| --- | --- |
|
|
@@ -45,7 +46,7 @@ plugin's own detail page, persisted credentials & snapshots, auto-refresh.*
|
|
|
45
46
|
> 现在限额进度改由 `/api/balance` 提供(`已用 = 100 - remaining_percent`),
|
|
46
47
|
> 重置倒计时也直接使用接口下发的真实 `resets_at`。
|
|
47
48
|
|
|
48
|
-
## 📦 安装 Install
|
|
49
|
+
## 📦 安装 / Install
|
|
49
50
|
|
|
50
51
|
```bash
|
|
51
52
|
dsh plugin --profile web add dsh-ollama-usage
|
|
@@ -55,7 +56,7 @@ dsh --profile web
|
|
|
55
56
|
> 也可手动把 `dsh-ollama-usage` 加入 profile `package.json` 的
|
|
56
57
|
> `dsh.profile.bundles` 后重启。
|
|
57
58
|
|
|
58
|
-
## 🚀 使用 Usage
|
|
59
|
+
## 🚀 使用 / Usage
|
|
59
60
|
|
|
60
61
|
1. 打开 **插件列表 → dsh-ollama-usage**(面板渲染在该页面的描述与组件行之间);
|
|
61
62
|
2. 未登录时按面板指引:登录 [ollama.com](https://ollama.com/settings) →
|
|
@@ -64,13 +65,13 @@ dsh --profile web
|
|
|
64
65
|
3. 检测成功后即持久化,展开侧边栏即可看到底部双横条,面板可随时查看详情与历史;
|
|
65
66
|
4. 不再需要时点 **清除已存 Key** 移除本地凭证(历史保留)。
|
|
66
67
|
|
|
67
|
-
## 🔒 数据与隐私 Privacy
|
|
68
|
+
## 🔒 数据与隐私 / Privacy
|
|
68
69
|
|
|
69
70
|
- 仅向 `https://ollama.com/api/balance` 发送带 Bearer 的查询请求;
|
|
70
71
|
- Key 以明文保存在本机 `$DSH_HOME/storages/ollama-usage/usage.json`(权限 600,
|
|
71
72
|
与 `~/.ollama/auth.json` 同等级信任),随时可清除。
|
|
72
73
|
|
|
73
|
-
## 🏗️ 架构 Architecture
|
|
74
|
+
## 🏗️ 架构 / Architecture
|
|
74
75
|
|
|
75
76
|
```
|
|
76
77
|
┌──────────────────────────┐ ┌─────────────────────────────┐
|
|
@@ -89,7 +90,28 @@ dsh --profile web
|
|
|
89
90
|
- 接线:`cordis.patch.yml`(Loader 行)+ `package.json` 的
|
|
90
91
|
`dsh.bundle.patch` / `dsh.client` 声明。
|
|
91
92
|
|
|
92
|
-
##
|
|
93
|
+
## 🧩 兼容性 / Compatibility
|
|
94
|
+
|
|
95
|
+
DSH 0.2.1 起兼容门禁优先读取 `engines.dsh`。本插件声明 **`engines.dsh: ">=0.1.7-rc.1"`**(无上限),`@deepseek-ai/dsh-home-paths` peer 保持 `>=0.1.7-rc.1`,并已核对:
|
|
96
|
+
|
|
97
|
+
| DSH 版本 | 状态 |
|
|
98
|
+
| --- | --- |
|
|
99
|
+
| 0.1.5-rc.1 | ✅ 实测通过 |
|
|
100
|
+
| 0.1.5-rc.2 | ✅ 实测通过 |
|
|
101
|
+
| 0.1.6-alpha.2 | ✅ 实测通过 |
|
|
102
|
+
| 0.1.7-rc.1 | ✅ 实测通过 |
|
|
103
|
+
| 0.1.7-rc.2 | ✅ 实测通过 |
|
|
104
|
+
| 0.2.0-rc.1 | ✅ 实测通过 |
|
|
105
|
+
| 0.2.1-rc.1 | ✅ 兼容门禁 + 探针通过 |
|
|
106
|
+
| 0.2.1-rc.2 | ✅ 兼容门禁通过 |
|
|
107
|
+
|
|
108
|
+
> 只列出**实际跑过**的版本;未实测的不列。
|
|
109
|
+
|
|
110
|
+
v0.1.12 支持 DSH **≥0.1.5-rc.1**(`@deepseek-ai/dsh-*` peer 放宽为 `>=0.1.7-rc.1`),已在 **0.1.5-rc.1 / 0.1.5-rc.2 / 0.1.6-alpha.2 / 0.1.7-rc.1 / 0.1.7-rc.2 / 0.2.0-rc.1** 实测(RPC envelope 探针全过;0.1.7-rc.2 上 `/ollama-usage/snapshot` 实测返回;0.2.0-rc.1 上通过新的兼容性门禁并正常加载;0.2.1-rc.1 上兼容门禁与 RPC envelope 探针通过,0.2.1-rc.2 门禁通过);旧版 DSH(0.1.0-rc.5 ~ rc.8)请使用最后兼容的 npm 版本 **0.1.5**。
|
|
111
|
+
|
|
112
|
+
## 🛠️ 开发 / Develop
|
|
113
|
+
|
|
114
|
+
### 测试 / Tests
|
|
93
115
|
|
|
94
116
|
```bash
|
|
95
117
|
npm test # bridge-smoke → balance-parse → rpc-envelope-alpha4
|
|
@@ -102,7 +124,7 @@ npm test # bridge-smoke → balance-parse → rpc-envelope-alpha4
|
|
|
102
124
|
以及无限额套餐 / 非 JSON / 401 / 403 / 网络异常各分支。
|
|
103
125
|
- `test/rpc-envelope-alpha4.mjs`:逐端点通过 alpha.4 的 Connection RPC 信封校验器。
|
|
104
126
|
|
|
105
|
-
|
|
127
|
+
### 构建与发布 / Build & Publish
|
|
106
128
|
|
|
107
129
|
```bash
|
|
108
130
|
npm install # 安装依赖(@deepseek-ai/dsh-home-paths)
|
|
@@ -111,6 +133,6 @@ npm pack # 本地打包检查
|
|
|
111
133
|
npm publish # 发布到 npm
|
|
112
134
|
```
|
|
113
135
|
|
|
114
|
-
## 📄 License
|
|
136
|
+
## 📄 许可证 / License
|
|
115
137
|
|
|
116
138
|
[MIT](LICENSE) © 2026 dsh-ollama-usage contributors
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-ollama-usage",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"description": "DeepSeek Harness 插件:可视化 Ollama Cloud 账号用量余量(每 5 小时会话用量 + 周用量),支持侧边栏双横条、插件详情页完整面板、API Key 与用量快照持久化、自动刷新与登录引导。Ollama Pro usage & remaining-quota visualization for DeepSeek Harness: 5-hour session + weekly quota bars in the sidebar footer, a full panel on the plugin's own detail page, persisted API key and usage snapshots, auto-refresh and login guidance.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -32,7 +32,9 @@
|
|
|
32
32
|
"0.1.6-alpha.2": "compatible",
|
|
33
33
|
"0.1.7-rc.1": "compatible",
|
|
34
34
|
"0.1.7-rc.2": "compatible",
|
|
35
|
-
"0.2.0-rc.1": "compatible"
|
|
35
|
+
"0.2.0-rc.1": "compatible",
|
|
36
|
+
"0.2.1-rc.1": "compatible",
|
|
37
|
+
"0.2.1-rc.2": "compatible"
|
|
36
38
|
},
|
|
37
39
|
"node": ">=20"
|
|
38
40
|
}
|
|
@@ -95,5 +97,9 @@
|
|
|
95
97
|
"license": "MIT",
|
|
96
98
|
"scripts": {
|
|
97
99
|
"test": "DSH_HOME=.tmp-dsh-home HOME=.tmp-home node test/bridge-smoke.mjs && DSH_HOME=.tmp-balance-dsh-home HOME=.tmp-balance-home node test/balance-parse.mjs && DSH_HOME=.tmp-env-dsh-home HOME=.tmp-env-home node test/rpc-envelope-alpha4.mjs"
|
|
100
|
+
},
|
|
101
|
+
"engines": {
|
|
102
|
+
"node": ">=20",
|
|
103
|
+
"dsh": ">=0.1.7-rc.1"
|
|
98
104
|
}
|
|
99
|
-
}
|
|
105
|
+
}
|