dsh-bash-terminal-ts 0.5.0 → 0.5.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/README.en.md CHANGED
@@ -1,4 +1,4 @@
1
- # dsh-bash-terminal
1
+ # dsh-bash-terminal-ts
2
2
 
3
3
  > Community: [LINUX DO](https://linux.do) · [GitHub](https://github.com/drscrewdriver/dsh-bash-terminal-ts)
4
4
 
@@ -10,7 +10,7 @@ A DeepSeek Harness (DSH) plugin: one `shell` tool that runs commands through **P
10
10
  >
11
11
  > | Branch | DSH segment | Package name | Status |
12
12
  > |--------|-------------|--------------|--------|
13
- > | `ts/0.1.5` | 0.1.5-alpha.1 – 0.1.5-rc.x | `dsh-bash-terminal` | this branch; `build` / `unit` / `apply` / `client` / `terminal` green locally |
13
+ > | `ts/0.1.5` | 0.1.5-alpha.1 – 0.1.5-rc.x | `dsh-bash-terminal-ts` | this branch; `build` / `unit` / `apply` / `client` / `terminal` green locally |
14
14
  > | `main` | 0.1.2-alpha.1 – 0.1.2-rc.x | `dsh-bash-terminal-ts` | the TypeScript rewrite's mainline |
15
15
  >
16
16
  > The two lines **deliberately use different package names**, so they install side by side without overwriting each other. Pick the branch that covers your DSH build.
@@ -20,7 +20,7 @@ A DeepSeek Harness (DSH) plugin: one `shell` tool that runs commands through **P
20
20
  | Backend | Runs | Syntax / paths | Env vars |
21
21
  |---------|------|----------------|----------|
22
22
  | `powershell` (default) | `pwsh -NoLogo -NoProfile -NonInteractive -Command <cmd>` | PowerShell; `C:\\...` | `$env:NAME` |
23
- | `gitbash` | Git for Windows `bash -lc <cmd>` | POSIX; `/d/WorkSpace`; PATH includes `/usr/bin` and `/mingw64/bin` | `$NAME` |
23
+ | `gitbash` | Git for Windows `bash -lc <cmd>` | POSIX; `/d/workspace`; PATH includes `/usr/bin` and `/mingw64/bin` | `$NAME` |
24
24
  | `msys2` | MSYS2 `bash -lc <cmd>` (`C:\msys64\usr\bin\bash.exe`) | POSIX; `/c/...`; PATH includes `/usr/bin` and `/mingw64/bin` (gcc / make) | `$NAME` (MSYSTEM=MINGW64 injected) |
25
25
  | `wsl` | `wsl [-d <distro>] -e bash -lc <cmd>` | Linux; `/mnt/d/...` | `$NAME` (via WSLENV) |
26
26
 
@@ -29,13 +29,19 @@ A DeepSeek Harness (DSH) plugin: one `shell` tool that runs commands through **P
29
29
  - **Interactive terminal**: the `terminal` tool opens persistent real-PTY sessions over node-pty — on non-Windows via the official `ctx.subprocess.spawnTerminal` seam, on Windows directly through node-pty because the upstream seam's process inspector is POSIX-only. Actions `open` / `send` / `read` / `signal` / `close`; shell state persists across calls; sessions are managed as background jobs and auto-close when idle.
30
30
  - **Background execution** via the generic jobs registry (`run_in_background` / `job_output` / `job_kill`).
31
31
 
32
+ ## Screenshots
33
+
34
+ The **Default terminal** row in Settings -> General: the user picks PowerShell / Git Bash / MSYS2 / WSL, and the `shell` tool obeys that choice — the model cannot override it.
35
+
36
+ ![Default terminal setting row](assets/shells.png)
37
+
32
38
  ## Install
33
39
 
34
- The package ships the official `dsh.bundle` manifest (its own `cordis.patch.yml`): listing `dsh-bash-terminal` in a profile's `dsh.profile.bundles` auto-applies the mount — no manual profile edits.
40
+ The package ships the official `dsh.bundle` manifest (its own `cordis.patch.yml`): listing `dsh-bash-terminal-ts` in a profile's `dsh.profile.bundles` auto-applies the mount — no manual profile edits.
35
41
 
36
42
  ```powershell
37
- npm install -g dsh-bash-terminal
38
- dsh plugin --profile web add dsh-bash-terminal # adds to profile bundles + applies the patch
43
+ npm install -g dsh-bash-terminal-ts
44
+ dsh plugin --profile web add dsh-bash-terminal-ts # adds to profile bundles + applies the patch
39
45
  powershell -ExecutionPolicy Bypass -File install.ps1 install # patches the DSH settings-UI allowlist (see below)
40
46
  # restart dsh web
41
47
  ```
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # dsh-bash-terminal
1
+ # dsh-bash-terminal-ts
2
2
 
3
3
  > 🌐 [English](README.en.md) · 社区交流:[LINUX DO](https://linux.do) · [GitHub](https://github.com/drscrewdriver/dsh-bash-terminal-ts)
4
4
 
@@ -10,7 +10,7 @@ DSH(DeepSeek Harness)插件:一个 `shell` 工具,在 Windows 上统一
10
10
  >
11
11
  > | 分支 | DSH 段 | 包名 | 状态 |
12
12
  > |------|--------|------|------|
13
- > | `ts/0.1.5` | 0.1.5-alpha.1 – 0.1.5-rc.x | `dsh-bash-terminal` | 本分支;`build` / `unit` / `apply` / `client` / `terminal` 本机全绿 |
13
+ > | `ts/0.1.5` | 0.1.5-alpha.1 – 0.1.5-rc.x | `dsh-bash-terminal-ts` | 本分支;`build` / `unit` / `apply` / `client` / `terminal` 本机全绿 |
14
14
  > | `main` | 0.1.2-alpha.1 – 0.1.2-rc.x | `dsh-bash-terminal-ts` | TypeScript 重写主线 |
15
15
  >
16
16
  > **两条线刻意使用不同包名**,因此可以并存安装、互不覆盖。请按你的 DSH 版本选分支。
@@ -18,12 +18,18 @@ DSH(DeepSeek Harness)插件:一个 `shell` 工具,在 Windows 上统一
18
18
  | 后端 | 实际执行 | 语法 / 路径 | 环境变量 |
19
19
  |------|----------|-------------|----------|
20
20
  | `powershell`(默认) | `pwsh -NoLogo -NoProfile -NonInteractive -Command <cmd>` | PowerShell;`C:\...` | `$env:NAME` |
21
- | `gitbash` | Git for Windows `bash -lc <cmd>` | POSIX;`/d/WorkSpace`;PATH 含 `/usr/bin`、`/mingw64/bin` | `$NAME` |
21
+ | `gitbash` | Git for Windows `bash -lc <cmd>` | POSIX;`/d/workspace`;PATH 含 `/usr/bin`、`/mingw64/bin` | `$NAME` |
22
22
  | `msys2` | MSYS2 `bash -lc <cmd>`(`C:\msys64\usr\bin\bash.exe`) | POSIX;`/c/...`;PATH 含 `/usr/bin`、`/mingw64/bin`(gcc / make) | `$NAME`(自动注入 `MSYSTEM=MINGW64`) |
23
23
  | `wsl` | `wsl [-d <distro>] -e bash -lc <cmd>` | Linux;`/mnt/d/...` | `$NAME`(经 WSLENV) |
24
24
 
25
25
  每次调用都启动全新 shell:**不保留状态**(cwd / 变量 / 别名)——请传 `workdir` 而不是用 `cd`。
26
26
 
27
+ ## 界面预览
28
+
29
+ 设置 → 通用 里的「默认终端」行:用户在 PowerShell / Git Bash / MSYS2 / WSL 之间选择,`shell` 工具只按这个设置执行,模型无法覆盖:
30
+
31
+ ![默认终端设置行](assets/shells.png)
32
+
27
33
  ## 设计要点
28
34
 
29
35
  - **终端由用户决定,AI 无法更改**:Web UI 设置页(设置 → 通用)出现"默认终端"下拉(PowerShell / Git Bash / MSYS2 / WSL);`shell` 工具永远只使用该设置,不暴露终端参数给模型。设置通过 DSH settings 系统持久化(settings.yaml)。
@@ -40,8 +46,8 @@ DSH(DeepSeek Harness)插件:一个 `shell` 工具,在 Windows 上统一
40
46
 
41
47
  ```powershell
42
48
  # 1. 安装插件包
43
- npm install -g dsh-bash-terminal
44
- dsh plugin --profile web add dsh-bash-terminal # 自动加进 profile 的 bundles 并应用 patch
49
+ npm install -g dsh-bash-terminal-ts
50
+ dsh plugin --profile web add dsh-bash-terminal-ts # 自动加进 profile 的 bundles 并应用 patch
45
51
 
46
52
  # 2. patch DSH 设置白名单(DSH 限制,见下方说明)
47
53
  powershell -ExecutionPolicy Bypass -File install.ps1 install
@@ -49,21 +55,21 @@ powershell -ExecutionPolicy Bypass -File install.ps1 install
49
55
  # 3. 重启 dsh web
50
56
  ```
51
57
 
52
- > 已用临时 profile 实测:`bundles: [dsh-bash-terminal]` → dump-config 自动出现 `tool-bash-terminal` entry。
58
+ > 已用临时 profile 实测:`bundles: [dsh-bash-terminal-ts]` → dump-config 自动出现 `tool-bash-terminal` entry。
53
59
 
54
60
  ### 本地开发安装(junction 直连,改源码即时生效)
55
61
 
56
62
  ```powershell
57
63
  # 1. 链接插件包到 profile 的 node_modules(junction,改源码即时生效)
58
64
  $profile = "$env:USERPROFILE\.dsh\profiles\web"
59
- New-Item -ItemType Junction -Path "$profile\node_modules\dsh-bash-terminal" -Target "D:\WorkSpace\projects\dsh-bash-terminal" | Out-Null
65
+ New-Item -ItemType Junction -Path "$profile\node_modules\dsh-bash-terminal-ts" -Target "D:\workspace\projects\dsh-bash-terminal-ts" | Out-Null
60
66
 
61
67
  # 2. 让插件能解析 @deepseek-ai/* 依赖(junction 到 profile 的依赖树,插件与宿主共用同一份模块实例)
62
- New-Item -ItemType Junction -Path "D:\WorkSpace\projects\dsh-bash-terminal\node_modules\@deepseek-ai" -Target "$profile\..\node_modules\@deepseek-ai" | Out-Null
68
+ New-Item -ItemType Junction -Path "D:\workspace\projects\dsh-bash-terminal-ts\node_modules\@deepseek-ai" -Target "$profile\..\node_modules\@deepseek-ai" | Out-Null
63
69
 
64
- # 3. 让 profile 通过官方 bundle 挂载插件(install.ps1 install 会自动做;等价于在 dsh.profile.bundles 加 "dsh-bash-terminal")
70
+ # 3. 让 profile 通过官方 bundle 挂载插件(install.ps1 install 会自动做;等价于在 dsh.profile.bundles 加 "dsh-bash-terminal-ts")
65
71
  # 4. (仅修改前端源码后)重新打包 client bundle:
66
- # cd D:\WorkSpace\projects\dsh-bash-terminal && node scripts/build-client.mjs
72
+ # cd D:\workspace\projects\dsh-bash-terminal-ts && node scripts/build-client.mjs
67
73
  # 5. 重启 dsh web
68
74
  ```
69
75
 
@@ -78,12 +84,12 @@ New-Item -ItemType Junction -Path "D:\WorkSpace\projects\dsh-bash-terminal\node_
78
84
  > 另:0.1.5 的 Web 设置面改为 `settings.describe()` 动态枚举,**不再有 namespace 白名单**
79
85
  > (`settings-not-exposed` 已不存在),`install.ps1` 里的白名单 patch 只是历史遗留、可忽略。
80
86
 
81
- > 当前已不再需要手动改 profile 的 `cordis.patch.yml`:插件包内自带 `dsh.bundle.patch`(包内 `cordis.patch.yml`),只要 profile 的 `dsh.profile.bundles` 里有 `dsh-bash-terminal`,DSH 就会自动挂载。
87
+ > 当前已不再需要手动改 profile 的 `cordis.patch.yml`:插件包内自带 `dsh.bundle.patch`(包内 `cordis.patch.yml`),只要 profile 的 `dsh.profile.bundles` 里有 `dsh-bash-terminal-ts`,DSH 就会自动挂载。
82
88
 
83
89
  验证组合树(无需重启):
84
90
 
85
91
  ```powershell
86
- node "$env:APPDATA\nvm\v24.16.0\node_modules\@deepseek-ai\dsh\lib\bin.js" --profile web --dump-config | Select-String dsh-bash-terminal
92
+ node "$env:APPDATA\nvm\<node-version>\node_modules\@deepseek-ai\dsh\lib\bin.js" --profile web --dump-config | Select-String dsh-bash-terminal-ts
87
93
  ```
88
94
 
89
95
  ## 使用
@@ -94,7 +100,7 @@ node "$env:APPDATA\nvm\v24.16.0\node_modules\@deepseek-ai\dsh\lib\bin.js" --prof
94
100
 
95
101
  - 默认终端 = Git Bash 时:`shell(command: "git status")` 走 Git Bash
96
102
  - 默认终端 = MSYS2 时:`shell(command: "gcc --version")` 走 MSYS2(MINGW64 环境,`/mingw64/bin` 的 gcc、make 可用)
97
- - 默认终端 = WSL 时:`shell(command: "ls -la /mnt/d/WorkSpace")` 走 WSL;传 `distro: "Ubuntu"` 可指定发行版
103
+ - 默认终端 = WSL 时:`shell(command: "ls -la /mnt/d/workspace")` 走 WSL;传 `distro: "Ubuntu"` 可指定发行版
98
104
  - 默认终端 = PowerShell 时:`shell(command: "Get-Process node")` 走 PowerShell
99
105
 
100
106
  ## 模型使用示例
@@ -126,7 +132,7 @@ node "$env:APPDATA\nvm\v24.16.0\node_modules\@deepseek-ai\dsh\lib\bin.js" --prof
126
132
  npm 账号已启用 2FA 发布验证,需一次性验证码:
127
133
 
128
134
  ```powershell
129
- cd D:\WorkSpace\projects\dsh-bash-terminal
135
+ cd D:\workspace\projects\dsh-bash-terminal-ts
130
136
  npm publish --otp <验证码> # 验证码来自你的认证器
131
137
  ```
132
138
 
@@ -140,9 +146,9 @@ npm publish --otp <验证码> # 验证码来自你的认证器
140
146
  powershell -ExecutionPolicy Bypass -File install.ps1 uninstall
141
147
  ```
142
148
 
143
- 它会删除 junction、恢复设置白名单、清理旧版遗留的 `cordis.patch.yml` 挂载块,并从 `dsh.profile.bundles` 移除 `dsh-bash-terminal`。之后重启 dsh web 即可。
149
+ 它会删除 junction、恢复设置白名单、清理旧版遗留的 `cordis.patch.yml` 挂载块,并从 `dsh.profile.bundles` 移除 `dsh-bash-terminal-ts`。之后重启 dsh web 即可。
144
150
 
145
- 手动卸载时,除了删除 `node_modules\dsh-bash-terminal`,还要记得从 profile `package.json` 的 `dsh.profile.bundles` 中移除 `dsh-bash-terminal`。
151
+ 手动卸载时,除了删除 `node_modules\dsh-bash-terminal-ts`,还要记得从 profile `package.json` 的 `dsh.profile.bundles` 中移除 `dsh-bash-terminal-ts`。
146
152
 
147
153
  ## 交互式终端(terminal 工具)
148
154
 
@@ -188,7 +194,7 @@ powershell -ExecutionPolicy Bypass -File install.ps1 uninstall
188
194
  ## 测试
189
195
 
190
196
  ```powershell
191
- cd D:\WorkSpace\projects\dsh-bash-terminal
197
+ cd D:\workspace\projects\dsh-bash-terminal-ts
192
198
  npm install # 安装依赖(含 typescript)
193
199
  npm run build # tsc 编译 src/*.ts → lib/*.js;client.tsx → lib/client.js + dist/client.js;test/*.ts → test-dist/
194
200
  npm test # node test-dist/unit.js → apply.js → client.js → terminal.js
package/cordis.patch.yml CHANGED
@@ -1,5 +1,5 @@
1
- # dsh-bash-terminal bundle layer — applied automatically when a profile lists
1
+ # dsh-bash-terminal-ts bundle layer — applied automatically when a profile lists
2
2
  # this package in dsh.profile.bundles (dsh.bundle.patch declaration).
3
3
  - insert:
4
4
  - id: tool-bash-terminal
5
- name: 'dsh-bash-terminal'
5
+ name: 'dsh-bash-terminal-ts'
@@ -1,139 +1,139 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/client.tsx
20
- var client_exports = {};
21
- __export(client_exports, {
22
- apply: () => apply,
23
- inject: () => inject
24
- });
25
- module.exports = __toCommonJS(client_exports);
26
- var import_react = require("react");
27
- var import_dsh_client_store = require("@deepseek-ai/dsh-client-store");
28
- var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
29
- var import_jsx_runtime = require("react/jsx-runtime");
30
- var SETTINGS_NS = "settings.bash-terminal";
31
- var SETTINGS_NAMESPACE = "bash-terminal";
32
- var SHELLS = ["powershell", "gitbash", "msys2", "wsl"];
33
- var ROW_CSS = ".btRow{border-bottom:1px solid var(--dsw-alias-border-l2);align-items:center;gap:8px;padding:16px 0;display:flex}.btRowText{flex-direction:column;flex:1;gap:4px;min-width:0;padding-right:48px;display:flex}.btTitle{color:var(--dsw-alias-label-primary);font-size:14px;font-weight:400;line-height:22px}.btDesc{color:var(--dsw-alias-label-tertiary);font-size:12px;font-weight:400;line-height:18px}.btSelector{background:var(--dsw-alias-bg-module-platform);height:36px;font:inherit;color:var(--dsw-alias-label-primary);cursor:pointer;border:none;border-radius:18px;align-items:center;gap:12px;padding:0 14px;font-size:14px;line-height:22px;display:inline-flex}.btSelector:hover{background:var(--dsw-alias-interactive-bg-hover)}.btChevron{flex:none}";
34
- if (typeof document !== "undefined" && document.querySelector('style[data-plugin-css="bash-terminal-row"]') === null) {
35
- const tag = document.createElement("style");
36
- tag.dataset.plugin = "dsh-bash-terminal";
37
- tag.dataset.pluginCss = "bash-terminal-row";
38
- tag.textContent = ROW_CSS;
39
- document.head.appendChild(tag);
40
- }
41
- var zh = {
42
- "shell.title": "\u9ED8\u8BA4\u7EC8\u7AEF",
43
- "shell.description": "shell \u5DE5\u5177\u6267\u884C\u547D\u4EE4\u65F6\u4F7F\u7528\u7684\u7EC8\u7AEF",
44
- "shell.powershell": "PowerShell",
45
- "shell.gitbash": "Git Bash",
46
- "shell.msys2": "MSYS2",
47
- "shell.wsl": "WSL"
48
- };
49
- var en = {
50
- "shell.title": "Default terminal",
51
- "shell.description": "Terminal used by the shell tool",
52
- "shell.powershell": "PowerShell",
53
- "shell.gitbash": "Git Bash",
54
- "shell.msys2": "MSYS2",
55
- "shell.wsl": "WSL"
56
- };
57
- var inject = ["slots", "locale", "settingsScope"];
58
- function ShellPreferenceRow({ t, useStore, setShell }) {
59
- const shell = useStore((s) => s.shell);
60
- const writable = useStore((s) => s.writable);
61
- const [open, setOpen] = (0, import_react.useState)(false);
62
- const items = SHELLS.map((id) => ({ id, label: t("shell." + id) }));
63
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "btRow", children: [
64
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "btRowText", children: [
65
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "btTitle", children: t("shell.title") }),
66
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "btDesc", children: t("shell.description") })
67
- ] }),
68
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
69
- import_dsh_client_ui_primitives.Menu,
70
- {
71
- open,
72
- onClose: () => setOpen(false),
73
- items,
74
- selectedId: shell,
75
- onSelect: (id) => {
76
- setOpen(false);
77
- setShell(id);
78
- },
79
- align: "end",
80
- portal: true,
81
- anchor: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
82
- "button",
83
- {
84
- type: "button",
85
- className: "btSelector",
86
- "aria-haspopup": "menu",
87
- "aria-expanded": open,
88
- disabled: !writable,
89
- onClick: () => setOpen(!open),
90
- style: !writable ? { opacity: 0.5, cursor: "not-allowed" } : void 0,
91
- children: [
92
- t("shell." + shell),
93
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconChevronDownOutline14, { className: "btChevron" })
94
- ]
95
- }
96
- )
97
- }
98
- )
99
- ] });
100
- }
101
- function apply(ctx) {
102
- ctx.effect(() => ctx.locale.register(SETTINGS_NS, { zh, en }), "bash-terminal: settings dictionaries");
103
- const scope = ctx.settingsScope.bind({ namespace: SETTINGS_NAMESPACE });
104
- const store = (0, import_dsh_client_store.defineStore)({
105
- init: () => ({ shell: "powershell", revision: -1, writable: false }),
106
- actions: {
107
- sync: (d, shell, revision, writable) => {
108
- if (revision !== void 0 && revision <= d.revision) return;
109
- if (shell !== void 0) d.shell = shell;
110
- if (revision !== void 0) d.revision = revision;
111
- if (writable !== void 0) d.writable = writable;
112
- }
113
- }
114
- });
115
- let bound;
116
- const push = (snap) => {
117
- bound?.sync(snap.value?.defaultShell, snap.revision, snap.writable);
118
- };
119
- ctx.slots.inject(
120
- "settings.general.item",
121
- () => ctx.slots.register(
122
- {
123
- name: "settings.general.item",
124
- id: "bash-terminal-shell",
125
- order: 20,
126
- store,
127
- locale: SETTINGS_NS,
128
- inject: (actions) => {
129
- bound = actions;
130
- push(scope.getSnapshot());
131
- return { setShell: (value) => void scope.set("defaultShell", value) };
132
- }
133
- },
134
- ShellPreferenceRow
135
- ),
136
- "bash-terminal: settings row"
137
- );
138
- ctx.effect(() => scope.subscribe(() => push(scope.getSnapshot())), "bash-terminal: settings watch");
139
- }
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/client.tsx
20
+ var client_exports = {};
21
+ __export(client_exports, {
22
+ apply: () => apply,
23
+ inject: () => inject
24
+ });
25
+ module.exports = __toCommonJS(client_exports);
26
+ var import_react = require("react");
27
+ var import_dsh_client_store = require("@deepseek-ai/dsh-client-store");
28
+ var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
29
+ var import_jsx_runtime = require("react/jsx-runtime");
30
+ var SETTINGS_NS = "settings.bash-terminal";
31
+ var SETTINGS_NAMESPACE = "bash-terminal";
32
+ var SHELLS = ["powershell", "gitbash", "msys2", "wsl"];
33
+ var ROW_CSS = ".btRow{border-bottom:1px solid var(--dsw-alias-border-l2);align-items:center;gap:8px;padding:16px 0;display:flex}.btRowText{flex-direction:column;flex:1;gap:4px;min-width:0;padding-right:48px;display:flex}.btTitle{color:var(--dsw-alias-label-primary);font-size:14px;font-weight:400;line-height:22px}.btDesc{color:var(--dsw-alias-label-tertiary);font-size:12px;font-weight:400;line-height:18px}.btSelector{background:var(--dsw-alias-bg-module-platform);height:36px;font:inherit;color:var(--dsw-alias-label-primary);cursor:pointer;border:none;border-radius:18px;align-items:center;gap:12px;padding:0 14px;font-size:14px;line-height:22px;display:inline-flex}.btSelector:hover{background:var(--dsw-alias-interactive-bg-hover)}.btChevron{flex:none}";
34
+ if (typeof document !== "undefined" && document.querySelector('style[data-plugin-css="bash-terminal-row"]') === null) {
35
+ const tag = document.createElement("style");
36
+ tag.dataset.plugin = "dsh-bash-terminal-ts";
37
+ tag.dataset.pluginCss = "bash-terminal-row";
38
+ tag.textContent = ROW_CSS;
39
+ document.head.appendChild(tag);
40
+ }
41
+ var zh = {
42
+ "shell.title": "\u9ED8\u8BA4\u7EC8\u7AEF",
43
+ "shell.description": "shell \u5DE5\u5177\u6267\u884C\u547D\u4EE4\u65F6\u4F7F\u7528\u7684\u7EC8\u7AEF",
44
+ "shell.powershell": "PowerShell",
45
+ "shell.gitbash": "Git Bash",
46
+ "shell.msys2": "MSYS2",
47
+ "shell.wsl": "WSL"
48
+ };
49
+ var en = {
50
+ "shell.title": "Default terminal",
51
+ "shell.description": "Terminal used by the shell tool",
52
+ "shell.powershell": "PowerShell",
53
+ "shell.gitbash": "Git Bash",
54
+ "shell.msys2": "MSYS2",
55
+ "shell.wsl": "WSL"
56
+ };
57
+ var inject = ["slots", "locale", "settingsScope"];
58
+ function ShellPreferenceRow({ t, useStore, setShell }) {
59
+ const shell = useStore((s) => s.shell);
60
+ const writable = useStore((s) => s.writable);
61
+ const [open, setOpen] = (0, import_react.useState)(false);
62
+ const items = SHELLS.map((id) => ({ id, label: t("shell." + id) }));
63
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "btRow", children: [
64
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "btRowText", children: [
65
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "btTitle", children: t("shell.title") }),
66
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "btDesc", children: t("shell.description") })
67
+ ] }),
68
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
69
+ import_dsh_client_ui_primitives.Menu,
70
+ {
71
+ open,
72
+ onClose: () => setOpen(false),
73
+ items,
74
+ selectedId: shell,
75
+ onSelect: (id) => {
76
+ setOpen(false);
77
+ setShell(id);
78
+ },
79
+ align: "end",
80
+ portal: true,
81
+ anchor: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
82
+ "button",
83
+ {
84
+ type: "button",
85
+ className: "btSelector",
86
+ "aria-haspopup": "menu",
87
+ "aria-expanded": open,
88
+ disabled: !writable,
89
+ onClick: () => setOpen(!open),
90
+ style: !writable ? { opacity: 0.5, cursor: "not-allowed" } : void 0,
91
+ children: [
92
+ t("shell." + shell),
93
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconChevronDownOutline14, { className: "btChevron" })
94
+ ]
95
+ }
96
+ )
97
+ }
98
+ )
99
+ ] });
100
+ }
101
+ function apply(ctx) {
102
+ ctx.effect(() => ctx.locale.register(SETTINGS_NS, { zh, en }), "bash-terminal: settings dictionaries");
103
+ const scope = ctx.settingsScope.bind({ namespace: SETTINGS_NAMESPACE });
104
+ const store = (0, import_dsh_client_store.defineStore)({
105
+ init: () => ({ shell: "powershell", revision: -1, writable: false }),
106
+ actions: {
107
+ sync: (d, shell, revision, writable) => {
108
+ if (revision !== void 0 && revision <= d.revision) return;
109
+ if (shell !== void 0) d.shell = shell;
110
+ if (revision !== void 0) d.revision = revision;
111
+ if (writable !== void 0) d.writable = writable;
112
+ }
113
+ }
114
+ });
115
+ let bound;
116
+ const push = (snap) => {
117
+ bound?.sync(snap.value?.defaultShell, snap.revision, snap.writable);
118
+ };
119
+ ctx.slots.inject(
120
+ "settings.general.item",
121
+ () => ctx.slots.register(
122
+ {
123
+ name: "settings.general.item",
124
+ id: "bash-terminal-shell",
125
+ order: 20,
126
+ store,
127
+ locale: SETTINGS_NS,
128
+ inject: (actions) => {
129
+ bound = actions;
130
+ push(scope.getSnapshot());
131
+ return { setShell: (value) => void scope.set("defaultShell", value) };
132
+ }
133
+ },
134
+ ShellPreferenceRow
135
+ ),
136
+ "bash-terminal: settings row"
137
+ );
138
+ ctx.effect(() => scope.subscribe(() => push(scope.getSnapshot())), "bash-terminal: settings watch");
139
+ }