dsh-plugin-workbench 0.0.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/CHANGELOG.md +22 -0
- package/LICENSE +21 -0
- package/README.md +219 -0
- package/cordis.patch.yml +11 -0
- package/lib/client.js +8629 -0
- package/lib/client.js.map +1 -0
- package/lib/index.js +179 -0
- package/package.json +71 -0
- package/scripts/patch-layout.mjs +323 -0
- package/src/client/FileExplorer.tsx +374 -0
- package/src/client/FilePreview.tsx +353 -0
- package/src/client/css-modules.d.ts +8 -0
- package/src/client/files.module.css +536 -0
- package/src/client/highlight.ts +88 -0
- package/src/client/index.ts +45 -0
- package/src/client/locales.ts +39 -0
- package/src/client/store.ts +151 -0
- package/src/dsh.d.ts +62 -0
- package/src/index.ts +203 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
本项目所有重要变更都会记录在此文件。
|
|
4
|
+
格式基于 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/),
|
|
5
|
+
版本号遵循 [Semantic Versioning](https://semver.org/lang/zh-CN/)。
|
|
6
|
+
|
|
7
|
+
## [0.0.1] - 2026-08-14
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- 初始版本发布(https://github.com/Pasumao/dsh-plugin-workbench):
|
|
12
|
+
- VS Code 风格文件树列:跟随会话工作区、懒加载展开、每 2 秒自动刷新
|
|
13
|
+
- 可编辑分栏预览:语法高亮层 + 透明 textarea、`Ctrl+S`/`Cmd+S` 保存、
|
|
14
|
+
脏标记圆点、保存失败提示
|
|
15
|
+
- 标签页:多文件同时打开、点选/拖拽排序/逐个关闭、收起/弹出
|
|
16
|
+
- 明暗主题:VS Code 亮色/暗色配色一键切换(独立于 app 皮肤)
|
|
17
|
+
- 按工作区隔离:每个 cwd 各自保存标签、激活文件、收起与展开状态
|
|
18
|
+
- 内置 highlight.js:JS/TS、Python、JSON、HTML/XML、CSS、Markdown、Shell、
|
|
19
|
+
Java、C/C++、C#、Go、Rust、SQL、YAML、INI
|
|
20
|
+
- 布局补丁脚本 `scripts/patch-layout.mjs`:4 列布局 + explorer 槽位 +
|
|
21
|
+
中心分栏(幂等、可回滚、锚点校验)
|
|
22
|
+
- MIT 许可
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Pasumao
|
|
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.md
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
# dsh-plugin-workbench
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
DSH Web GUI 的 VS Code 风格工作区文件浏览器插件:在 sidebar 与聊天区之间新增
|
|
10
|
+
**文件树列**,点文件在中间区左侧打开**可编辑的代码预览**(语法高亮 + 标签页),
|
|
11
|
+
文件树自动刷新,每个工作区各自保存自己的标签与展开状态。
|
|
12
|
+
|
|
13
|
+
> 需要两条改动线同时存在:本插件仓库 + 对 `dsh-client-ui-layout` 编译产物的布局补丁。
|
|
14
|
+
|
|
15
|
+
## 功能特性
|
|
16
|
+
|
|
17
|
+
- **文件树**:跟随当前会话工作区(`SessionSummary.cwd`),目录在前、按名称排序、
|
|
18
|
+
懒加载展开;每 2 秒自动刷新可见目录,磁盘变化无需手动刷新。
|
|
19
|
+
- **分栏预览**:点文件在中间区左侧打开(默认 55% 宽),聊天区压缩到右侧;
|
|
20
|
+
分隔条可拖拽调宽;打开/关闭带淡入淡出动画。
|
|
21
|
+
- **直接编辑**:预览即编辑器(透明 textarea 叠加语法高亮层),打开即可打字;
|
|
22
|
+
`Ctrl+S` / `Cmd+S` 保存写回磁盘,未保存的标签显示脏标记圆点。
|
|
23
|
+
- **标签页**:可同时打开多个文件,标签可点选、可拖拽排序、可逐个关闭。
|
|
24
|
+
- **收起/弹出**:标签栏最右侧 `<` 收起(暂存,标签与内容保留);文件列头部 `>`
|
|
25
|
+
原样弹出。
|
|
26
|
+
- **明暗主题**:文件列头部 ☀/🌙 一键切换 VS Code 亮色/暗色配色(独立于 app 皮肤)。
|
|
27
|
+
- **按工作区隔离**:每个工作区(cwd)各存一份标签、激活文件、收起状态、展开目录;
|
|
28
|
+
切换工作区互不干扰,切回后原样恢复。
|
|
29
|
+
- **语法高亮**:内置 highlight.js,覆盖 JS/TS、Python、JSON、HTML/XML、CSS、Markdown、
|
|
30
|
+
Shell、Java、C/C++、C#、Go、Rust、SQL、YAML、INI(按扩展名自动识别)。
|
|
31
|
+
|
|
32
|
+
## 架构
|
|
33
|
+
|
|
34
|
+
一个包同时承载 host 半部(cordis 插件)与 client 半部(浏览器 bundle),外加一处
|
|
35
|
+
对 DSH 核心布局编译产物的补丁。
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
浏览器 host (Node)
|
|
39
|
+
┌────────────────────────────────────────────┐ ┌──────────────────────┐
|
|
40
|
+
│ AppFrame (4 列: sidebar|explorer|center|details) │ │ ctx.fs (沙箱文件系统) │
|
|
41
|
+
│ ├ explorer 槽位 → FileExplorer(文件树) │ RPC │ /dsh-plugin-files │
|
|
42
|
+
│ ├ explorer.preview 槽位 → FilePreview(编辑)│◄─────►│ ├ list 目录列举 │
|
|
43
|
+
│ └ 会话区 = conversation 槽位(聊天) │ │ ├ read 文件读取 │
|
|
44
|
+
└────────────────────────────────────────────┘ │ └ write 文件写回 │
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
- **host 半部**(`src/index.ts`):`apply(ctx)` 注册 loopback 专属 RPC 通道
|
|
48
|
+
`/dsh-plugin-files`,端点 `list`/`read`/`write` 全部基于 `ctx.fs`
|
|
49
|
+
(`resolve/stat/listDir/readText/writeText/processPath`)。读操作任何沙箱模式均放行;
|
|
50
|
+
`write` 显式以 `danger-full-access` 策略写回(等价 `/api` 写工具的权限模型)。
|
|
51
|
+
- **client 半部**(`src/client/*`):`apply(ctx)` 注册 `files` locale 命名空间,
|
|
52
|
+
并把 `FileExplorer` / `FilePreview` 分别注入 `explorer` / `explorer.preview` 槽位;
|
|
53
|
+
数据读写经 `ctx.connection.rpc.call` 走 host 端点,`ctx.workspaces.openPath` 打开系统。
|
|
54
|
+
`store.ts` 是共享状态:标签、激活文件、收起状态按 cwd 分桶(`workspaces[cwd]`)。
|
|
55
|
+
- **布局补丁**(`scripts/patch-layout.mjs`):DSH 自带的 `dsh-client-ui-layout` 只有
|
|
56
|
+
`sidebar | center | details` 三列。脚本对已安装包编译产物 `lib/client.js` 做精确
|
|
57
|
+
字符串替换,新增:`explorer` 列 + 拖拽手柄 + layout store 的 `explorer` 面板,
|
|
58
|
+
以及中心列分栏(`conversation` + `explorer.preview` 并排)。
|
|
59
|
+
|
|
60
|
+
## 文件结构
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
dsh-plugin-workbench/
|
|
64
|
+
├─ package.json # 包定义(main→host / exports["./client"]→client / dsh.bundle)
|
|
65
|
+
├─ cordis.patch.yml # bundle 补丁层:loader 条目(boot 自动应用)
|
|
66
|
+
├─ tsdown.config.ts # clientBundle 双面打包配置
|
|
67
|
+
├─ tsconfig.json # typecheck 配置(strict)
|
|
68
|
+
├─ README.md # 本文档
|
|
69
|
+
├─ CONTRIBUTING.md # 贡献指南
|
|
70
|
+
├─ CODE_OF_CONDUCT.md # 行为准则
|
|
71
|
+
├─ SECURITY.md # 安全政策
|
|
72
|
+
├─ CHANGELOG.md # 变更日志
|
|
73
|
+
├─ .github/
|
|
74
|
+
│ ├─ workflows/ci.yml # CI:pnpm install + typecheck + build(Node 20/22)
|
|
75
|
+
│ └─ ISSUE_TEMPLATE/ # Bug 报告 / 功能建议模板
|
|
76
|
+
├─ build/
|
|
77
|
+
│ ├─ tsdown.client.ts # 复用的 tsdown 预设(CSS Modules 内联 / banner / 纯净门)
|
|
78
|
+
│ └─ web-platform.ts # 平台模块表(外置 externals 清单)
|
|
79
|
+
├─ scripts/
|
|
80
|
+
│ └─ patch-layout.mjs # 布局补丁:4 列 + explorer 槽位 + 中心分栏(幂等、可回滚)
|
|
81
|
+
├─ patches/
|
|
82
|
+
│ └─ layout.backup/ # 布局 bundle 原版备份(脚本自动生成,不入库)
|
|
83
|
+
├─ src/
|
|
84
|
+
│ ├─ index.ts # host:/dsh-plugin-files RPC(list/read/write)
|
|
85
|
+
│ ├─ dsh.d.ts # 本地最小 Context 类型声明(DX only)
|
|
86
|
+
│ └─ client/
|
|
87
|
+
│ ├─ index.ts # client 入口:locale + 两个槽位注册
|
|
88
|
+
│ ├─ FileExplorer.tsx # 文件树列(懒加载 / 自动刷新 / 每工作区展开状态)
|
|
89
|
+
│ ├─ FilePreview.tsx # 分栏预览(标签 / 可编辑 / 语法高亮 / 收起弹出)
|
|
90
|
+
│ ├─ highlight.ts # highlight.js 语言集 + 扩展名识别
|
|
91
|
+
│ ├─ store.ts # 每工作区一份的标签/激活/收起状态
|
|
92
|
+
│ ├─ locales.ts # zh/en 文案
|
|
93
|
+
│ ├─ css-modules.d.ts # CSS Modules 类型声明(typecheck 用)
|
|
94
|
+
│ └─ files.module.css # VS Code 亮暗配色 + 编辑器 + 标签栏样式
|
|
95
|
+
└─ lib/ # 构建产物(不入库,`pnpm run build` 生成)
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## 前置要求
|
|
99
|
+
|
|
100
|
+
- 本地可运行的 DSH web(插件 RPC 通道仅限 loopback)
|
|
101
|
+
- Node.js ≥ 18 与 pnpm
|
|
102
|
+
- 本文档以 Windows 为例;macOS/Linux 路径同理(`~/.dsh`)
|
|
103
|
+
|
|
104
|
+
## 构建
|
|
105
|
+
|
|
106
|
+
```powershell
|
|
107
|
+
pnpm install
|
|
108
|
+
pnpm run build # 产出 lib/index.js(host)与 lib/client.js(browser)
|
|
109
|
+
pnpm run watch # 开发热更
|
|
110
|
+
pnpm run typecheck # 可选(tsdown 本身不做类型检查)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## 安装与启用
|
|
114
|
+
|
|
115
|
+
> **兼容性**:布局补丁针对 `dsh-client-ui-layout@0.1.0-rc.6` 的编译产物编写;
|
|
116
|
+
> 其他 DSH 版本需先按新产物更新 `scripts/patch-layout.mjs` 里的锚点。
|
|
117
|
+
|
|
118
|
+
本包是一个标准 DSH bundle(`package.json` 声明 `dsh.bundle`,自带
|
|
119
|
+
`cordis.patch.yml` 补丁层),推荐用 `dsh plugin` 命令安装:
|
|
120
|
+
|
|
121
|
+
**方式 A:从 npm 安装(官方推荐)**
|
|
122
|
+
|
|
123
|
+
```powershell
|
|
124
|
+
dsh plugin --profile web add dsh-plugin-workbench
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**方式 B:从 GitHub 安装**
|
|
128
|
+
|
|
129
|
+
```powershell
|
|
130
|
+
dsh plugin --profile web add github:Pasumao/dsh-plugin-workbench
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
> git 安装会在安装时通过 `prepare` 脚本构建;pnpm 默认拦截构建脚本,
|
|
134
|
+
> 按提示把包名加入 profile 的 `pnpm-workspace.yaml` 的 `allowBuilds` 后重跑。
|
|
135
|
+
|
|
136
|
+
**方式 C:本地路径(开发调试)**
|
|
137
|
+
|
|
138
|
+
```powershell
|
|
139
|
+
dsh plugin --profile web add C:/path/to/dsh-plugin-workbench
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**手动安装(不用 `dsh plugin` 命令时)**
|
|
143
|
+
|
|
144
|
+
1. 在 `<DSH_HOME>/profiles/web/package.json` 的 dependencies 加入
|
|
145
|
+
`"dsh-plugin-workbench": "^0.0.1"`,然后 `cd <DSH_HOME>/profiles/web && pnpm install`
|
|
146
|
+
2. 把本包根目录 `cordis.patch.yml` 的内容追加到 profile 的 `cordis.patch.yml`
|
|
147
|
+
(loader 条目)
|
|
148
|
+
|
|
149
|
+
**以上所有方式装完后,还需要打布局补丁**(bundle 层只注入 loader 条目,
|
|
150
|
+
不会改写布局编译产物):
|
|
151
|
+
|
|
152
|
+
```powershell
|
|
153
|
+
node node_modules/dsh-plugin-workbench/scripts/patch-layout.mjs
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
> pnpm 安装时包体在只读 store 中,备份目录可能无法写入;此时可省略备份
|
|
157
|
+
> (脚本仍会继续),或改用 link 方式安装。
|
|
158
|
+
|
|
159
|
+
最后重启 dsh web。
|
|
160
|
+
|
|
161
|
+
## 验证
|
|
162
|
+
|
|
163
|
+
```powershell
|
|
164
|
+
# 插件 bundle 可访问(200)
|
|
165
|
+
Invoke-WebRequest http://127.0.0.1:3080/plugins/dsh-plugin-workbench/client.js
|
|
166
|
+
# 布局 bundle 已打补丁(含 explorerCol / conversationSeat / renderSlot("explorer.preview"))
|
|
167
|
+
Invoke-WebRequest http://127.0.0.1:3080/plugins/@deepseek-ai/dsh-client-ui-layout/client.js
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
RPC 自测(loopback,`path` 换成你要列出的目录):
|
|
171
|
+
|
|
172
|
+
```powershell
|
|
173
|
+
$body = @{ type='client-request'; rpcId='t'; method='list';
|
|
174
|
+
payload=@{ path='C:\path\to\workspace' } } | ConvertTo-Json -Depth 5
|
|
175
|
+
Invoke-WebRequest http://127.0.0.1:3080/dsh-plugin-files/list -Method POST `
|
|
176
|
+
-ContentType 'application/json' -Body $body -UseBasicParsing
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## 回滚
|
|
180
|
+
|
|
181
|
+
1. `dsh plugin --profile web remove dsh-plugin-workbench`(手动安装时:从 profile
|
|
182
|
+
`package.json` 移除依赖并删除 profile `cordis.patch.yml` 中对应 insert)。
|
|
183
|
+
2. 还原布局 bundle:把 `patches/layout.backup/client.js.orig` 覆盖回
|
|
184
|
+
`@deepseek-ai\dsh-client-ui-layout\lib\client.js`(npx-cache 副本)。
|
|
185
|
+
3. 重启 dsh web。
|
|
186
|
+
|
|
187
|
+
## dsh 升级后
|
|
188
|
+
|
|
189
|
+
`npm`/`npx` 重装 `@deepseek-ai/dsh` 会覆盖布局 bundle,升级后重新执行
|
|
190
|
+
`node scripts/patch-layout.mjs`。若脚本报 "anchor not found",说明编译产物结构
|
|
191
|
+
变了,需按新 bundle 更新 `scripts/patch-layout.mjs` 里的锚点。插件本身是
|
|
192
|
+
bundle 依赖,升级用 `dsh plugin --profile web update dsh-plugin-workbench`
|
|
193
|
+
(本地 link 开发时 `pnpm run build` 重建即可)。
|
|
194
|
+
|
|
195
|
+
## 说明
|
|
196
|
+
|
|
197
|
+
- `/dsh-plugin-files` 通道仅限 loopback(与产品既有安全模型一致)。
|
|
198
|
+
- 文件树自动刷新为 2 秒轮询(与 DSH 自带 HMR 的轮询机制一致),只重列可见目录。
|
|
199
|
+
- 编辑保存为无条件写回;保存失败会在编辑区右下角提示,标签保持脏标记。
|
|
200
|
+
- 明暗主题只作用于文件浏览器(`data-fe-theme`),不影响聊天区与皮肤。
|
|
201
|
+
- 本仓库不包含 DSH 的任何编译产物;`patches/layout.backup/` 由补丁脚本按需生成。
|
|
202
|
+
|
|
203
|
+
## 参与贡献
|
|
204
|
+
|
|
205
|
+
欢迎提交 Issue 与 PR!请先阅读 [CONTRIBUTING](./CONTRIBUTING.md)(开发环境、
|
|
206
|
+
提交检查清单、代码规范)与 [CODE_OF_CONDUCT](./CODE_OF_CONDUCT.md)。
|
|
207
|
+
完整变更记录见 [CHANGELOG](./CHANGELOG.md),安全相关事项见 [SECURITY](./SECURITY.md)。
|
|
208
|
+
|
|
209
|
+
## AI 生成声明
|
|
210
|
+
|
|
211
|
+
本项目的部分内容(包括部分源码、本文档与工程化配置)由 AI 辅助编码工具
|
|
212
|
+
(DeepSeek Harness)生成。所有 AI 生成内容均经过人工审查、类型检查、编译验证
|
|
213
|
+
与实机测试;涉及权限与文件系统的逻辑(`src/index.ts` 的 RPC 端点、
|
|
214
|
+
`scripts/patch-layout.mjs`)已按最小权限原则人工复核。项目以 MIT 许可开源,
|
|
215
|
+
欢迎任何人审计、修改与分发。
|
|
216
|
+
|
|
217
|
+
## License
|
|
218
|
+
|
|
219
|
+
[MIT](./LICENSE)
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# dsh-plugin-workbench — profile patch layer
|
|
2
|
+
#
|
|
3
|
+
# Applied automatically at boot when this package is registered as a bundle
|
|
4
|
+
# (dsh.profile.bundles, i.e. installed via `dsh plugin add`), or append this
|
|
5
|
+
# block to the profile's own cordis.patch.yml when installing manually.
|
|
6
|
+
#
|
|
7
|
+
# NOTE: the layout patch (scripts/patch-layout.mjs) is NOT part of this layer;
|
|
8
|
+
# it must still be run once against the installed dsh-client-ui-layout bundle.
|
|
9
|
+
- insert:
|
|
10
|
+
- id: dsh-workbench
|
|
11
|
+
name: dsh-plugin-workbench
|