@hyzyn/dsh-tty 0.18.0 → 0.18.1
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 +42 -2
- package/README.md +37 -2
- package/client.js +26 -26
- package/lib/index.js +50 -24
- package/lib/index.js.map +1 -1
- package/lib/shell-integration.d.ts +20 -2
- package/lib/shell-integration.js +52 -2
- package/lib/shell-integration.js.map +1 -1
- package/package.json +2 -2
package/README.en.md
CHANGED
|
@@ -53,6 +53,41 @@ After installing, restart `dsh web`; a “Terminal” entry appears in the sideb
|
|
|
53
53
|
|
|
54
54
|

|
|
55
55
|
|
|
56
|
+
## Windows hosts (0.18.1, best-effort)
|
|
57
|
+
|
|
58
|
+
**Before 0.18.1 a Windows host could not open a single local terminal**, for two reasons on the same path:
|
|
59
|
+
|
|
60
|
+
1. `$SHELL` **does not exist on Windows**, and the default shell fell back to `/bin/zsh` unconditionally →
|
|
61
|
+
`spawn` fails with ENOENT (measured: `spawn /bin/zsh -> ENOENT`, while `%COMSPEC%` works);
|
|
62
|
+
2. the spawn plan was POSIX-shaped (`-c 'export TERM=…; export COLORTERM=…; exec "$shell"'`) — cmd.exe does
|
|
63
|
+
not understand `-c` (it ignores the whole line, runs an empty session and exits, so the tab appears and
|
|
64
|
+
vanishes), and PowerShell understands `-c` but rejects `export` as an unknown cmdlet.
|
|
65
|
+
|
|
66
|
+
Both were reproduced on **Windows 11 ARM (24H2) + Node 22 ARM64**. The fix:
|
|
67
|
+
|
|
68
|
+
- **Default shell is `%COMSPEC%`** (guaranteed to exist); for PowerShell put the full path to
|
|
69
|
+
`powershell.exe` / `pwsh.exe` in the settings card’s “Shell path”. On Windows the candidate list offers
|
|
70
|
+
`%COMSPEC%` + Windows PowerShell 5.1 + PowerShell 7 (when installed), with the default first;
|
|
71
|
+
- **No wrapper layer on Windows**: plain `[shell]`; the PowerShell family gets `-NoLogo` (drops the copyright
|
|
72
|
+
banner) but deliberately **not `-NoProfile`** — the user’s profile is where aliases and functions come from.
|
|
73
|
+
TERM / COLORTERM are meaningless for ConPTY and are no longer injected;
|
|
74
|
+
- **“Run one command” tabs** (docker exec, command tabs opened by the agent) use `cmd /c` or
|
|
75
|
+
`PowerShell -Command`;
|
|
76
|
+
- **Three things are not supported** (the host turns them off and the settings card explains why):
|
|
77
|
+
- **Shell integration (OSC 133/7)**: injection relies on POSIX rc stubs plus the `-c` wrapper, neither of
|
|
78
|
+
which exists for cmd / PowerShell, so it is permanently off — **local** tabs therefore lose cwd tracking
|
|
79
|
+
(`tty_list.cwd` following `cd`), `tty_capture{last}` and command-granular `tty_expect` (remote Linux /
|
|
80
|
+
macOS hosts are unaffected);
|
|
81
|
+
- **tmux persistence**: there is no tmux on Windows, so local tabs open normally but are not managed
|
|
82
|
+
(SSH into a Linux host still works);
|
|
83
|
+
- **Server status bar**: locally only CPU / memory / uptime are available (`node:os`); disk / TCP / network
|
|
84
|
+
throughput / temperature show “无” (remote **Windows** hosts go through the PowerShell hop — see the
|
|
85
|
+
status-bar section);
|
|
86
|
+
- **How far this was verified**: on Windows 11 ARM a full install (`dsh plugin add @hyzyn/dsh-all`), all nine
|
|
87
|
+
plugins mounting, `dsh web` serving, and the browser half being delivered (the same artifact macOS serves:
|
|
88
|
+
12,312,246 bytes, identical new-code markers), plus `[dsh-tty] mounted (shell=C:\WINDOWS\system32\cmd.exe)`.
|
|
89
|
+
x64 Windows is covered by the CI matrix (build / typecheck / test, see Development).
|
|
90
|
+
|
|
56
91
|
## Agent tools (P1)
|
|
57
92
|
|
|
58
93
|
The plugin injects thirteen tools into the agent (with the same power as the bash tool; operations show up live in the user’s terminal):
|
|
@@ -695,10 +730,15 @@ verify things like “is there still a white panel after switching light/dark th
|
|
|
695
730
|
passes through `(handle).terminal.resize(cols, rows)` directly (node-pty’s native API, reachable in the
|
|
696
731
|
same process). If a DSH upgrade changes the internals, since 0.3.0 it warns once and degrades to a fixed
|
|
697
732
|
size instead of throwing on every frame.
|
|
698
|
-
- **TERM is injected through a `-c` wrapper layer**: DSH hardcodes node-pty `name:"dumb"`, and in
|
|
733
|
+
- **TERM is injected through a `-c` wrapper layer (POSIX only)**: DSH hardcodes node-pty `name:"dumb"`, and in
|
|
699
734
|
node-pty name takes precedence over env.TERM, so the shell is started as
|
|
700
735
|
`sh -c 'export TERM=...; exec "$shell"'` (transparent to the user; the TERM /
|
|
701
|
-
COLORTERM values are whitelisted to avoid breaking the wrapper command).
|
|
736
|
+
COLORTERM values are whitelisted to avoid breaking the wrapper command). **There is no such layer on
|
|
737
|
+
Windows** — neither cmd nor PowerShell understands that syntax, and ConPTY does not need TERM (see the
|
|
738
|
+
“Windows hosts” section).
|
|
739
|
+
- **Windows hosts**: local terminals work (default `%COMSPEC%`), but shell integration, tmux persistence and
|
|
740
|
+
disk / TCP / throughput / temperature are unsupported or unavailable — the full boundary and verification
|
|
741
|
+
scope are in the “Windows hosts” section.
|
|
702
742
|
- **terminate() has a “survivor” race**: DSH’s tree-level cleanup occasionally reports
|
|
703
743
|
`terminal cleanup failed; surviving pids`, which the plugin handles best-effort
|
|
704
744
|
(on failure it degrades to SIGKILL on the top-level shell), and the exit code/signal may be null.
|
package/README.md
CHANGED
|
@@ -53,6 +53,38 @@ dsh plugin --profile web add link:$(pwd)/packages/tty # 仓库开发调试
|
|
|
53
53
|
|
|
54
54
|

