MrWeiCodes/dsh-fs-encoding

为 DeepSeek Harness(DSH)提供文件编码守护:让 AI 读写 GBK 等非 UTF-8 文件和带 BOM 的文件时不会弄坏编码

Project Overview项目介绍

This is a native file encoding management plugin built exclusively for DeepSeek Harness (DSH). It addresses a core limitation of DSH’s native file tools, which only support UTF-8 and often corrupt legacy project files with non-UTF-8 encodings or BOM headers. The plugin replaces DSH’s native read, write, and edit tools while retaining all original DSH security features, including sandboxing, version checking, and post-read write protection. To install via the recommended npm method, run the command dsh plugin --profile web add dsh-fs-encoding and restart dsh web after installation completes.

The plugin preserves byte-level fidelity: any file’s original encoding and BOM status is retained after edits, so a GBK file remains a GBK file after any modification by DSH’s AI. If the target encoding cannot represent new content added by AI, the plugin rejects the write request entirely instead of writing garbled characters that permanently corrupt the file. It is designed specifically for developers working on legacy projects that use region-specific encodings like GBK, Big5, or Shift-JIS. By default, it asks users or AI to confirm ambiguous encoding candidates to prevent incorrect guesses that damage files.

The plugin is released under the permissive MIT open source license, and supports 19 common encodings, with Windows-1258 Vietnamese excluded due to limitations of the underlying encoding library. Configuration can be done via a simple YAML file or environment variables, with options to toggle auto-guessing, adjust the list of candidate encodings, and set the maximum allowed file size. It does not modify DSH core code, and uninstalling it immediately restores the original native tools to their original state. It conflicts with any other plugin that registers the same read/write/edit tools on the same DSH scope layer.

dsh-fs-encoding是专门为DeepSeek Harness(DSH)开发的原生文件编码治理插件,用于解决DSH原生文件工具仅支持UTF-8编码、无法正确处理旧项目常见非UTF-8编码的问题。它接管DSH原生的read、write、edit三个核心文件工具,在保留原生所有安全机制与原有行为的前提下,实现非UTF-8编码文件和BOM的正确读写,始终保证文件修改后仍保留原有编码格式。

面向需要处理包含东亚多语言编码的 legacy 项目开发者,默认模式下遇到无BOM非UTF-8文件会列出候选编码供人工或AI选择,宁可失败也不猜错,避免文件被静默损坏。用户也可以开启自动猜测编码模式,让插件自动处理可明确识别的非UTF-8文件,插件不支持编码转换,严格保证不会破坏原有文件编码。

本插件采用MIT许可免费开源,共支持十九种常见编码,覆盖全系列Unicode、东亚各语言主流编码和全系列Windows ANSI编码,目前暂不支持越南语Windows-1258编码。安装方式灵活,提供四种安装方式,支持配置文件和环境变量自定义参数,安装完成后需要重启dsh web才能生效。

Pre-install check安装前体检Compatibility · Security兼容性 · 安全性 1 warning1 项注意
  • Only 6 stars - very few users, little community feedback星标只有 6,几乎没人在用,遇到问题缺少社区反馈
DSH walks through these 9 checksDSH 会逐条核对这 9 项

Compatibility兼容性

  • DSH, Node, OS and profile requirementsDSH 版本 / Node 版本 / 操作系统 / profile 是否满足要求
  • External dependencies and runtimes (Electron / Python / Docker, ...)外部依赖与运行时(Electron / Python / Docker 等)是否齐备
  • Conflicts with installed plugins: command names, skill / tool names, ports, duplicate MCP registration与已装插件是否冲突:命令名、skill / tool 重名、端口占用、重复 MCP 注册

Security安全性

  • Repo matches the facts registered here; archived or abandoned?仓库是否与页面登记一致,是否归档或长期停更
  • Safety of preinstall / install / postinstall and install.sh / setup.ps1preinstall / install / postinstall 与 install.sh、setup.ps1 是否安全
  • curl|bash, download-then-execute, obfuscation, unrelated domains → stop immediatelycurl|bash、下载即执行、混淆代码、无关域名 → 立刻停止
  • Typosquatting or unmaintained packages among the new dependencies新增依赖里有没有 typosquatting 或无人维护的包
  • Requested permissions vs. what the feature actually needs申请了哪些权限、是否超出功能所需(filesystem / network / shell / clipboard)
  • Any sudo / admin requirement, plus uninstall and rollback是否要求 sudo / 管理员权限,以及卸载与回滚方式

Anything uncertain must be marked unknown with a note on how to confirm it. This site's signal screen is a static snapshot, not a security audit.拿不准的必须标「未知」并说明要我怎么确认。本站的信号筛查是静态快照,不能替代安全审计。

