DeepSeek Harness 插件

dsh-file-explorer-preview-code

CodeMirror 6 code preview and editor for DSH Web, overriding dsh-file-explorer's plain-text preview with per-language syntax highlighting(英文原文)

跳到安装方式

来源信息

GitHub 仓库
wolfsonliu/dsh-file-explorer-preview-code
最近更新
2026年8月19日
分类
工具与能力
GitHub stars
0
载体类型
plugin
目录证据
上游声明已找到 dsh.bundle
证据路径
package.json#dsh.bundle
核对版本
0.1.0-rc.8
上游核对日期
2026-08-20

该证据由上游目录提供。本站没有安装、运行或安全审核这个插件。

安装

默认先复制一段 Prompt,让 Agent 读 GitHub 仓库和源码;需要自己装时再切到命令。

复制这段 Prompt,发给 DSH、Codex 或其他 Agent,让它先读 GitHub 仓库和源码。

请先不要安装或执行任何命令。阅读这个插件的 GitHub 仓库、README 和关键源码,然后用清楚、直接的方式回答以下问题,帮助我判断它是否适合我的需求:

1. 这个插件是什么,解决什么问题;
2. 适合哪些用户和典型使用场景;
3. 安装后如何使用,并给出一个最小使用示例;
4. 有哪些已知限制,以及隐私、安全、兼容性或维护风险;
5. 给出“推荐 / 有条件推荐 / 不推荐”的明确建议和理由。

请区分仓库明确说明、根据源码推断和未知信息。证据不足时请明确说明,不要猜测或照抄 README。

GitHub:https://github.com/wolfsonliu/dsh-file-explorer-preview-code
插件名:dsh-file-explorer-preview-code
作者:wolfsonliu

检查来源文件

安装前先看这个插件目录里的 README 和其他文件。

文件资源管理器4 个文件
README.zh.md来源说明 · 只读预览
README 语言

dsh-file-explorer-preview-code

English | 中文

DSH Web 的 CodeMirror 6 代码预览与编辑器,基于 codemirrorbasicSetup)+ @codemirror/language-data(按语言高亮)+ @codemirror/theme-one-dark(深色主题)构建。它以优先级 10 覆盖 dsh-file-explorer 内置的纯文本预览(优先级 0),为代码文件提供按语言区分的高亮,以及支持自动保存的就地编辑。

截图

深色主题浅色主题
![深色主题下的代码预览](assets/dsh-file-explorer-preview-code_dark.png)![浅色主题下的代码预览](assets/dsh-file-explorer-preview-code_light.png)

功能

1. 语法高亮:通过 @codemirror/language-data 按文件名解析语言(约 90 种),.ts/.tsx/.js/.jsx/.json/.css/.html/.py/.yaml/.yml/.toml/.sh/.go/.rs/.java/.c/.cpp/.h/.xml/.sql/.ini 等都能得到正确的着色。 2. 就地编辑:预览框是真正的 CodeMirror 编辑器(行号、撤销/重做、软换行),而非只读的 <pre>。 3. 自动保存:停止输入 500ms 后自动保存,Ctrl/Cmd+S 立即保存。 4. 保存状态栏:底部细栏显示语言、Ln/Col 光标位置与保存状态(未保存 / 保存中… / 已保存 / 保存失败),并提供手动保存按钮。 5. 主题感知:高亮实时跟随 DSH 的深色/浅色切换(data-ds-dark-theme)。 6. 可扩展设计:通过 fileExplorer 服务注册,不改动核心文件浏览器。

依赖

本插件依赖 @dsh-external/dsh-file-explorer——它注入 fileExplorer cordis 服务,由该服务提供 registerPreviewwriteFile(保存路径)。请先安装并启用 dsh-file-explorer,再安装本插件:

git clone https://github.com/wolfsonliu/dsh-file-explorer.git
cd dsh-file-explorer
npm install && npm run build
dsh plugin --profile web add .