|
|
55
55
|
|
|
56
|
+
## Windows 宿主(0.18.1,best-effort)
|
|
57
|
+
|
|
58
|
+
**0.18.1 之前,Windows 宿主上的本地终端一条都开不起来**,两处都在同一条路径上:
|
|
59
|
+
|
|
60
|
+
1. `$SHELL` 在 Windows 上**根本不存在**,默认 shell 无条件回落 `/bin/zsh` → `spawn` 直接
|
|
61
|
+
ENOENT(实测:`spawn /bin/zsh -> ENOENT`,而 `%COMSPEC%` 可用);
|
|
62
|
+
2. 启动计划是 POSIX 形状的 `-c 'export TERM=…; export COLORTERM=…; exec "$shell"'` ——
|
|
63
|
+
cmd.exe 不认 `-c`(忽略整行、空跑一场就退出,标签开了就消失),PowerShell 认 `-c` 但把
|
|
64
|
+
`export` 当不存在的 cmdlet 报错。
|
|
65
|
+
|
|
66
|
+
两条都在 **Windows 11 ARM(24H2)+ Node 22 ARM64** 上实测复现,修法:
|
|
67
|
+
|
|
68
|
+
- **默认 shell = `%COMSPEC%`**(系统保证存在);要 PowerShell 就在设置卡片把「Shell 路径」
|
|
69
|
+
填成 `powershell.exe` / `pwsh.exe` 的完整路径。Windows 上候选列表给的是 `%COMSPEC%` +
|
|
70
|
+
Windows PowerShell 5.1 + PowerShell 7(装了才有),默认项排最前;
|
|
71
|
+
- **Windows 上不做包装层**:直接 `[shell]`;PowerShell 家族补 `-NoLogo`(去掉版权横幅),
|
|
72
|
+
**不补 `-NoProfile`** —— 用户的 profile 正是别名与函数的来源。TERM / COLORTERM 对 ConPTY
|
|
73
|
+
没有意义,也不再注入;
|
|
74
|
+
- **「跑一条命令」的标签**(docker exec、agent 起的命令标签)走 `cmd /c` 或
|
|
75
|
+
`PowerShell -Command`;
|
|
76
|
+
- **不支持的三项(宿主侧自动关掉,设置卡片里写明原因)**:
|
|
77
|
+
- **shell 集成(OSC 133/7)**:注入靠 POSIX rc 桩 + `-c` 包装层,cmd / PowerShell 上都不成立,
|
|
78
|
+
因此恒关 —— **本地标签**的 `tty_list.cwd` 跟随 `cd`、`tty_capture{last}` 与 `tty_expect`
|
|
79
|
+
的命令粒度不可用(远程 Linux / macOS 主机照旧支持);
|
|
80
|
+
- **tmux 持久化**:Windows 上没有 tmux,本地标签照常打开但不受托管(SSH 到 Linux 主机仍可用);
|
|
81
|
+
- **服务器状态条**:本地只拿得到 CPU / 内存 / 在线时长(`node:os`),磁盘 / TCP / 网速 / 温度
|
|
82
|
+
显示「无」(**远端** Windows 主机走 PowerShell 那一跳,见「服务器状态条」一节);
|
|
83
|
+
- **验证到什么程度**:Windows 11 ARM 上跑过完整安装(`dsh plugin add @hyzyn/dsh-all`)、九个插件
|
|
84
|
+
装载、`dsh web` 起服务与浏览器半体交付(与 macOS 上服务的是同一份产物:12 312 246 字节、
|
|
85
|
+
新代码标记一致)、`[dsh-tty] mounted (shell=C:\WINDOWS\system32\cmd.exe)`;x64 Windows 由 CI
|
|
86
|
+
的三平台矩阵覆盖(build / typecheck / test,见「开发」)。
|
|
87
|
+
|
|
56
88
|
## agent 工具(P1)
|
|
57
89
|
|
|
58
90
|
插件向 agent 注入十三个工具(与 bash 工具同权,操作实时显示在用户终端里):
|
|
@@ -664,10 +696,13 @@ node scripts/preview.mjs --theme=light # 浅色主题
|
|
|
664
696
|
插件直接透传 `(handle).terminal.resize(cols, rows)`(node-pty 原生 API,
|
|
665
697
|
同进程可达)。DSH 升级若改内部结构,0.3.0 起会警告一次并退化为固定尺寸,
|
|
666
698
|
不再逐帧抛错。
|
|
667
|
-
- **TERM 注入用 `-c`
|
|
699
|
+
- **TERM 注入用 `-c` 包装层(仅 POSIX)**:DSH 硬编码 node-pty `name:"dumb"`,而
|
|
668
700
|
node-pty 里 name 优先于 env.TERM,因此 shell 以
|
|
669
701
|
`sh -c 'export TERM=...; exec "$shell"'` 方式启动(对用户透明;TERM /
|
|
670
|
-
COLORTERM
|
|
702
|
+
COLORTERM 值做白名单校验,防止破坏包装层命令)。**Windows 上没有这一层** —— cmd /
|
|
703
|
+
PowerShell 都不认这套语法,ConPTY 也不需要 TERM(见「Windows 宿主」一节)。
|
|
704
|
+
- **Windows 宿主**:本地终端可用(默认 `%COMSPEC%`),但 shell 集成 / tmux 持久化 /
|
|
705
|
+
磁盘·TCP·网速·温度这几项不适用或拿不到 —— 完整边界与验证范围见「Windows 宿主」一节。
|
|
671
706
|
- **terminate() 有「幸存者」竞态**:DSH 树级清理偶发报
|
|
672
707
|
`terminal cleanup failed; surviving pids`,插件按 best-effort 处理
|
|
673
708
|
(失败降级对顶层 shell 直接 SIGKILL),退出码/信号可能为 null。
|