Or use CLI install (for developers)或使用命令行安装(适合开发者)

CLI Install命令行安装

dsh plugin --profile web add dsh-fs-encoding

把 MrWeiCodes/dsh-fs-encoding 加入你的 DSH 配置(web profile)即可启用。

READMEREADME

dsh-fs-encoding — DSH 文件编码守护

为 DeepSeek Harness(DSH)提供的文件编码治理插件:让 AI 读写文件时不再弄坏 BOM 与多字节编码

🌏 中文 | English

dsh · dsh-plugin · plugin · encoding · BOM · GBK · Big5 · Shift-JIS · UTF-16 · AI agent · 编码 · 文件编码 · 乱码

简介

DSH 自带的 read / write / edit 三个文件工具只认 UTF-8,遇到中文、日文、韩文项目里常见的编码就会出问题:

  • GBK、Big5、Shift-JIS 等编码的文件根本读不了,直接报 invalid UTF-8 text,AI 只能干看着;
  • 带 BOM 的 UTF-8 文件能读,但 BOM 会被悄悄吃掉——AI 随手改一次,文件开头那三个字节就没了。对 PHP、旧版编译器、部分 Windows 软件来说,文件头少了 BOM 就可能解析出错或直接乱码;
  • 更麻烦的是没有任何警告:你只会在某天发现文件坏了,却不知道是哪次编辑弄坏的。

本插件接管这三个工具,在完整保留原有行为(沙箱围栏、读后写保护、版本校验、diff 展示)的前提下,让非 UTF-8 文件和 BOM 都能正确读写:文件原来是什么编码,改完还是什么编码。

功能特性

  • 字节级保真:文件编码在首次读取时确定一次,之后每次保存都按原编码写回。改一个 GBK 文件,它仍然是一个 GBK 文件,不会被偷偷转成 UTF-8。
  • BOM 保真:原本有 BOM 就精确还原,原本没有就绝不擅自添加——两个方向都不会出错。
  • 换行符保真:CRLF / LF / CR 在读取时识别、保存时还原,Windows 项目不会被改成 LF。
  • 绝不静默损坏:如果目标编码表示不了新内容(比如往 GBK 文件里写 emoji),插件会直接拒绝写入并说明原因,文件保持原样——而不是写进去一堆 ? 把文件毁掉。
  • 读不了会告诉你怎么办:遇到非 UTF-8 文件时,插件会列出最可能的几种编码和各自的解码效果,AI(或你)选一个重新读即可,就像 VS Code 的「通过编码重新打开」。
  • 十九种编码:UTF-8(含 BOM)、UTF-16、UTF-32,以及 GBK、Big5、Shift-JIS、EUC-KR 和 Windows-125x 全系(西欧、中欧、西里尔、希腊、土耳其、希伯来、阿拉伯、波罗的海)。
  • 零学习成本:read / write / edit 三个工具的参数、返回格式与原版完全一致,是直接替换,原有提示词和工作习惯都不用改;read 和 write 各多了一个可选的 encoding 参数(write 的只用于新建文件,见下)。
  • 能建指定编码的新文件:write 加一个 encoding 就能直接生成 GBK、Shift-JIS 等编码的文件,不用先写 UTF-8 再转码。
  • 多三个工具:insert(按行号插入,原生没有这个能力)、undo_last_edit(撤销上一次编辑,内容与编码一并还原)和 str_replace_editor(4 个子命令的兼容层,同样带编码治理)。见下方「另外三个工具」。
  • 配置简单:一个 YAML 文件,几项开关,都能用环境变量覆盖。

使用

开箱即用

装好就能用,不需要任何配置。 插件没有必填项、没有初始化步骤,也不会改动你的项目——装上之后,AI 照常用 read / write / edit,编码的事插件自己处理:

  • 读 UTF-8 文件(含带 BOM 的):和原版完全一样,BOM 不会再被吃掉。
  • 读带 BOM 的 UTF-16 / UTF-32 文件:自动识别。
  • 改 GBK、Shift-JIS 等老编码文件:按原编码写回,不会被悄悄转成 UTF-8。
  • 写新文件:默认 UTF-8,需要别的编码时加一个参数即可。

这些都不需要你做任何事,也不需要 AI 改调用习惯。日常使用中,AI 的调用方式与原版完全一致。

AI 的调用区别

只有一种情况会不一样:无 BOM 的非 UTF-8 文件(典型是 GBK / Big5 / Shift-JIS 的老文件)。此时插件不会擅自猜,而是停下来让 AI 用显式编码重读一次:

Showing the opening section of the README — the full document lives in the repository以上为 README 开头摘要,完整文档在仓库内 · View the full README on GitHub →在 GitHub 查看完整 README →

← 上一个 Prev dsh-btw 下一个 Next dsh-gungnir →