dsh-plugin-pwsh-utf8
v0.1.1
Published
DeepSeek Harness plugin: a sandboxed pwsh tool with UTF-8 file-I/O defaults forced, fixing garbled Get-Content/Set-Content on CJK Windows (codepage 936).
Maintainers
Readme
dsh-plugin-pwsh-utf8
DeepSeek Harness 插件:一个强制 UTF-8 文件 I/O 默认值的沙箱化 pwsh 工具。
背景
中文 Windows(系统代码页 936)下,harness 自带的 pwsh 工具只设置了 [Console]::OutputEncoding,而 Get-Content / Set-Content 仍按 ANSI 代码页读写——harness 自己写的 UTF-8 文件(session 日志、workspace.json、代码文件)会被读成乱码(实测复现)。pwsh_utf8 在每个命令前注入:
$PSDefaultParameterValues['Get-Content:Encoding']='UTF8'
$PSDefaultParameterValues['Set-Content:Encoding']='UTF8'
$PSDefaultParameterValues['Add-Content:Encoding']='UTF8'
[Console]::InputEncoding=[System.Text.UTF8Encoding]::new($false)
$OutputEncoding=[System.Text.UTF8Encoding]::new($false)效果
注册 pwsh_utf8 工具,语义与 pwsh 相同(走 ctx.shell,保留沙箱/审批),但文件读写按 UTF-8 处理。模型在中文 Windows 上读 UTF-8 文件时应优先用这个工具。
安装
dsh plugin --profile web add dsh-plugin-pwsh-utf8挂载(profile cordis.patch.yml 或 agent preset):
- id: pwsh-utf8
name: dsh-plugin-pwsh-utf8边界
- 只修文件 I/O cmdlet 与控制台编码;不改变 PowerShell 语言模式(CLM 仍由沙箱策略决定)。
- 不替换内置
pwsh工具(外部插件无法改写其定义);模型需要选择pwsh_utf8。若要在 preset 中强制使用,可配合tools.restrict禁用内置pwsh。
开发
npm test