@maplewf/dsh-web-update 0.0.0-stage → 0.1.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/README.en.md +65 -0
- package/README.md +64 -2
- package/client.js +779 -0
- package/cordis.patch.yml +27 -0
- package/icon.svg +15 -0
- package/index.js +766 -0
- package/lib/core.js +259 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +53 -4
package/README.en.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# dsh-web-update
|
|
2
|
+
|
|
3
|
+
Adds a **Version Update** page in Settings to check and upgrade the dsh web runtime (`@deepseek-ai/dsh`).
|
|
4
|
+
|
|
5
|
+
## Behavior
|
|
6
|
+
|
|
7
|
+
- **Startup check**: runs an async check 1.5s after each dsh web service start (disable with `checkOnStart: false`). The result is written to the Host status and shown on the Settings page.
|
|
8
|
+
- **Red-dot badge**: the Settings → "Version Update" nav icon shows a red dot when a newer version than the current one is published. The dot uses the same Host status; the status line in the page mirrors it ("new version available").
|
|
9
|
+
- **Check version**: triggers a manual check. Prefers `npm view <pkg> dist-tags --json --prefer-online` (following local npm config and network paths), falls back to `https://registry.npmjs.org/<pkg>/latest`.
|
|
10
|
+
- **Update version**: after confirmation runs `npm install -g <pkg>@<version> --no-audit --no-fund`; when the target directory (e.g. root-owned `/usr/lib/node_modules`) is not writable by the service user, automatically falls back to `sudo -n`. After install it re-reads `package.json` to verify the version, then restarts the dsh web unit via a `systemd-run --user` transient timer (the process lives inside the restarted unit's cgroup, so a plain detached child would be killed by `KillMode=control-group`). The command run in the timer defaults to `systemctl --user restart <unit>`; override it with the `restartCommand` config (empty = built-in default), or edit it directly under Plugin Management → dsh-web-update → Config (applies immediately).
|
|
11
|
+
- The page polls status every second during install/restart; after the restart the Harness client reconnects automatically, no manual `location.reload()`.
|
|
12
|
+
- Read-only tool `check_dsh_update` (`action: status | check`) lets agents query version state; **no** agent-side install capability — updates are confirmed and executed by the user on the page.
|
|
13
|
+
|
|
14
|
+
## Configuration (`cordis.patch.yml` `config`)
|
|
15
|
+
|
|
16
|
+
| Field | Default | Description |
|
|
17
|
+
| --- | --- | --- |
|
|
18
|
+
| `unit` | `deepseek-harness-web.service` | systemd user unit to restart |
|
|
19
|
+
| `package` | `@deepseek-ai/dsh` | package to check/install |
|
|
20
|
+
| `channel` | `latest` | npm dist-tag to follow |
|
|
21
|
+
| `checkOnStart` | `true` | check once at startup |
|
|
22
|
+
| `restartDelaySeconds` | `3` | delay between install and restart |
|
|
23
|
+
| `restartCommand` | (empty) | restart command run in the timer: empty = built-in `systemctl --user restart <unit>`; non-empty = executed via `/bin/sh -c`, `{unit}` substituted. Editable in Plugin Management → dsh-web-update → Config; applies immediately (volatile, no restart) |
|
|
24
|
+
| `commandTimeoutSeconds` | `600` | hard timeout for npm install |
|
|
25
|
+
| `npmPath` | `/usr/bin/npm` | npm executable |
|
|
26
|
+
| `tool` | `true` | whether to register the `check_dsh_update` tool |
|
|
27
|
+
|
|
28
|
+
## Prerequisites
|
|
29
|
+
|
|
30
|
+
- Passwordless sudo: `sudo -n true` passes (true on this machine); otherwise make the npm global prefix user-writable, or run `sudo chown -R <user> /usr/lib/node_modules/@deepseek-ai` once.
|
|
31
|
+
- `systemd-run --user` available (user-level systemd).
|
|
32
|
+
|
|
33
|
+
## Structure
|
|
34
|
+
|
|
35
|
+
- `index.js`: Host half — startup check, `/api/dsh-version-update` route (status/check/update), install & restart scheduling, read-only tool.
|
|
36
|
+
- `lib/core.js`: pure functions (semver comparison, runtime version read, dist-tags parsing, install command construction), unit-testable without the host.
|
|
37
|
+
- `client.js`: browser half — `settings.section` page, `settings.section.icon` red dot, locale strings.
|
|
38
|
+
- `locale/*.json`: metadata for the plugin manager display; page strings live in `client.js`'s embedded dictionary.
|
|
39
|
+
|
|
40
|
+
## Publishing
|
|
41
|
+
|
|
42
|
+
Release pipeline lives in `.github/workflows/release.yml` (tag `v*`): packs the bundle, publishes the market index to GitHub Pages, publishes to npm as `@maplewf/dsh-web-update` (Trusted Publishing / OIDC, no token), and attaches the `.tgz` to a GitHub Release.
|
|
43
|
+
|
|
44
|
+
⚠️ The npm name `dsh-web-update` is taken by a third-party plugin, so this plugin publishes as the scoped package `@maplewf/dsh-web-update`. The local `package.json` name stays `dsh-web-update`; the workflow renames it temporarily right before publishing, so packing and index generation are unaffected.
|
|
45
|
+
|
|
46
|
+
First-release order (push the package first, then configure settings, then tag for full automation):
|
|
47
|
+
|
|
48
|
+
1. **Create the repo and push the code** (requires `gh auth login` on the local machine first):
|
|
49
|
+
```bash
|
|
50
|
+
gh repo create maplewf/dsh-web-update --public --source=. --push
|
|
51
|
+
```
|
|
52
|
+
2. **Publish manually once** to create the npm package record (while logged in to npm; gives the OIDC binding and CI idempotent skip a solid base, and avoids debugging a failed first CI publish):
|
|
53
|
+
```bash
|
|
54
|
+
npm pkg set name=@maplewf/dsh-web-update
|
|
55
|
+
npm publish --access public
|
|
56
|
+
npm pkg set name=dsh-web-update # restore the local name; do not commit the scoped name
|
|
57
|
+
```
|
|
58
|
+
3. **Configure settings**:
|
|
59
|
+
- npmjs.com account → Access Tokens → Generate new token → Publish access (OIDC) → bind the repo `maplewf/dsh-web-update`; same settings as dsh-kube: check Publish directly, leave Manage dist-tags and Require additional authentication unchecked;
|
|
60
|
+
- Repo Settings → Pages → Source: **"GitHub Actions"**.
|
|
61
|
+
4. **Tag to trigger the automated release**:
|
|
62
|
+
```bash
|
|
63
|
+
git tag v0.1.0 && git push origin v0.1.0
|
|
64
|
+
```
|
|
65
|
+
(npm publish is skipped idempotently for already-published versions; Pages deploys; the Release gets the `.tgz`.)
|
package/README.md
CHANGED
|
@@ -1,3 +1,65 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-web-update
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
在设置页新增「版本更新」页,用于检查并升级 dsh web 主体(`@deepseek-ai/dsh`)。
|
|
4
|
+
|
|
5
|
+
## 行为
|
|
6
|
+
|
|
7
|
+
- **启动检查**:dsh web 服务每次启动后 1.5s 异步检查一次(`checkOnStart: false` 可关闭)。检查结果写入 Host 状态,可在设置页查看。
|
|
8
|
+
- **红点提醒**:设置 → 「版本更新」导航图标上,当已发布版本高于当前版本时显示红点。红点数据来自同一份 Host 状态,页面内的状态行同步显示「有新版本可用」。
|
|
9
|
+
- **检查版本**:手动触发一次检查。优先用 `npm view <pkg> dist-tags --json --prefer-online`(沿用本机 npm 配置与网络路径),失败时回退到 `https://registry.npmjs.org/<pkg>/latest`。
|
|
10
|
+
- **更新版本**:确认后执行 `npm install -g <pkg>@<version> --no-audit --no-fund`;当目标目录(如 root 拥有的 `/usr/lib/node_modules`)对服务用户不可写时自动改用 `sudo -n`。安装结束会回读 `package.json` 校验版本,然后通过 `systemd-run --user` 瞬态计时器重启 `dsh web` 单元(进程位于被重启 unit 的 cgroup 内,普通 detached 子进程会被 `KillMode=control-group` 一并杀掉)。计时器内执行的命令默认是 `systemctl --user restart <unit>`,可用 `restartCommand` 配置自定义(留空=内置默认),也可以在「插件管理 → dsh-web-update → 配置」里直接编辑(就地生效)。
|
|
11
|
+
- 页面在安装/重启期间每秒轮询状态;重启完成后页面由 Harness 客户端自动重连,不主动 `location.reload()`。
|
|
12
|
+
- 只读工具 `check_dsh_update`(`action: status | check`)供 agent 查询版本情况;**不提供** agent 侧安装能力,更新由用户在页面上确认执行。
|
|
13
|
+
|
|
14
|
+
## 配置(`cordis.patch.yml` 行 config)
|
|
15
|
+
|
|
16
|
+
| 字段 | 默认 | 说明 |
|
|
17
|
+
| --- | --- | --- |
|
|
18
|
+
| `unit` | `deepseek-harness-web.service` | 重启的 systemd 用户单元 |
|
|
19
|
+
| `package` | `@deepseek-ai/dsh` | 检查/安装的包 |
|
|
20
|
+
| `channel` | `latest` | 跟随的 npm dist-tag |
|
|
21
|
+
| `checkOnStart` | `true` | 启动时检查一次 |
|
|
22
|
+
| `restartDelaySeconds` | `3` | 安装完成到重启的延迟 |
|
|
23
|
+
| `restartCommand` | (空) | 计时器内执行的重启命令:留空=内置 `systemctl --user restart <unit>`;非空=以 `/bin/sh -c` 执行,`{unit}` 会替换为 unit。可在「插件管理 → dsh-web-update → 配置」中编辑,保存后立即生效(volatile,无需重启) |
|
|
24
|
+
| `commandTimeoutSeconds` | `600` | npm 安装硬超时 |
|
|
25
|
+
| `npmPath` | `/usr/bin/npm` | npm 可执行文件 |
|
|
26
|
+
| `tool` | `true` | 是否注册 `check_dsh_update` 工具 |
|
|
27
|
+
|
|
28
|
+
## 前置条件
|
|
29
|
+
|
|
30
|
+
- 免密 sudo:`sudo -n true` 通过(当前机器满足);否则请把 npm 全局前缀改成用户可写目录,或一次性 `sudo chown -R <user> /usr/lib/node_modules/@deepseek-ai`。
|
|
31
|
+
- `systemd-run --user` 可用(用户级 systemd)。
|
|
32
|
+
|
|
33
|
+
## 结构
|
|
34
|
+
|
|
35
|
+
- `index.js`:Host 半 —— 启动检查、`/api/dsh-version-update` 路由(status/check/update)、安装与重启调度、只读工具。
|
|
36
|
+
- `lib/core.js`:纯函数(semver 比较、读运行时版本、解析 dist-tags、构造安装命令),可脱离宿主单测。
|
|
37
|
+
- `client.js`:浏览器半 —— `settings.section` 页面、`settings.section.icon` 红点、语言包。
|
|
38
|
+
- `locale/*.json`:插件管理器展示用元数据;页面文案在 `client.js` 的内嵌字典中。
|
|
39
|
+
|
|
40
|
+
## 发布
|
|
41
|
+
|
|
42
|
+
发布流程见 `.github/workflows/release.yml`(打 `v*` tag 触发):打包 bundle、市场索引发布到 GitHub Pages、npm 发布(`@maplewf/dsh-web-update`,Trusted Publishing / OIDC 无 token)、GitHub Release 附 `.tgz`。
|
|
43
|
+
|
|
44
|
+
⚠️ npm 上的 `dsh-web-update` 已被他人占用,故发布为 scoped 包 `@maplewf/dsh-web-update`;本地 `package.json` 名字固定为 `dsh-web-update`,workflow 在发布前临时改名,打包与索引生成不受影响。
|
|
45
|
+
|
|
46
|
+
首次发布顺序(先推包建记录,再改 settings,最后 tag 全自动):
|
|
47
|
+
|
|
48
|
+
1. **建仓并推送代码**(本机需先 `gh auth login`):
|
|
49
|
+
```bash
|
|
50
|
+
gh repo create maplewf/dsh-web-update --public --source=. --push
|
|
51
|
+
```
|
|
52
|
+
2. **手动首发一次**建立 npm 包记录(npm 登录态下;这样 OIDC 绑定与 CI 幂等跳过都有依据,避免首次 CI 发布失败难排查):
|
|
53
|
+
```bash
|
|
54
|
+
npm pkg set name=@maplewf/dsh-web-update
|
|
55
|
+
npm publish --access public
|
|
56
|
+
npm pkg set name=dsh-web-update # 改回本地名,勿把 scoped 名提交进仓库
|
|
57
|
+
```
|
|
58
|
+
3. **配置 settings**:
|
|
59
|
+
- npmjs.com 账号 → Access Tokens → Generate new token → Publish access(OIDC)→ 绑定仓库 `maplewf/dsh-web-update`;设置同 dsh-kube:勾 Publish directly、不勾 Manage dist-tags、不勾 Require additional authentication;
|
|
60
|
+
- 仓库 Settings → Pages → Source 选 **"GitHub Actions"**。
|
|
61
|
+
4. **打 tag 触发自动发布**:
|
|
62
|
+
```bash
|
|
63
|
+
git tag v0.1.0 && git push origin v0.1.0
|
|
64
|
+
```
|
|
65
|
+
(npm 幂等跳过已发布的版本,Pages 部署,Release 附 `.tgz`。)
|