@dsh-xhl/dsh-file-explorer 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/README.md ADDED
@@ -0,0 +1,77 @@
1
+ # DSH File Explorer(编译型插件)
2
+
3
+ 工作区文件预览 / 编辑插件,参照 [DSH-better-sidebar](https://github.com/omdsh-dev/DSH-better-sidebar) 架构的**编译型外部插件**(tsdown 打包,CodeMirror 6 编辑器),由同目录下的动态 Cordis 插件版本移植而来。
4
+
5
+ ## 功能
6
+
7
+ - **标题栏 ButtonGroup**(`conversation.session.header.utilities`):左侧按钮 + 右侧下拉(编辑器 / 文件夹 / VSCode)
8
+ - **编辑器**(默认):点击打开全屏文件预览 / 编辑弹窗(Ctrl+P 亦可)
9
+ - **文件夹**:点击直接打开会话工作区所在的**系统文件夹**(Windows `explorer` / macOS `open` / Linux `xdg-open`)
10
+ - **VSCode**:点击用 `code` 命令行在 **VS Code** 中打开会话工作区(自动探测安装位置 / PATH)
11
+ - 选择记忆在 localStorage,点击后底部提示确认打开的路径
12
+ - **文件列表**:左侧目录树(跳过 `node_modules`/`.git`/`dist` 等)
13
+ - **按文件名过滤**:输入即过滤
14
+ - **全文搜索**:正则 / 大小写 / 全词匹配、包含/排除过滤,结果按文件分组、命中高亮,点击跳转并高亮匹配
15
+ - **编辑**:CodeMirror 6(20+ 语言语法高亮含 Vue SFC、行号、撤销/重做、Ctrl+S 保存、只读切换、Tab 缩进)
16
+ - **预览**:图片直接显示、PDF 内嵌查看(Markdown / HTML 预览已移除——大文档渲染会卡死界面)
17
+ - **界面**:复用 Web 壳设计系统(`@deepseek-ai/dsh-client-ui-primitives`:Button / Menu / Modal / Input / Toast / Tooltip + `--dsw-*` token),随主题明暗自适应
18
+
19
+ ## 架构
20
+
21
+ ```
22
+ src/
23
+ index.ts Host:/filex/api JSON 路由(session.cwd / fs.list / fs.read / fs.write / fs.search / fs.reveal)
24
+ + /filex/file 媒体路由(图片/PDF 字节),loopback 信任围栏
25
+ trust-fence.ts Host-header loopback 校验(DNS-rebinding 防护)
26
+ client/
27
+ index.tsx 入口:header ButtonGroup(编辑器/文件夹模式)+ overlay 弹窗 + Ctrl+P 快捷键
28
+ Explorer.tsx 弹窗:文件树 / 文件名过滤 / 全文搜索 / 查看器分派(primitives 重排)
29
+ TextEditor.tsx CodeMirror 6 编辑器 + 搜索跳转高亮
30
+ lang.ts 扩展名 → CodeMirror 语言映射
31
+ cm-theme.ts CodeMirror 明暗主题(DSH alias token 驱动)
32
+ api.ts /filex fetch 封装
33
+ style.ts 布局样式(仅弹窗布局/树/搜索行等自有部分)+ 明暗检测
34
+ ```
35
+
36
+ ## 构建
37
+
38
+ ```bash
39
+ pnpm install
40
+ pnpm build # lib/index.js(host)+ lib/client.js(client bundle,CodeMirror 内联)
41
+ ```
42
+
43
+ ## 安装 / 挂载(desktop profile 示例)
44
+
45
+ ```bash
46
+ # 0. 从 npm 安装已发布的包(或见下方本地 link 方式)
47
+ cd ~/.dsh/profiles/desktop
48
+ pnpm add @dsh-xhl/dsh-file-explorer
49
+ # 并手动在 profile 的 dsh.profile.bundles 加: "@dsh-xhl/dsh-file-explorer"
50
+
51
+ # 1. 本地开发:profile 依赖 link 本地包
52
+ cd ~/.dsh/profiles/desktop
53
+ pnpm add @dsh-xhl/dsh-file-explorer@link:C:/xhl/agent-work/dsh-file-editor
54
+ # 或手动在 profile package.json 加:
55
+ # "dependencies": { "@dsh-xhl/dsh-file-explorer": "link:C:/xhl/agent-work/dsh-file-editor" }
56
+ # "dsh": { "profile": { "bundles": [..., "@dsh-xhl/dsh-file-explorer"] } }
57
+
58
+ # 2. 安装依赖
59
+ pnpm install
60
+
61
+ # 3. 验证组合生效(应看到 @dsh-xhl/dsh-file-explorer 行)
62
+ dsh --profile desktop --dump-config
63
+
64
+ # 4. 重启 DSH(host 半必须重启加载)
65
+ ```
66
+
67
+ > 旧版动态插件源码保留在 `plugin/host.js` / `plugin/client.js`(cordis_define 用),
68
+ > 新编译型版本为 `src/`。
69
+
70
+ ## 与动态插件版本的区别
71
+
72
+ | | 动态插件(旧) | 编译型插件(新) |
73
+ |---|---|---|
74
+ | 编辑器 | 自研轻量高亮(透明 textarea + pre 覆盖) | **CodeMirror 6** |
75
+ | 语法高亮 | 自研 tokenizer | 20+ 官方语言包 |
76
+ | 构建 | 无(运行时定义) | tsdown 打包(lib/) |
77
+ | 沙箱 | 动态 Client 沙箱(无 import、定时器受限) | 无沙箱,完整浏览器/Node API |
@@ -0,0 +1,8 @@
1
+ # dsh-file-explorer bundle patch
2
+ #
3
+ # 通过 bundle 通道挂载:
4
+ # dsh plugin --profile <name> add @dsh-xhl/dsh-file-explorer@<version>
5
+ # 或手动把 '@dsh-xhl/dsh-file-explorer' 加进 profile 的 dsh.profile.bundles 并 link 依赖。
6
+ - insert:
7
+ - id: dsh-file-explorer
8
+ name: 'dsh-file-explorer'