@fonlan/dsh-quick-commands 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/LICENSE +21 -0
- package/README.en.md +149 -0
- package/README.md +108 -0
- package/cordis.patch.yml +3 -0
- package/lib/client.js +1036 -0
- package/lib/client.js.map +1 -0
- package/lib/index.js +904 -0
- package/lib/types/index.d.ts +19 -0
- package/lib/types/server/remote.d.ts +117 -0
- package/lib/types/server/rpc.d.ts +4 -0
- package/lib/types/server/runner.d.ts +114 -0
- package/lib/types/server/settings.d.ts +24 -0
- package/lib/types/shared/contract.d.ts +87 -0
- package/package.json +108 -0
- package/src/client/api.ts +76 -0
- package/src/client/header.tsx +534 -0
- package/src/client/index.tsx +50 -0
- package/src/client/locales.ts +106 -0
- package/src/client/quick-commands.css +580 -0
- package/src/client/run-state.ts +125 -0
- package/src/client/settings-card.tsx +209 -0
- package/src/client/slot-augment.d.ts +14 -0
- package/src/index.ts +61 -0
- package/src/server/remote.ts +304 -0
- package/src/server/rpc.ts +286 -0
- package/src/server/runner.ts +471 -0
- package/src/server/settings.ts +106 -0
- package/src/shared/contract.ts +92 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 fonlan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.en.md
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# dsh-quick-commands
|
|
2
|
+
|
|
3
|
+
**[中文](./README.md) | [English](./README.en.md)**
|
|
4
|
+
|
|
5
|
+
DSH web plugin: per-workspace quick commands. Configure named shell commands per DSH
|
|
6
|
+
workspace; run one from the session header (the ▶ quick-run icon left of the Session log pill)
|
|
7
|
+
and watch its stdout/stderr live in a floating popup.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
Requires DSH (DeepSeek Harness) to be installed. The commands below forward to pnpm
|
|
12
|
+
inside the target profile directory via `dsh plugin`; the target profile is initialized
|
|
13
|
+
automatically on first use, and once installed, the plugin (which declares `dsh.bundle`)
|
|
14
|
+
is added to the profile's bundles layer automatically — restart DSH (`dsh web`) to pick
|
|
15
|
+
it up.
|
|
16
|
+
|
|
17
|
+
### Install from npm
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
dsh plugin --profile web add @fonlan/dsh-quick-commands
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Install from GitHub
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
dsh plugin --profile web add github:fonlan/dsh-quick-commands
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Pin a branch / tag if needed:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
dsh plugin --profile web add github:fonlan/dsh-quick-commands#main
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
> Git-hosted plugins build on install via their `prepare` script. If pnpm blocks
|
|
36
|
+
> that build, add the exact key pnpm printed to `allowBuilds` in
|
|
37
|
+
> `<profile>/pnpm-workspace.yaml`, then re-run the command above.
|
|
38
|
+
|
|
39
|
+
### Uninstall
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
dsh plugin --profile web remove @fonlan/dsh-quick-commands
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The package is removed from the profile's dependencies and bundles layer; restart DSH
|
|
46
|
+
to take effect.
|
|
47
|
+
|
|
48
|
+
## Features
|
|
49
|
+
|
|
50
|
+
- **Settings card** (设置 → 插件配置 → Quick commands): lists every DSH workspace;
|
|
51
|
+
per workspace, add/rename/remove commands (name + command text fields), instant
|
|
52
|
+
save per edit.
|
|
53
|
+
- **Header button** (session header, left of Session log): lists the current
|
|
54
|
+
workspace's commands (session cwd matched to a workspace path, subdirectories
|
|
55
|
+
included). Click a command → run it in the workspace directory.
|
|
56
|
+
- **Live output popup**: streams stdout/stderr at ~200 ms cadence, split tabs,
|
|
57
|
+
raw text, auto-follow with manual-scroll pause; tree-scoped termination on
|
|
58
|
+
kill/close; serial per workspace (one run at a time per workspace). Drag the
|
|
59
|
+
left border (width) and the top/bottom border (height), or the free-corner
|
|
60
|
+
grip, to resize; the size is remembered across runs and sessions (persisted
|
|
61
|
+
in the plugin settings).
|
|
62
|
+
- **Remote (SSH) workspaces**: when the workspace is a `@dsh-ssh/dsh-ssh`
|
|
63
|
+
remote workspace (its path is the local placeholder under
|
|
64
|
+
`~/.dsh/remote/<hostId>/...`), quick commands stream over SSH on the remote
|
|
65
|
+
host instead of the local machine. The command menu and the run popup show a
|
|
66
|
+
blue **SSH** badge; the connection fails fast (with a readable error) when
|
|
67
|
+
the SSH host is not configured in `dsh-ssh-hosts`. Local workspaces are
|
|
68
|
+
untouched — they keep the exact pre-existing subprocess behaviour.
|
|
69
|
+
|
|
70
|
+
## Configuration
|
|
71
|
+
|
|
72
|
+
The plugin settings namespace is `quick-commands`:
|
|
73
|
+
|
|
74
|
+
```jsonc
|
|
75
|
+
{
|
|
76
|
+
"workspaces": [
|
|
77
|
+
{ "workspaceId": "<dsh workspace id>", "commands": [
|
|
78
|
+
{ "name": "lint", "command": "npm run lint" },
|
|
79
|
+
{ "name": "test", "command": "npm test" }
|
|
80
|
+
]}
|
|
81
|
+
],
|
|
82
|
+
"popupAnchor": "corner", // or "button"
|
|
83
|
+
"popupSize": { "width": 520, "height": 340 } // optional, written when the user drags the popup's resize grip
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Placeholders
|
|
88
|
+
|
|
89
|
+
| Placeholder | Value |
|
|
90
|
+
| --- | --- |
|
|
91
|
+
| `{workspace}` | workspace root path (also the execution cwd) |
|
|
92
|
+
| `{cwd}` | the session's actual cwd (may be a subdirectory) |
|
|
93
|
+
| `{title}` | workspace display title |
|
|
94
|
+
|
|
95
|
+
On a remote workspace the placeholders resolve to *remote* paths: `{workspace}`
|
|
96
|
+
and `{cwd}` are the remote absolute paths (the session cwd is re-anchored onto
|
|
97
|
+
the remote filesystem when it sits inside the placeholder workspace), so
|
|
98
|
+
`echo {cwd}` prints the remote directory.
|
|
99
|
+
|
|
100
|
+
### Environment
|
|
101
|
+
|
|
102
|
+
Local commands inherit the harness process environment plus:
|
|
103
|
+
`DSH_WORKSPACE`, `DSH_WORKSPACE_ID`, `DSH_WORKSPACE_TITLE`.
|
|
104
|
+
Remote commands run on the SSH host with that host's own shell environment (the
|
|
105
|
+
`DSH_*` variables are not injected remotely).
|
|
106
|
+
|
|
107
|
+
### Remote execution details
|
|
108
|
+
|
|
109
|
+
- Requires the `@dsh-ssh/dsh-ssh` host plugin to be loaded (it provides the
|
|
110
|
+
`sshPool` service and the `dsh-ssh-hosts` settings namespace); when absent,
|
|
111
|
+
a quick command on a remote placeholder workspace is refused with an explicit
|
|
112
|
+
error instead of silently running locally.
|
|
113
|
+
- Output streams live over the SSH channel (same tail/offset polling, popup
|
|
114
|
+
unchanged). Kill terminates the remote **process group** (`kill -TERM -- -<pgid>`
|
|
115
|
+
plus a pkill fallback), so children like `sleep`/builders are covered.
|
|
116
|
+
- A marker line is prefixed to the remote command to probe the group-leader
|
|
117
|
+
pid; it is filtered out of the stderr the popup shows.
|
|
118
|
+
- Remote execution shells: Linux/macOS hosts (bash-compatible), the platform
|
|
119
|
+
of the *remote* host, not the local one.
|
|
120
|
+
|
|
121
|
+
## Security model
|
|
122
|
+
|
|
123
|
+
Commands are user-configured and user-clicked; no model requests, no approval
|
|
124
|
+
prompts, no sandbox confinement. They execute with the harness process's own
|
|
125
|
+
env/PATH on the host machine under the workspace directory. Configure only
|
|
126
|
+
commands you trust. Remote commands execute with the remote user's privileges
|
|
127
|
+
over SSH; the same trust applies, plus anything the remote host exposes.
|
|
128
|
+
|
|
129
|
+
## Platform
|
|
130
|
+
|
|
131
|
+
- Local macOS / Linux: `bash -c`
|
|
132
|
+
- Local Windows: `pwsh -c` (autodetect via `process.platform`)
|
|
133
|
+
- Remote workspaces: the remote host's shell (Linux/macOS, as supported by
|
|
134
|
+
`@dsh-ssh/dsh-ssh`)
|
|
135
|
+
|
|
136
|
+
## Development
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
pnpm install
|
|
140
|
+
npm run build # host tsc + client tsdown
|
|
141
|
+
node --experimental-strip-types --test test/remote.test.ts # remote unit tests
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
For the super-injector pipeline: `dev_build_plugin` / `dev_inject_plugin` from the
|
|
145
|
+
DSH web profile.
|
|
146
|
+
|
|
147
|
+
## License
|
|
148
|
+
|
|
149
|
+
MIT
|
package/README.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# dsh-quick-commands
|
|
2
|
+
|
|
3
|
+
**[中文](./README.md) | [English](./README.en.md)**
|
|
4
|
+
|
|
5
|
+
DSH Web 插件:按工作区(workspace)管理快捷命令。为每个 DSH 工作区配置命名 shell 命令,从会话头部(Session log 左侧的 ▶ 快捷运行图标)点击即可运行,stdout/stderr 在浮动弹窗中实时显示。
|
|
6
|
+
|
|
7
|
+
## 安装
|
|
8
|
+
|
|
9
|
+
需要已安装 DSH(DeepSeek Harness)。以下命令通过 `dsh plugin` 在目标 profile 目录中转发给 pnpm 执行;目标 profile 首次使用时会自动初始化,安装完成后插件(声明了 `dsh.bundle`)会自动加入该 profile 的 bundles 层,重启 DSH(`dsh web`)后生效。
|
|
10
|
+
|
|
11
|
+
### 从 npm 安装
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
dsh plugin --profile web add @fonlan/dsh-quick-commands
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### 从 GitHub 安装
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
dsh plugin --profile web add github:fonlan/dsh-quick-commands
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
也可以固定到分支 / tag:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
dsh plugin --profile web add github:fonlan/dsh-quick-commands#main
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
> 以 git 方式安装的插件会在安装时通过 `prepare` 脚本构建;如 pnpm 阻止了该构建,请按 pnpm 输出的提示,在 `<profile>/pnpm-workspace.yaml` 的 `allowBuilds` 中加入对应的 key,然后重新执行上述命令。
|
|
30
|
+
|
|
31
|
+
### 卸载
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
dsh plugin --profile web remove @fonlan/dsh-quick-commands
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
卸载后该包会从 profile 的依赖与 bundles 层中移除,重启 DSH 后生效。
|
|
38
|
+
|
|
39
|
+
## 功能特性
|
|
40
|
+
|
|
41
|
+
- **设置卡片**(设置 → 插件配置 → Quick commands):列出所有 DSH 工作区;在每个工作区下可新增 / 重命名 / 删除命令(名称 + 命令文本字段),每次编辑即时保存。
|
|
42
|
+
- **头部按钮**(会话头部,Session log 左侧):列出当前工作区的命令(会话 cwd 匹配到工作区路径,包含子目录)。点击命令 → 在工作区目录中运行。
|
|
43
|
+
- **实时输出弹窗**:以约 200ms 的频率流式输出 stdout/stderr,分页签显示,纯文本,自动跟随滚动(手动滚动时暂停);关闭 / 杀进程时按树形作用域终止;每个工作区串行执行(同一工作区同时只运行一个命令)。拖动左边框(宽度)和上 / 下边框(高度),或自由角手柄,即可调整大小;尺寸在多次运行与会话之间保持(持久化在插件设置中)。
|
|
44
|
+
- **远程(SSH)工作区**:当工作区是 `@dsh-ssh/dsh-ssh` 远程工作区(其路径为 `~/.dsh/remote/<hostId>/...` 下的本地占位符)时,快捷命令将流式传输到远程主机执行,而不是本地执行。命令菜单和运行弹窗会显示蓝色 **SSH** 徽标;当 SSH 主机未在 `dsh-ssh-hosts` 中配置时,连接会快速失败(附带可读的错误信息)。本地工作区不受影响——它们保持与之前完全一致的子进程行为。
|
|
45
|
+
|
|
46
|
+
## 配置
|
|
47
|
+
|
|
48
|
+
插件设置命名空间为 `quick-commands`:
|
|
49
|
+
|
|
50
|
+
```jsonc
|
|
51
|
+
{
|
|
52
|
+
"workspaces": [
|
|
53
|
+
{ "workspaceId": "<dsh workspace id>", "commands": [
|
|
54
|
+
{ "name": "lint", "command": "npm run lint" },
|
|
55
|
+
{ "name": "test", "command": "npm test" }
|
|
56
|
+
]}
|
|
57
|
+
],
|
|
58
|
+
"popupAnchor": "corner", // 或 "button"
|
|
59
|
+
"popupSize": { "width": 520, "height": 340 } // 可选,用户拖动弹窗调整手柄时写入
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### 占位符
|
|
64
|
+
|
|
65
|
+
| 占位符 | 值 |
|
|
66
|
+
| --- | --- |
|
|
67
|
+
| `{workspace}` | 工作区根路径(也是执行时的 cwd) |
|
|
68
|
+
| `{cwd}` | 会话的实际 cwd(可能是子目录) |
|
|
69
|
+
| `{title}` | 工作区显示标题 |
|
|
70
|
+
|
|
71
|
+
在远程工作区上,占位符解析为 *远程* 路径:`{workspace}` 和 `{cwd}` 为远程绝对路径(当会话 cwd 位于占位符工作区内时,会被重新锚定到远程文件系统),因此 `echo {cwd}` 打印的是远程目录。
|
|
72
|
+
|
|
73
|
+
### 环境变量
|
|
74
|
+
|
|
75
|
+
本地命令继承宿主进程环境,并额外设置:
|
|
76
|
+
`DSH_WORKSPACE`、`DSH_WORKSPACE_ID`、`DSH_WORKSPACE_TITLE`。
|
|
77
|
+
远程命令在 SSH 主机上以该主机的自身 shell 环境运行(远程侧不会注入 `DSH_*` 变量)。
|
|
78
|
+
|
|
79
|
+
### 远程执行细节
|
|
80
|
+
|
|
81
|
+
- 需要加载 `@dsh-ssh/dsh-ssh` 宿主插件(它提供 `sshPool` 服务和 `dsh-ssh-hosts` 设置命名空间);缺失时,对远程占位符工作区执行的快捷命令会被明确拒绝并报错,而不是静默地在本地执行。
|
|
82
|
+
- 输出流通过 SSH 通道实时传输(相同的 tail/offset 轮询,弹窗不变)。杀进程会终止远程 **进程组**(`kill -TERM -- -<pgid>` 加 pkill 回退),因此 `sleep` / 构建器等子进程也会被覆盖。
|
|
83
|
+
- 远程命令前会加上一行探针标记以探测组 leader pid;弹窗显示的 stderr 中会过滤掉该行。
|
|
84
|
+
- 远程执行 shell:Linux / macOS 主机(bash 兼容),取决于 *远程* 主机的平台,而非本地主机。
|
|
85
|
+
|
|
86
|
+
## 安全模型
|
|
87
|
+
|
|
88
|
+
命令由用户配置、用户点击执行;不涉及模型请求、无审批提示、无沙箱限制。它们以宿主进程自身的 env/PATH 在主机上、工作区目录下执行。请只配置你信任的命令。远程命令以远程用户权限通过 SSH 执行;同样的信任原则适用,并加上远程主机暴露的一切。
|
|
89
|
+
|
|
90
|
+
## 平台
|
|
91
|
+
|
|
92
|
+
- 本地 macOS / Linux:`bash -c`
|
|
93
|
+
- 本地 Windows:`pwsh -c`(通过 `process.platform` 自动检测)
|
|
94
|
+
- 远程工作区:远程主机的 shell(Linux / macOS,如 `@dsh-ssh/dsh-ssh` 所支持)
|
|
95
|
+
|
|
96
|
+
## 开发
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
pnpm install
|
|
100
|
+
npm run build # 宿主 tsc + 客户端 tsdown
|
|
101
|
+
node --experimental-strip-types --test test/remote.test.ts # 远程单元测试
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
超级注入器流水线:在 DSH web profile 中使用 `dev_build_plugin` / `dev_inject_plugin`。
|
|
105
|
+
|
|
106
|
+
## License
|
|
107
|
+
|
|
108
|
+
MIT
|
package/cordis.patch.yml
ADDED