dsh-crossterm 0.8.15 → 0.9.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/CHANGELOG.md +17 -0
- package/MAINTAINERS.md +18 -0
- package/README.md +11 -3
- package/cordis.patch.yml +9 -1
- package/lib/bus.js +1 -1
- package/lib/index.js +48 -1
- package/lib/restart/core.js +524 -0
- package/lib/restart/runtime.js +65 -0
- package/lib/restart/scripts/busy-check.mjs +193 -0
- package/lib/restart/scripts/countdown.html +427 -0
- package/lib/restart/scripts/dsh-restart-helper.mjs +299 -0
- package/lib/restart/scripts/get-geom.ps1 +23 -0
- package/lib/restart/scripts/rearm-watch.mjs +76 -0
- package/lib/restart/scripts/run-helper.cmd +13 -0
- package/lib/restart/scripts/topmost.ps1 +133 -0
- package/lib/restart/scripts/trigger-restart.mjs +186 -0
- package/package.json +4 -2
- package/parts/restart.manifest.json +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# dsh-crossterm 变更记录
|
|
2
2
|
|
|
3
|
+
## 0.9.0 — 2026-10-20
|
|
4
|
+
|
|
5
|
+
**自动重启并进互通插件(插件页第 6 个组件)**
|
|
6
|
+
|
|
7
|
+
User said (m12143):“将自动重启插件变成组件融合到互通插件内,任命原会话继续负责自动重启模块,
|
|
8
|
+
不再单独发版也不负责发版,每次修改更新后向你汇报,由你上传插件新版本”
|
|
9
|
+
|
|
10
|
+
- 原 `dsh-restart` 插件(包名 `dsh-restart-module` 0.3.28)代码并入 `lib/restart/`:`core.js`(`dsh_restart` 全套动作)
|
|
11
|
+
+ `scripts/`(`trigger-restart.mjs` / `dsh-restart-helper.mjs` / `busy-check.mjs` / `rearm-watch.mjs` / UI 页面等 8 个)
|
|
12
|
+
+ `runtime.js`(`ensureRestartRuntime()` 按版本把脚本同步到运行目录)。
|
|
13
|
+
- 新组件 `parts/restart`(插件页显示「自动重启」):`cordis.patch.yml` 第 6 行 insert、`config.part: restart`;
|
|
14
|
+
它不参与总线,只把 `dsh_restart` 工具挂到每个会话上。
|
|
15
|
+
- 运行目录:`<busDir>/restart-module/`(默认 `C:\Users\<你>\.dsh\crossterm\restart-module`),
|
|
16
|
+
启动时按版本同步脚本;`logs/`、`request.json`、`result.json` 一律不动,重启记录不会因为升级丢失。
|
|
17
|
+
- 旧插件 `dsh-restart-module` 若还装着,会与本组件重复注册 `dsh_restart`,需在 profile 里摘掉。
|
|
18
|
+
- 负责人:自动重启模块由原 `dsh-restart` 会话(`a3e9f80e`,会话名「自动重启」)继续维护,不单独发版;
|
|
19
|
+
改动汇报给插件主维护会话,由主维护会话并入 `dsh-crossterm` 一起发版。
|
|
3
20
|
## 0.8.15 — 2026-10-20
|
|
4
21
|
|
|
5
22
|
**为什么发这版**:YOCE_C 从 0.8.13 点更新到 0.8.14 后回归发现,没重启前 `/status` 仍只有 `version=0.8.13`、
|
package/MAINTAINERS.md
CHANGED
|
@@ -26,6 +26,17 @@
|
|
|
26
26
|
"since": "2026-10-18T00:00:00+08:00",
|
|
27
27
|
"scope": "按负责人派活改 lib/*.js;不得改版本号、总线状态、重启、C 盘写入、AGENTS.md"
|
|
28
28
|
},
|
|
29
|
+
"modules": {
|
|
30
|
+
"restart": {
|
|
31
|
+
"session": "session-a3e9f80e-6f28-425c-9807-0b9d8b872b5e",
|
|
32
|
+
"short": "a3e9f80e",
|
|
33
|
+
"name": "自动重启",
|
|
34
|
+
"role": "自动重启模块负责人(原 dsh-restart 插件作者会话)",
|
|
35
|
+
"since": "2026-10-20",
|
|
36
|
+
"scope": "lib/restart/ 下的 core.js、runtime.js、scripts/**",
|
|
37
|
+
"rule": "不单独发版、不自己发版;改完向主维护会话(b6aa099b)汇报,由主维护并入 dsh-crossterm 发版"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
29
40
|
"previous": [
|
|
30
41
|
{
|
|
31
42
|
"session": "session-6ef6da30-a7f1-4a4e-...",
|
|
@@ -42,6 +53,13 @@
|
|
|
42
53
|
}
|
|
43
54
|
-->
|
|
44
55
|
|
|
56
|
+
## 模块负责人(大插件里的小模块,可以分工)
|
|
57
|
+
|
|
58
|
+
一份插件里可以拆给多人:模块负责人只管自己那几支文件,发版仍由插件负责人统一做。
|
|
59
|
+
|
|
60
|
+
| 模块 | 负责人 | 范围 | 规矩 |
|
|
61
|
+
|---|---|---|---|
|
|
62
|
+
| 自动重启(`lib/restart/`,插件页第 ⑥ 个组件) | `a3e9f80e`(会话名「自动重启」) | `core.js` / `runtime.js` / `scripts/**` | 不单独发版、不自己发版;改完汇报给 `b6aa099b`,由插件负责人并入 `dsh-crossterm` 一起发版 |
|
|
45
63
|
## 任期表
|
|
46
64
|
|
|
47
65
|
| 起(本地时间) | 止(本地时间) | 会话 | 终端 / nodeId | 角色 | 交接依据 |
|
package/README.md
CHANGED
|
@@ -23,28 +23,36 @@ A 终端看不到 B 终端里有哪个会话、在干什么,也没法把一条
|
|
|
23
23
|
| ③ | 跨终端 | 同一台机器上的多个 DSH 终端/进程之间互发邮件与文件 | `term_whoami` `term_list` `term_send` `term_send_files` |
|
|
24
24
|
| ④ | 跨设备 | 经云端总线,在多台机器的 DSH 之间互发邮件与文件 | `term_cloud` |
|
|
25
25
|
| ⑤ | 跨账号 | 预留位:后续用于跨账号互通,当前不挂工具 | — |
|
|
26
|
+
| ⑥ | 自动重启 | 改完插件/配置后让 DSH 自己重启一次,并自动拉起离线会话(原 `dsh-restart` 插件,0.9.0 起并入) | `dsh_restart` |
|
|
26
27
|
|
|
27
28
|
> 入口行为什么必须用裸包名:浏览器 client 半端只对裸包名行生效(`dsh-client-modules` 的
|
|
28
29
|
> `locatePkgJson()` 对子路径行返回 undefined),而插件页顶部标题与这一行共用同一份 `locale/zh.json` 的 meta,
|
|
29
30
|
> 所以它单独做入口(配置卡片 + 自动更新开关),标题带「(自更新)」;卡片头用 `shortTitle` 显示短名「跨端互通」。
|
|
30
31
|
|
|
31
|
-
**本版更新(0.
|
|
32
|
+
**本版更新(0.9.0)**
|
|
32
33
|
|
|
33
34
|
- **升级当次就能提示「待重启」**:以前这一步要等服务端换成新版才认得出来(YOCE_C 回归的第 3/4 步就是这样「看不见」)。
|
|
34
35
|
现在浏览器 client 自己带版本号(`CLIENT_VERSION`),点完更新就从 `/update` 响应的 `installed` / `before` 判断,
|
|
35
36
|
立刻把卡片切成「已装待重启」;渲染时还会按「磁盘版本 > 进程版本」持续推导,旧进程也提示得出来。
|
|
36
37
|
- `/check` 多返回一个 `running`(= 进程版本),与 `current` 并列,旧客户端也能照常解析。
|
|
38
|
+
- **自动重启并进来当第 6 个组件**:原 `dsh-restart` 插件的 `dsh_restart` 工具与 8 个 helper 脚本并入 `lib/restart/`,
|
|
39
|
+
插件页多一行「自动重启」。它不参与总线,只在每个会话上挂 `dsh_restart`;脚本首次启动时同步到
|
|
40
|
+
`<总线目录>/restart-module/`(默认 `C:\Users\<你>\.dsh\crossterm\restart-module`)。
|
|
41
|
+
- **不再单独发版**:自动重启模块由原 `dsh-restart` 会话(`a3e9f80e`,会话名「自动重启」)继续维护,
|
|
42
|
+
改动汇报给插件主维护会话,由主维护会话并入本插件一起发版。
|
|
43
|
+
- 旧的 `dsh-restart-module` 插件还装着时会重复注册 `dsh_restart`,需在 profile 里摘掉它(本机另行处理)。
|
|
37
44
|
- 本机是 `link:` 源码版,没有这层差别;以上对用 npm 安装的设备生效。
|
|
38
45
|
|
|
39
|
-
**上一版(0.8.
|
|
46
|
+
**上一版(0.8.15)**
|
|
40
47
|
|
|
41
48
|
- **「更新」按钮不再看起来没用**:装完新版但还没重启时,卡片多一行「待重启」、
|
|
42
49
|
更新按钮变成不可点的「已装待重启」,接口 `/check` 改回 `needRestart=true` 而不是继续报「有更新」。
|
|
43
50
|
- 根因是状态表达:宿主进程里还是旧版本号,而磁盘上已经装了新版 —— 现在这两个版本分开显示。
|
|
44
51
|
- 本机是 `link:` 源码版(磁盘版本永远等于源码版本),所以这行只会在 npm 安装的设备上出现。
|
|
45
52
|
|
|
46
|
-
**更早(0.8.13 / 0.8.12 / 0.8.11 / 0.8.10 / 0.8.9 / 0.8.8 / 0.8.7 / 0.8.6 / 0.8.5 / 0.8.0)**
|
|
53
|
+
**更早(0.8.14 / 0.8.13 / 0.8.12 / 0.8.11 / 0.8.10 / 0.8.9 / 0.8.8 / 0.8.7 / 0.8.6 / 0.8.5 / 0.8.0)**
|
|
47
54
|
|
|
55
|
+
- 0.8.14:装完未重启时卡片显示「待重启」、更新按钮变灰「已装待重启」,`/check` 回 `needRestart=true`。
|
|
48
56
|
- 0.8.13:已经是最新就不装;没写收件人的信优先投给 `MAINTAINERS.md` 里的维护者会话。
|
|
49
57
|
- 0.8.12 / 0.8.11:修「点更新必定失败」(pnpm 不认 `--prefer-online`)、装低自动回滚、最新版取两个源的最大值。
|
|
50
58
|
- 0.8.10 / 0.8.9 / 0.8.8 / 0.8.7:云端设备只列别人、带权限与状态、版本仅在差异时显示;插件页标题改「跨端互通(自更新)」;
|
package/cordis.patch.yml
CHANGED
|
@@ -18,6 +18,8 @@
|
|
|
18
18
|
# ③ dsh-crossterm/parts/terminal 跨终端:term_whoami / term_list / term_send / term_send_files
|
|
19
19
|
# ④ dsh-crossterm/parts/device 跨设备:term_cloud(云端总线同步)
|
|
20
20
|
# ⑤ dsh-crossterm/parts/account 跨账号:预留占位,暂不挂工具
|
|
21
|
+
⑥ dsh-crossterm/parts/restart 自动重启:dsh_restart(原 dsh-restart 插件,0.9.0 起并入)
|
|
22
|
+
它不碰总线,只把 dsh_restart 工具挂到每个会话上。
|
|
21
23
|
#
|
|
22
24
|
# 组件名来自 package.json 的 exports 映射:
|
|
23
25
|
# "./parts/session/package.json" -> "./parts/session.manifest.json"
|
|
@@ -32,7 +34,7 @@
|
|
|
32
34
|
# 关掉入口行只失去「配置卡片 + 自动更新」,四个业务组件照常工作、各自仍可单独关。
|
|
33
35
|
# 之前(0.7.x–0.8.8)是 ui 行 provide('crossterm')、其余四行 inject 它,关入口会连坐——已废弃。
|
|
34
36
|
#
|
|
35
|
-
#
|
|
37
|
+
# 前五个组件在同一 DSH 进程里共用一份总线实例(自动重启不参与,它只挂自己的工具):心跳只起一次,云同步只在 device 组件启用
|
|
36
38
|
# 且 config.json 里 cloudEnabled=true 时才跑。安装/改动后需重启对应的 DSH 进程。
|
|
37
39
|
# ============================================================================
|
|
38
40
|
|
|
@@ -59,3 +61,9 @@
|
|
|
59
61
|
name: dsh-crossterm/parts/account
|
|
60
62
|
config:
|
|
61
63
|
part: account
|
|
64
|
+
- id: crossterm-restart
|
|
65
|
+
# 自动重启(原 dsh-restart 插件):不参与总线,只挂 dsh_restart 工具。
|
|
66
|
+
# helper 脚本随包分发在 lib/restart/scripts/,启动时复制到 <busDir>/restart-module/。
|
|
67
|
+
name: dsh-crossterm/parts/restart
|
|
68
|
+
config:
|
|
69
|
+
part: restart
|
package/lib/bus.js
CHANGED
|
@@ -23,7 +23,7 @@ import path from 'node:path'
|
|
|
23
23
|
import crypto from 'node:crypto'
|
|
24
24
|
import { rotateIfNeeded } from './logs.js'
|
|
25
25
|
|
|
26
|
-
export const VERSION = '0.
|
|
26
|
+
export const VERSION = '0.9.0'
|
|
27
27
|
|
|
28
28
|
/** DSH 的家目录:与宿主其它状态(sessions / profiles)同一个根,多终端天然共享 */
|
|
29
29
|
export function dshHome() {
|
package/lib/index.js
CHANGED
|
@@ -42,6 +42,7 @@ import { runSetup } from './cloud/setup.js'
|
|
|
42
42
|
import { deviceRow, matchDevice } from './cloud/match.js'
|
|
43
43
|
import { registerWeb, selfUpdate } from './web.js'
|
|
44
44
|
import { recordOwnership, readMaintainersDoc } from './logs.js'
|
|
45
|
+
import { ensureRestartRuntime } from './restart/runtime.js'
|
|
45
46
|
|
|
46
47
|
const PLUGIN = 'dsh-crossterm'
|
|
47
48
|
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
|
|
@@ -1511,7 +1512,7 @@ const TOOL_PART = {
|
|
|
1511
1512
|
term_cloud: 'device',
|
|
1512
1513
|
}
|
|
1513
1514
|
|
|
1514
|
-
const PARTS = ['all', 'ui', 'session', 'terminal', 'device', 'account']
|
|
1515
|
+
const PARTS = ['all', 'ui', 'session', 'terminal', 'device', 'account', 'restart']
|
|
1515
1516
|
|
|
1516
1517
|
const PART_LABEL = {
|
|
1517
1518
|
all: '全部组件',
|
|
@@ -1520,6 +1521,7 @@ const PART_LABEL = {
|
|
|
1520
1521
|
terminal: '跨终端',
|
|
1521
1522
|
device: '跨设备',
|
|
1522
1523
|
account: '跨账号(预留)',
|
|
1524
|
+
restart: '自动重启',
|
|
1523
1525
|
}
|
|
1524
1526
|
|
|
1525
1527
|
function normalizePart(raw) {
|
|
@@ -2079,10 +2081,55 @@ function releaseTerm(term) {
|
|
|
2079
2081
|
|
|
2080
2082
|
// ── 入口 ──────────────────────────────────────────────────────────────────
|
|
2081
2083
|
|
|
2084
|
+
const RESTART_SRC = path.join(ROOT, 'lib', 'restart', 'scripts')
|
|
2085
|
+
|
|
2086
|
+
/**
|
|
2087
|
+
* 「自动重启」组件(原 dsh-restart 插件,0.9.0 起并入)。
|
|
2088
|
+
*
|
|
2089
|
+
* 它不参与总线:只把 dsh_restart 工具挂到每个会话上,并把 helper 脚本复制到
|
|
2090
|
+
* 可写目录后交给 ./restart/core.js。脚本必须在 import core.js **之前**落到
|
|
2091
|
+
* DSH_RESTART_MODULE_DIR,因为 core.js 在模块顶层读这个环境变量。
|
|
2092
|
+
*/
|
|
2093
|
+
function mountRestart(root, config) {
|
|
2094
|
+
const label = 'dsh-crossterm(自动重启)'
|
|
2095
|
+
let destDir = ''
|
|
2096
|
+
const mark = (line) => {
|
|
2097
|
+
const text = `[${new Date().toISOString()}] ${label}: ${line}\n`
|
|
2098
|
+
try {
|
|
2099
|
+
if (destDir) {
|
|
2100
|
+
const dir = path.join(destDir, 'logs')
|
|
2101
|
+
fs.mkdirSync(dir, { recursive: true })
|
|
2102
|
+
fs.appendFileSync(path.join(dir, 'plugin.log'), text)
|
|
2103
|
+
}
|
|
2104
|
+
} catch { /* ignore */ }
|
|
2105
|
+
}
|
|
2106
|
+
try {
|
|
2107
|
+
const cfg = readConfig()
|
|
2108
|
+
destDir = path.join(cfg.busDir, 'restart-module')
|
|
2109
|
+
const info = ensureRestartRuntime({ srcDir: RESTART_SRC, destDir, version: VERSION })
|
|
2110
|
+
if (info.skipped.length) mark(`脚本缺失:${info.skipped.join(', ')}`)
|
|
2111
|
+
if (!process.env.DSH_RESTART_MODULE_DIR) process.env.DSH_RESTART_MODULE_DIR = destDir
|
|
2112
|
+
mark(`运行目录就绪:${destDir}(本次复制 ${info.copied.length} 个脚本)`)
|
|
2113
|
+
void import('./restart/core.js')
|
|
2114
|
+
.then((mod) => {
|
|
2115
|
+
mod.default.apply(root, { ...config, part: 'restart' })
|
|
2116
|
+
mark('已挂载 dsh_restart 工具')
|
|
2117
|
+
})
|
|
2118
|
+
.catch((e) => mark(`加载失败:${(e && e.message) || String(e)}`))
|
|
2119
|
+
} catch (e) {
|
|
2120
|
+
mark(`启动失败:${(e && e.message) || String(e)}`)
|
|
2121
|
+
}
|
|
2122
|
+
}
|
|
2123
|
+
|
|
2082
2124
|
export default {
|
|
2083
2125
|
name: PLUGIN,
|
|
2084
2126
|
apply(root, config) {
|
|
2085
2127
|
const part = normalizePart(config?.part)
|
|
2128
|
+
// 「自动重启」是独立组件:不碰总线,只挂 dsh_restart 工具。
|
|
2129
|
+
if (part === 'restart') {
|
|
2130
|
+
mountRestart(root, config)
|
|
2131
|
+
return
|
|
2132
|
+
}
|
|
2086
2133
|
// 0.8.9 起「入口」组件不再当总开关:它只负责插件卡片与「自动更新」,
|
|
2087
2134
|
// 四个业务组件(跨会话/跨终端/跨设备/跨账号)各挂各的 —— 关掉入口行不会连坐。
|
|
2088
2135
|
// 自动更新默认关(cfg.autoUpdate=false),开关在卡片里,改了落 config.json。
|