Skip to content
    ↑↓ select↵ openesc close
    English中文
    elvisw
    opencode-plugin-utf8

    OpenCode plugin that ensures UTF-8 encoding for shell environments, fixing Chinese character garbled text on Windows

    GitHub stars

    0

    Monthly installs

    71

    17 in 7 days

    Composite scoreSCORE

    30.8

    Multi-signal model

    Last commit

    17 days ago

    2026-08-03

    Install and configure

    opencode.json

    Writes to this project's opencode.json — applies to this repository only.

    opencode.json

    {
      "$schema": "https://opencode.ai/config.json",
      "plugin": ["opencode-plugin-utf8@1.0.0"]
    }

    opencode loads npm dependencies through its embedded runtime on startup and caches them locally — no manual global install needed.

    OpenCode 插件:自动为 shell 环境注入 UTF-8 编码配置,解决 Windows 上中文乱码问题。

    解决的问题

    在 Windows 环境下使用 OpenCode 时,PowerShell 和 Python 子进程默认使用系统编码(如 GBK),导致中文输出乱码。本插件自动注入编码配置,无需手动设置��[...]

    工作原理

    插件通过两个 hook 实现:

    1. shell.env — 为所有 shell 命令注入 Python UTF-8 环境变量:

      • PYTHONIOENCODING=utf-8
      • PYTHONUTF8=1
    2. tool.execute.before — 在 PowerShell 命令前添加编码设置:

      • [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
      • [Console]::InputEncoding = [System.Text.Encoding]::UTF8

    安装

    npm install opencode-plugin-utf8
    

    配置

    在 OpenCode 配置文件 (opencode.jsonopencode.jsonc) 中添加:

    {
      "plugin": ["opencode-plugin-utf8"]
    }
    

    或者本地开发时使用文件路径:

    {
      "plugin": ["./node_modules/opencode-plugin-utf8/src/index.js"]
    }
    

    兼容性

    环境 状态
    Windows PowerShell 支持
    Windows Python 支持
    macOS / Linux 无副作用,可安全启用

    License

    MIT