> @dsh-external/dsh-file-explorer 从 git 仓库安装(github:wolfsonliu/dsh-file-explorer),以便 tsc 解析其 ./client 类型定义。若需针对未发布的本地 checkout 联调,可把该依赖改为指向你自己的路径。

安装

从 git 仓库安装:

git clone https://github.com/wolfsonliu/dsh-file-explorer-preview-code.git
cd dsh-file-explorer-preview-code
npm install && npm run build
dsh plugin --profile web add .
dsh web

工作原理

客户端入口注入 fileExplorerlocale,为每个代码扩展名注册同一个 CodePreview 组件(优先级 10):

export const inject = ['fileExplorer', 'locale']

export function apply(ctx) {
  ctx.effect(() => {
    const readRaw = typeof ctx.fileExplorer.readRawFile === 'function'
      ? ctx.fileExplorer.readRawFile.bind(ctx.fileExplorer)
      : undefined
    const component = makeCodePreview(ctx.fileExplorer.writeFile, readRaw, ctx.locale.bind(CODE_NS))
    const disposers = CODE_EXTS.map(ext => ctx.fileExplorer.registerPreview(ext, component, 10))
    return () => { for (const d of disposers) d() }
  })
}

注册的扩展名(CODE_EXTS):ts tsx js jsx json css html py yaml yml toml env sh go rs java c cpp h xml sql graphql cfg ini

编辑器组件处理四种预览类型:

类型行为
text直接使用 preview.content(≤ 2 MiB 的文件)
text-large调用 readRawFile(filePath),将 ArrayBuffer 按 UTF-8 解码后打开编辑器(超过 2 MiB 的文本文件)
binarytext-large 相同 —— readRawFile + 解码
too-largetext-large 相同 —— readRawFile + 解码(图片超出上限;不会发给本插件注册的代码扩展名)

readRawFile 不可用时(较旧的 dsh-file-explorer 核心),text-largebinary 文件会显示升级提示。编辑内容始终通过 fileExplorer.writeFile(filePath, content) 写回。

配置

组合包只插入一行 roster 配置(无宿主端配置项):

- insert:
    - id: file-explorer-preview-code
      name: '@dsh-external/dsh-file-explorer-preview-code'

语言覆盖

@codemirror/language-data 可为 24 个扩展名中的 21 个匹配到语言。envgraphql 没有对应语言支持,会以纯文本(无高亮)的可编辑缓冲打开;cfg 会命中 language-data 的旧式 TTCN_CFG(属于匹配偏差,并非语义上的 ini)。这些扩展名仍会在编辑器中打开。

已知限制

  • 体积:所有 @codemirror/* 语言包被内联进单个 lib/client.js(约 2.7 MB 原始体积,按需懒加载)。
  • 不支持 Markdown.md/.mdx 仍由 dsh-file-explorer 内置的 markdown 预览处理。
  • 直写:编辑直接写回工作区文件,无保存前 diff、无多标签页。
  • 大文件:超过 dsh-file-explorer maxTextBytes(2 MiB)的文件会以 preview.kind === 'text-large' 到达,通过 readRawFile 获取并载入编辑器。极大的文件(数百 MiB)可能因 CodeMirror 单缓冲模型导致浏览器性能问题。readRawFile 属于稳定服务契约(于 v0.1.0 引入)。

开发预览插件

本仓库即「开发 preview 插件」的参考实现。契约、最小骨架、打包要点与 i18n 见 [docs/developing-preview-plugins.zh.md](docs/developing-preview-plugins.zh.md)([English](docs/developing-preview-plugins.md))。

相关项目

开发

npm install
npm run check     # tsc 类型检查
npm test          # vitest 单元测试
npm run build     # tsc + tsdown(宿主 ESM 占位 + 客户端 CJS bundle)

> npm run build 之后请强制刷新浏览器Ctrl/Cmd+Shift+R):dsh web 可能仍缓存着旧的插件 bundle,普通刷新可能不会加载你最新的构建。

许可

[MIT](LICENSE)