Introduction

DeepSeek Harness (DSH) extends capabilities through plugins. In Windows environments, the built-in pwsh tool included with DSH may produce garbled characters when running commands, especially for Chinese and other non-ASCII characters. This happens because native program output encodings are inconsistent: some programs output using the system ANSI code page (such as GBK), while others output UTF-8, whereas DSH internally decodes uniformly as UTF-8. As a result, a single decoding strategy cannot cover all scenarios.

Plugin Overview

This plugin is hongweifei/dsh-pwsh-encoding-fix, used to fix the garbled-character issue described above. It is a Cordis plugin (bundle type) that performs encoding conversion inside the PowerShell process, ensuring that mixed GBK and UTF-8 output is displayed correctly.

Core Features

The plugin provides the following capabilities:
* Automatic encoding detection: It can correctly handle mixed GBK and UTF-8 output from the same command on a segment-by-segment basis.
* Lossless capture: It natively receives output byte by byte using Latin-1 (code page 28591), preventing invalid byte sequences from being replaced with placeholders.
* No change to command semantics: $? and $LASTEXITCODE are captured as usual, and the exit code remains unchanged when a command fails.
* Works for foreground and background commands: The wrapping occurs at the shell.resolve entry point, covering both foreground run and background start.
* Only affects PowerShell: The bash executor is not affected.

Installation and Enablement

Use the official command to install the plugin:

dsh plugin --profile web add "github:hongweifei/dsh-pwsh-encoding-fix"

After installation, restart DSH Web and perform a hard refresh (Ctrl+F5).

Configuration

By default, the plugin attempts to decode non-UTF-8 bytes using the system ANSI code page (Default). If you need to explicitly specify a code page (for example, forcing GBK), append configuration to the profile’s cordis.patch.yml:

- insert:
    - id: pwsh-encoding-fix
      name: '@dsh-external/dsh-pwsh-encoding-fix'
      config:
        codePage: '936'

Typical Usage

Run the following commands in the pwsh tool to verify:

# 测试 UTF-8 输出的程序
node -e "process.stdout.write('错误: 找不到符号\n')"

# 测试 GBK 输出的程序
ipconfig

Notes

Be aware of the following edge cases when using the plugin:
* Write-Host output: Because encoding is temporarily switched during capture, Chinese text in Write-Host may be encoded as ?. Use Write-Output instead.
* exit command: If a command ends with exit N, that output may be lost (the exit code remains correct).
* PowerShell 5.1 arguments: Passing parameters containing . to native programs may cause argument-splitting issues. Use environment variables instead (such as $env:JAVA_TOOL_OPTIONS).
* Large output: Very large output is first aggregated in pwsh memory; pipe byte truncation behavior is unaffected.

Summary

This plugin solves the encoding inconsistency issues for pwsh commands in Windows environments in DSH, making debugging of Chinese output and mixed-encoding scenarios more intuitive.

Directory page: hongweifei/dsh-pwsh-encoding-fix
GitHub repository: hongweifei/dsh-pwsh-encoding-fix