dsh-plugin-workbench 0.0.1 → 0.0.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.
Files changed (2) hide show
  1. package/README.md +27 -176
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -6,213 +6,64 @@
6
6
  ![Stars](https://img.shields.io/github/stars/Pasumao/dsh-plugin-workbench?style=social)
7
7
  ![AI Assisted](https://img.shields.io/badge/AI-Assisted-8A2BE2)
8
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 核心布局编译产物的补丁。
9
+ DSH Web GUI 的 VS Code 风格文件浏览器插件:文件树 + 可编辑代码预览
10
+ (语法高亮、标签页),每个工作区独立保存状态。**需要布局补丁**(见下)。
36
11
 
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`)
12
+ ## 功能
103
13
 
104
- ## 构建
14
+ - 文件树:懒加载、2 秒自动刷新、每工作区独立展开状态
15
+ - 可编辑预览:透明 textarea 叠加语法高亮,`Ctrl+S`/`Cmd+S` 保存
16
+ - 标签页:多文件、拖拽排序、收起/弹出;亮暗主题一键切换
17
+ - 语法高亮:highlight.js(JS/TS、Python、JSON、HTML、CSS、Markdown、Shell 等)
105
18
 
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
- ## 安装与启用
19
+ ## 安装
114
20
 
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 安装(官方推荐)**
21
+ > 布局补丁针对 `dsh-client-ui-layout@0.1.0-rc.6` 编写,其他版本需更新锚点。
122
22
 
123
23
  ```powershell
24
+ # npm(推荐)
124
25
  dsh plugin --profile web add dsh-plugin-workbench
125
- ```
126
-
127
- **方式 B:从 GitHub 安装**
128
-
129
- ```powershell
26
+ # 或 GitHub
130
27
  dsh plugin --profile web add github:Pasumao/dsh-plugin-workbench
131
28
  ```
132
29
 
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
- 不会改写布局编译产物):
30
+ 安装后打布局补丁并重启:
151
31
 
152
32
  ```powershell
153
33
  node node_modules/dsh-plugin-workbench/scripts/patch-layout.mjs
34
+ # 重启 dsh web
154
35
  ```
155
36
 
156
- > pnpm 安装时包体在只读 store 中,备份目录可能无法写入;此时可省略备份
157
- > (脚本仍会继续),或改用 link 方式安装。
158
-
159
- 最后重启 dsh web。
160
-
161
- ## 验证
37
+ ## 开发
162
38
 
163
39
  ```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
40
+ pnpm install
41
+ pnpm run build # 产出 lib/index.js(host)与 lib/client.js(browser)
42
+ pnpm run typecheck
168
43
  ```
169
44
 
170
- RPC 自测(loopback,`path` 换成你要列出的目录):
45
+ ## 卸载
171
46
 
172
47
  ```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
48
+ dsh plugin --profile web remove dsh-plugin-workbench
49
+ # 并还原布局 bundle(patches/layout.backup/client.js.orig dsh-client-ui-layout/lib/client.js)
177
50
  ```
178
51
 
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
52
  ## 说明
196
53
 
197
- - `/dsh-plugin-files` 通道仅限 loopback(与产品既有安全模型一致)。
198
- - 文件树自动刷新为 2 秒轮询(与 DSH 自带 HMR 的轮询机制一致),只重列可见目录。
199
- - 编辑保存为无条件写回;保存失败会在编辑区右下角提示,标签保持脏标记。
200
- - 明暗主题只作用于文件浏览器(`data-fe-theme`),不影响聊天区与皮肤。
201
- - 本仓库不包含 DSH 的任何编译产物;`patches/layout.backup/` 由补丁脚本按需生成。
54
+ - `/dsh-plugin-files` RPC 通道仅限 loopback;写操作显式以 `danger-full-access` 执行
55
+ - DSH 升级会覆盖布局 bundle,需重新运行补丁脚本;锚点失效时更新 `scripts/patch-layout.mjs`
56
+ - 本仓库不包含 DSH 编译产物
202
57
 
203
58
  ## 参与贡献
204
59
 
205
- 欢迎提交 IssuePR!请先阅读 [CONTRIBUTING](./CONTRIBUTING.md)(开发环境、
206
- 提交检查清单、代码规范)与 [CODE_OF_CONDUCT](./CODE_OF_CONDUCT.md)。
207
- 完整变更记录见 [CHANGELOG](./CHANGELOG.md),安全相关事项见 [SECURITY](./SECURITY.md)。
60
+ [CONTRIBUTING](./CONTRIBUTING.md) 与 [CODE_OF_CONDUCT](./CODE_OF_CONDUCT.md)
61
+ 变更记录见 [CHANGELOG](./CHANGELOG.md)。
208
62
 
209
63
  ## AI 生成声明
210
64
 
211
- 本项目的部分内容(包括部分源码、本文档与工程化配置)由 AI 辅助编码工具
212
- (DeepSeek Harness)生成。所有 AI 生成内容均经过人工审查、类型检查、编译验证
213
- 与实机测试;涉及权限与文件系统的逻辑(`src/index.ts` 的 RPC 端点、
214
- `scripts/patch-layout.mjs`)已按最小权限原则人工复核。项目以 MIT 许可开源,
215
- 欢迎任何人审计、修改与分发。
65
+ 部分源码与文档由 AI 辅助生成(DeepSeek Harness),均经人工审查与实机验证;
66
+ 权限相关逻辑已按最小权限原则复核。
216
67
 
217
68
  ## License
218
69
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-plugin-workbench",
3
3
  "description": "VS Code-style workspace file explorer + editable preview for the dsh web GUI",
4
- "version": "0.0.1",
4
+ "version": "0.0.2",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@11.21.0",
7
7
  "engines": {