dsh-deepseek-balance-widget 2.3.0 → 2.3.2
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/AI_BALANCE_SETUP_GUIDE.md +151 -0
- package/README.md +34 -1
- package/README_EN.md +34 -1
- package/lib/client.js +7 -2
- package/lib/index.js +49 -11
- package/package.json +3 -2
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# AI 余额插件 · 智能体配置引导教程
|
|
2
|
+
|
|
3
|
+
> 本文件供**智能体(AI 助手)**在聊天中读取。当用户说"帮我配置 MiMo / DeepSeek 余额"时,智能体应先完整读完本文件,再按对应章节一步步引导用户,不要跳过任何步骤。
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 0. 智能体的职责与边界
|
|
8
|
+
|
|
9
|
+
你是这个 dsh 插件的"配置向导"。你的任务:
|
|
10
|
+
|
|
11
|
+
1. 读完整份教程,理解两平台的差异(MiMo 用 Cookie,DeepSeek 用 API Key)。
|
|
12
|
+
2. 引导用户用浏览器开发者工具抓取请求(cURL / 请求头)。
|
|
13
|
+
3. 从用户粘贴的内容里**精准提取**鉴权凭证。
|
|
14
|
+
4. 把凭证**写入本机** `~/.dsh/ai-balances.json`(Windows 实际路径:`C:\Users\<用户名>\.dsh\ai-balances.json`)。
|
|
15
|
+
5. 验证余额能读到。
|
|
16
|
+
6. 提醒用户**彻底重启 dsh** 让凭证生效。
|
|
17
|
+
|
|
18
|
+
**边界(务必遵守):**
|
|
19
|
+
- 你**不能**替用户登录任何平台,也**不能**跨域抓取 Cookie(浏览器同源策略 + 隐私限制)。
|
|
20
|
+
- 所有数据只写在本机 `~/.dsh/ai-balances.json`,**不上传**任何外部服务器。
|
|
21
|
+
- 写文件前必须先读取现状,用精确的方式修改,**绝不能删除或破坏其他已有条目**(尤其 `deepseek` 这条)。
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 1. 通用步骤:如何抓取浏览器请求(两种方法)
|
|
26
|
+
|
|
27
|
+
无论哪个平台,第一步都是让用户从浏览器里把"带鉴权信息的请求"复制给你。
|
|
28
|
+
|
|
29
|
+
### 方法 A:Copy as cURL(推荐,信息最全)
|
|
30
|
+
1. 在浏览器打开对应平台的余额/控制台页面并**保持登录**。
|
|
31
|
+
2. 按 `F12` 打开开发者工具 → 切到 **Network(网络)** 标签。
|
|
32
|
+
3. 按 `F5` 刷新页面,让请求重新发出。
|
|
33
|
+
4. 在过滤框输入关键词(见各平台章节),找到目标请求。
|
|
34
|
+
5. 右键该请求 → **Copy(复制)** → **Copy as cURL (bash)**。
|
|
35
|
+
6. 把复制出来的那一长串(以 `curl 'https://...` 开头)直接粘贴到对话里发给我。
|
|
36
|
+
|
|
37
|
+
### 方法 B:只复制请求头(轻量)
|
|
38
|
+
若用户不愿贴整段 cURL,可在 Network 里点开目标请求 → 切到 **Headers(标头)** → 找到 `Cookie:`(MiMo)或 `Authorization:`(DeepSeek)那一行 → 只复制该请求头的完整内容。
|
|
39
|
+
|
|
40
|
+
> 提醒用户:cURL / 请求头里含有登录凭证,**只发给我(本机 AI),不要发到任何公开/外部聊天**。
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## 2. MiMo(小米)配置
|
|
45
|
+
|
|
46
|
+
- **平台网址**:`https://platform.xiaomimimo.com/#/console/balance`
|
|
47
|
+
- **鉴权方式**:**登录 Cookie**(MiMo 余额接口只对登录 Cookie 开放,API Key 查不到余额)。
|
|
48
|
+
- **抓取关键词**:在 Network 过滤框输入 `api` 或 `balance`,找域名是 `platform.xiaomimimo.com` / `api.xiaomimimo.com` 的请求。
|
|
49
|
+
|
|
50
|
+
### 提取 Cookie
|
|
51
|
+
- 若用户贴的是 cURL:找其中 `-H 'Cookie: ...'` 或 `--cookie '...'` 部分,提取 `Cookie:` 之后、`'` 之前的完整内容。
|
|
52
|
+
- 若用户贴的是请求头:直接取其 `Cookie:` 整行内容。
|
|
53
|
+
- Cookie 是一长串 `key=value; key2=value2; ...`,原样保留,不要截断。
|
|
54
|
+
|
|
55
|
+
### 写入格式
|
|
56
|
+
目标文件:`~/.dsh/ai-balances.json`(JSON 数组)。找到或新增一条 MiMo 记录:
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
{
|
|
60
|
+
"id": "mimo",
|
|
61
|
+
"label": "MiMo(小米)",
|
|
62
|
+
"kind": "mimo",
|
|
63
|
+
"apiKey": "",
|
|
64
|
+
"cookie": "<这里放提取到的完整 Cookie 字符串>",
|
|
65
|
+
"enabled": true
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
> 注意 `id` 用 `mimo`,插件据此识别。若数组里已有 `id:"mimo"` 的条目,只更新它的 `cookie` 字段,保留其他字段。
|
|
70
|
+
|
|
71
|
+
### 备注
|
|
72
|
+
- MiMo 的 Cookie 约 **1–7 天**过期,过期后余额会显示 401。届时需要重新走一遍本流程更新 Cookie。
|
|
73
|
+
- 若提取后余额仍报"失败",把插件弹窗里显示的原始响应片段发给我,我再精确适配字段。
|
|
74
|
+
- MiMo 余额接口常见返回字段(插件弹窗里会显示中文标签):
|
|
75
|
+
- `giftBalance` → 赠送余额
|
|
76
|
+
- `cashBalance` → 现金余额
|
|
77
|
+
- `frozenBalance` → 冻结余额
|
|
78
|
+
- `overdraftLimit` → 透支额度
|
|
79
|
+
- `remainingOverdraftLimit` → 剩余透支额度
|
|
80
|
+
- `code` / `message` → 状态码 / 消息
|
|
81
|
+
- 若还有未识别的字段,会保持原样显示。
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## 3. DeepSeek 配置
|
|
86
|
+
|
|
87
|
+
- **平台网址**:`https://platform.deepseek.com/`(控制台)
|
|
88
|
+
- **鉴权方式**:**API Key**(即 `Authorization: Bearer sk-...` 凭证)。DeepSeek 余额接口 `https://api.deepseek.com/user/balance` 用 Bearer 鉴权。
|
|
89
|
+
- **抓取关键词**:在 Network 过滤框输入 `user` 或 `balance`,找域名是 `api.deepseek.com` / `platform.deepseek.com` 的请求。
|
|
90
|
+
|
|
91
|
+
### 提取 API Key
|
|
92
|
+
- 若用户贴的是 cURL:找其中 `-H 'Authorization: Bearer sk-...'` 部分,提取 `sk-` 开头的完整密钥。
|
|
93
|
+
- 若用户贴的是请求头:直接取 `Authorization: Bearer sk-...` 中 `sk-` 开头部分。
|
|
94
|
+
- 完整密钥形如 `sk-xxxxxxxxxxxxxxxx`,**一字不差**原样保留。
|
|
95
|
+
|
|
96
|
+
### 写入格式
|
|
97
|
+
目标文件:`~/.dsh/ai-balances.json`(JSON 数组)。找到或新增一条 DeepSeek 记录:
|
|
98
|
+
|
|
99
|
+
```json
|
|
100
|
+
{
|
|
101
|
+
"id": "deepseek",
|
|
102
|
+
"label": "DeepSeek",
|
|
103
|
+
"kind": "deepseek",
|
|
104
|
+
"apiKey": "<这里放提取到的 sk-... 密钥>",
|
|
105
|
+
"enabled": true
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
> `id:"deepseek"` 是固定项,插件默认就有,且**不能被移除**。若已存在,只更新 `apiKey` 字段。
|
|
110
|
+
> 如果用户机器上 DeepSeek 的密钥已经配置在 dsh 的 `.credentials.yaml`(`DEEPSEEK_API_KEY`)里,可把 `apiKey` 写成字符串 `"__credentials__"`,插件运行时会自动从环境变量解析,无需把明文写进本文件。
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## 4. 写入目标文件的操作要点
|
|
115
|
+
|
|
116
|
+
- 路径(Windows):`C:\Users\<用户名>\.dsh\ai-balances.json`
|
|
117
|
+
- 它是一个 **JSON 数组**,形如 `[ {深度条目}, {其他条目} ]`。
|
|
118
|
+
- 修改步骤:
|
|
119
|
+
1. 用 Read 读取该文件,确认当前内容(若文件不存在,说明用户还没初始化,先创建 `[]` 再追加)。
|
|
120
|
+
2. 用 Edit / Write 精确修改对应 `id` 的条目,**不要改动其他条目**。
|
|
121
|
+
3. 写回后再次 Read 确认 JSON 合法、结构完整。
|
|
122
|
+
- 不要写入任何多余字段;`cookie` 和 `apiKey` 只填当前平台需要的那个,另一个留空字符串或省略均可。
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## 5. 验证
|
|
127
|
+
|
|
128
|
+
写入后,任选一种方式验证余额能读到:
|
|
129
|
+
|
|
130
|
+
- **方式一(插件侧)**:让用户彻底重启 dsh,打开插件弹窗,看对应平台是否显示余额数字。
|
|
131
|
+
- **方式二(直接请求)**:
|
|
132
|
+
- DeepSeek:`curl -s https://api.deepseek.com/user/balance -H "Authorization: Bearer <sk-密钥>"`,看返回 `balance_infos`。
|
|
133
|
+
- MiMo:`curl -s https://platform.xiaomimimo.com/api/v1/balance -H "Cookie: <Cookie>"`,看返回余额字段。
|
|
134
|
+
- 若返回 401 / 404 / 失败:说明凭证过期或提取有误,引导用户重抓。
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## 6. 收尾提醒
|
|
139
|
+
|
|
140
|
+
配置写入成功后,务必告诉用户:
|
|
141
|
+
|
|
142
|
+
> **必须彻底重启 dsh**(命令行 `Ctrl+C` 停掉 `dsh web` 或关闭桌面端窗口,再重新启动),浏览器刷新不会重新加载插件凭证。重启后打开插件弹窗即可看到余额。
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## 附:常见坑
|
|
147
|
+
|
|
148
|
+
- **MiMo 用 API Key 查不到余额**:MiMo 余额接口只对登录 Cookie 开放,必须用 Cookie,不能用 API Key。
|
|
149
|
+
- **Cookie 过期**:MiMo 登录态会过期,余额变 401 时重新走第 2 章。
|
|
150
|
+
- **别删 deepseek 条目**:它是插件默认项,删了会导致 DeepSeek 余额消失。
|
|
151
|
+
- **JSON 写坏**:写文件前后都要 Read 校验,确保数组闭合、逗号正确。
|
package/README.md
CHANGED
|
@@ -20,11 +20,13 @@
|
|
|
20
20
|
需要:已安装 dsh(可用 `dsh web`)。
|
|
21
21
|
|
|
22
22
|
```bash
|
|
23
|
-
dsh plugin --profile web add dsh-deepseek-balance-widget
|
|
23
|
+
dsh plugin --profile web add dsh-deepseek-balance-widget@2.3.1
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
从 npm 拉取安装,dsh 自动注册到 `dsh.profile.bundles`,完成后**重启 `dsh web`** 即可。
|
|
27
27
|
|
|
28
|
+
> 务必带版本号 `@2.3.1`。不带版本号的 `add` 会按 npm 的 `latest` tag 安装,该 tag 可能被旧版本抢回去,导致装到老版本。
|
|
29
|
+
|
|
28
30
|
也可以直接对 AI 说:
|
|
29
31
|
|
|
30
32
|
> 帮我用 npm 安装 dsh-deepseek-balance-widget 插件。
|
|
@@ -47,6 +49,37 @@ AI 会接管全部:问 API Key / 引导获取平台 Cookie → 写入本机
|
|
|
47
49
|
|
|
48
50
|
凭据保存在你本机的 `~/.dsh/ai-balances.json`,不随插件分发、不上传。
|
|
49
51
|
|
|
52
|
+
## 更新
|
|
53
|
+
|
|
54
|
+
最新稳定版为 **`2.3.1`**。无论你当前是哪个旧版本,都推荐升级到它。
|
|
55
|
+
|
|
56
|
+
### 方式一:弹窗一键更新(推荐,已装用户)
|
|
57
|
+
|
|
58
|
+
1. 打开余额弹窗,底部会显示版本号;有新版本时显示 `vX → v2.3.1 更新`。
|
|
59
|
+
2. 点击「**检查更新**」,插件会自动从 npm 拉取并安装最高版本。
|
|
60
|
+
3. 安装完成后**必须彻底重启 `dsh web`**(关掉 `dsh web` 进程 / 退出桌面端再重开,**仅刷新浏览器页面无效**)才能加载新版本。
|
|
61
|
+
|
|
62
|
+
> 弹窗的「检查更新」会跳过 `latest` tag,直接安装 npm 上 semver 最高的版本,所以即使有人把 `latest` 改低了也能升到最新。
|
|
63
|
+
|
|
64
|
+
### 方式二:命令行强制更新(最稳妥,适合卡住或装不上的情况)
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
dsh plugin --profile web add dsh-deepseek-balance-widget@2.3.1
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
带版本号可绕过缓存 / 镜像源不同步 / `latest` 被抢低等问题,一步到位。
|
|
71
|
+
|
|
72
|
+
### 方式三:手动更新(命令行更新失败时兜底)
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
cd ~/.dsh/profiles/web
|
|
76
|
+
npm install dsh-deepseek-balance-widget@2.3.1 # 若目录内有 pnpm-lock.yaml 则用 pnpm add
|
|
77
|
+
# 验证磁盘上确实变了
|
|
78
|
+
cat node_modules/dsh-deepseek-balance-widget/package.json | grep '"version"'
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
确认输出 `2.3.1` 后,**彻底重启 `dsh web`** 即可。
|
|
82
|
+
|
|
50
83
|
## 卸载
|
|
51
84
|
|
|
52
85
|
```bash
|
package/README_EN.md
CHANGED
|
@@ -20,11 +20,13 @@ A multi-provider AI balance widget for the dsh web sidebar. **DeepSeek** is buil
|
|
|
20
20
|
Requires: dsh installed (with `dsh web` working).
|
|
21
21
|
|
|
22
22
|
```bash
|
|
23
|
-
dsh plugin --profile web add dsh-deepseek-balance-widget
|
|
23
|
+
dsh plugin --profile web add dsh-deepseek-balance-widget@2.3.1
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
Installed from npm and auto-registered by dsh. **Restart `dsh web`** and the balance button appears in the sidebar.
|
|
27
27
|
|
|
28
|
+
> Always include the version `@2.3.1`. A bare `add` follows npm's `latest` tag, which may be hijacked by older versions and silently install an outdated release.
|
|
29
|
+
|
|
28
30
|
Or just tell your AI:
|
|
29
31
|
|
|
30
32
|
> Install the dsh-deepseek-balance-widget plugin for me via npm.
|
|
@@ -47,6 +49,37 @@ The AI takes care of everything: asks for your API key / guides you through gett
|
|
|
47
49
|
|
|
48
50
|
Credentials are stored locally in `~/.dsh/ai-balances.json`; nothing is shipped with the plugin and nothing is uploaded.
|
|
49
51
|
|
|
52
|
+
## Update
|
|
53
|
+
|
|
54
|
+
The latest stable release is **`2.3.1`**. Upgrade to it regardless of which older version you currently have.
|
|
55
|
+
|
|
56
|
+
### Method 1: One-click from the popover (recommended for installed users)
|
|
57
|
+
|
|
58
|
+
1. Open the balance popover; the footer shows the version. When a newer one exists it reads `vX → v2.3.1 更新`.
|
|
59
|
+
2. Click "**检查更新**" (Check for update). The plugin pulls and installs the highest semver version from npm automatically.
|
|
60
|
+
3. After install you **must fully restart `dsh web`** (stop the `dsh web` process / quit the desktop app and reopen — **refreshing the browser tab is not enough**) for the new version to load.
|
|
61
|
+
|
|
62
|
+
> The popover's "Check for update" skips the `latest` tag and installs the highest semver version on npm, so it still reaches latest even if someone lowers the `latest` tag.
|
|
63
|
+
|
|
64
|
+
### Method 2: Force update from the command line (most reliable if stuck)
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
dsh plugin --profile web add dsh-deepseek-balance-widget@2.3.1
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Pinning the version bypasses cache / mirror desync / a hijacked `latest` tag in one step.
|
|
71
|
+
|
|
72
|
+
### Method 3: Manual update (fallback when the command-line update fails)
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
cd ~/.dsh/profiles/web
|
|
76
|
+
npm install dsh-deepseek-balance-widget@2.3.1 # use `pnpm add` if a pnpm-lock.yaml exists in this dir
|
|
77
|
+
# verify the on-disk version actually changed
|
|
78
|
+
cat node_modules/dsh-deepseek-balance-widget/package.json | grep '"version"'
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Once it prints `2.3.1`, **fully restart `dsh web`**.
|
|
82
|
+
|
|
50
83
|
## Uninstall
|
|
51
84
|
|
|
52
85
|
```bash
|
package/lib/client.js
CHANGED
|
@@ -280,8 +280,13 @@ window.__ModuleLoader__.load({
|
|
|
280
280
|
* dsh restart re-executes client.js, resetting all variables (including updateSuccessUntil),
|
|
281
281
|
* which makes the success message disappear and restores the normal version check button. */
|
|
282
282
|
const UPDATE_SUCCESS_MS = Number.MAX_SAFE_INTEGER;
|
|
283
|
-
/**
|
|
284
|
-
|
|
283
|
+
/**
|
|
284
|
+
* Fixed path to the AI-setup guide file that the host copies from the
|
|
285
|
+
* plugin package into the user's ~/.dsh directory at startup. Using this
|
|
286
|
+
* space-free, home-relative path avoids the "cannot read / glob failed"
|
|
287
|
+
* errors dsh chat AIs hit when the workspace path contains spaces.
|
|
288
|
+
*/
|
|
289
|
+
const AI_GUIDE_FILE = "~/.dsh/AI_BALANCE_SETUP_GUIDE.md";
|
|
285
290
|
/** Prompt copied to the chat when the user asks the AI to configure MiMo Cookie. */
|
|
286
291
|
const MIMO_COOKIE_GUIDE_PROMPT = `请先读取文件 ${AI_GUIDE_FILE},按里面「MiMo(小米)」章节的流程一步步引导我配置,最后把凭证写入本机插件。`;
|
|
287
292
|
/** Prompt copied to the chat when the user asks the AI to configure DeepSeek balance. */
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { launchEnvironmentOf } from "@deepseek-ai/dsh-launch-environment";
|
|
2
|
-
import { readFile, writeFile, stat } from "node:fs/promises";
|
|
2
|
+
import { readFile, writeFile, stat, mkdir, copyFile } from "node:fs/promises";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { dirname, resolve } from "node:path";
|
|
5
5
|
import { homedir } from "node:os";
|
|
@@ -567,16 +567,27 @@ async function runPackageUpdate() {
|
|
|
567
567
|
const target = versionInfo.latest;
|
|
568
568
|
const pm = await detectPackageManager();
|
|
569
569
|
const isWin = process.platform === "win32";
|
|
570
|
-
const cmd = isWin ? (pm === "pnpm" ? "pnpm
|
|
570
|
+
const cmd = isWin ? (pm === "pnpm" ? "pnpm" : "npm") : pm;
|
|
571
571
|
const args = pm === "pnpm"
|
|
572
572
|
? ["add", `dsh-deepseek-balance-widget@${target}`]
|
|
573
573
|
: ["install", `dsh-deepseek-balance-widget@${target}`];
|
|
574
574
|
return new Promise((resolve) => {
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
shell:
|
|
578
|
-
|
|
579
|
-
|
|
575
|
+
let child;
|
|
576
|
+
if (isWin) {
|
|
577
|
+
// Avoid Node.js DEP0190: spawn with shell:true and a separate args array is deprecated.
|
|
578
|
+
// Build a single command string and let cmd.exe parse it; hide the console window.
|
|
579
|
+
const quotedArgs = args.map((a) => `"${a.replace(/"/g, '\\"')}"`).join(" ");
|
|
580
|
+
child = spawn("cmd.exe", ["/d", "/s", "/c", `${cmd} ${quotedArgs}`], {
|
|
581
|
+
cwd: UPDATE_CWD,
|
|
582
|
+
windowsHide: true,
|
|
583
|
+
env: { ...process.env, NPM_CONFIG_FUND: "false", NPM_CONFIG_AUDIT: "false" }
|
|
584
|
+
});
|
|
585
|
+
} else {
|
|
586
|
+
child = spawn(cmd, args, {
|
|
587
|
+
cwd: UPDATE_CWD,
|
|
588
|
+
env: { ...process.env, NPM_CONFIG_FUND: "false", NPM_CONFIG_AUDIT: "false" }
|
|
589
|
+
});
|
|
590
|
+
}
|
|
580
591
|
let stdout = "";
|
|
581
592
|
let stderr = "";
|
|
582
593
|
child.stdout.on("data", (chunk) => { stdout += String(chunk); });
|
|
@@ -584,13 +595,26 @@ async function runPackageUpdate() {
|
|
|
584
595
|
child.on("error", (error) => {
|
|
585
596
|
resolve({ ok: false, output: stdout + stderr, error: String(error?.message ?? error) });
|
|
586
597
|
});
|
|
587
|
-
child.on("close", (code) => {
|
|
598
|
+
child.on("close", async (code) => {
|
|
588
599
|
const output = (stdout + "\n" + stderr).trim();
|
|
589
|
-
if (code
|
|
590
|
-
resolve({ ok: true, output: output.slice(-800) });
|
|
591
|
-
} else {
|
|
600
|
+
if (code !== 0) {
|
|
592
601
|
resolve({ ok: false, output, error: `${pm} ${args.join(" ")} exited with code ${code}` });
|
|
602
|
+
return;
|
|
593
603
|
}
|
|
604
|
+
// Verify the on-disk version actually changed so the user can't be misled into
|
|
605
|
+
// restarting dsh when the install silently wrote to a different location.
|
|
606
|
+
try {
|
|
607
|
+
const installedPkgPath = resolve(UPDATE_CWD, "node_modules", "dsh-deepseek-balance-widget", "package.json");
|
|
608
|
+
const installedPkg = JSON.parse(await readFile(installedPkgPath, "utf8"));
|
|
609
|
+
if (installedPkg.version !== target) {
|
|
610
|
+
resolve({ ok: false, output, error: `installed version mismatch: expected ${target}, found ${installedPkg.version}` });
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
} catch (verifyError) {
|
|
614
|
+
resolve({ ok: false, output, error: `update appeared to succeed but could not verify installed version: ${String(verifyError?.message ?? verifyError)}` });
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
617
|
+
resolve({ ok: true, output: output.slice(-800) });
|
|
594
618
|
});
|
|
595
619
|
});
|
|
596
620
|
}
|
|
@@ -890,6 +914,20 @@ async function queryPlatformUsage(token, month, year) {
|
|
|
890
914
|
* @param {import("@deepseek-ai/cordis").Context} ctx - plugin context.
|
|
891
915
|
*/
|
|
892
916
|
function apply(ctx) {
|
|
917
|
+
// Copy the AI setup guide to a fixed, space-free location so any chat AI
|
|
918
|
+
// launched from dsh can read it without being tripped up by spaces in the
|
|
919
|
+
// workspace path or by the file not being shipped in the npm tarball.
|
|
920
|
+
(async () => {
|
|
921
|
+
try {
|
|
922
|
+
const guideSrc = resolve(PLUGIN_ROOT, "AI_BALANCE_SETUP_GUIDE.md");
|
|
923
|
+
const dshDir = resolve(homedir(), ".dsh");
|
|
924
|
+
const guideDest = resolve(dshDir, "AI_BALANCE_SETUP_GUIDE.md");
|
|
925
|
+
await stat(guideSrc);
|
|
926
|
+
await mkdir(dshDir, { recursive: true });
|
|
927
|
+
await copyFile(guideSrc, guideDest);
|
|
928
|
+
} catch {}
|
|
929
|
+
})();
|
|
930
|
+
|
|
893
931
|
ctx.effect(() => {
|
|
894
932
|
const dispose = ctx.webServer.register({
|
|
895
933
|
kind: "prefix",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-deepseek-balance-widget",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Multi-provider AI balance widget for the dsh web sidebar: a live, auto-refreshing balance pill plus a detail popover listing DeepSeek and any added providers (MiMo etc.). Keys are stored per-machine in ~/.dsh/ai-balances.json and resolved from the local credential seam, never hardcoded.",
|
|
6
6
|
"keywords": [
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
"README.md",
|
|
27
27
|
"README_EN.md",
|
|
28
28
|
"LICENSE",
|
|
29
|
-
"scripts"
|
|
29
|
+
"scripts",
|
|
30
|
+
"AI_BALANCE_SETUP_GUIDE.md"
|
|
30
31
|
],
|
|
31
32
|
"engines": {
|
|
32
33
|
"node": ">=18"
|