opencode-plugin-utf8OpenCode plugin that ensures UTF-8 encoding for shell environments, fixing Chinese character garbled text on Windows
0
71
17 in 7 days
30.8
Multi-signal model
17 days ago
2026-08-03
Install and configure
opencode.jsonWrites 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"]
}Writes to ~/.config/opencode/opencode.json — applies to every project.
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-plugin-utf8@1.0.0"]
}If you want to modify the plugin locally, install it into the project and reference the local path.
shell
pnpm add -D opencode-plugin-utf8opencode 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 实现:
shell.env— 为所有 shell 命令注入 Python UTF-8 环境变量:PYTHONIOENCODING=utf-8PYTHONUTF8=1
tool.execute.before— 在 PowerShell 命令前添加编码设置:[Console]::OutputEncoding = [System.Text.Encoding]::UTF8[Console]::InputEncoding = [System.Text.Encoding]::UTF8
安装
npm install opencode-plugin-utf8
配置
在 OpenCode 配置文件 (opencode.json 或 opencode.jsonc) 中添加:
{
"plugin": ["opencode-plugin-utf8"]
}
或者本地开发时使用文件路径:
{
"plugin": ["./node_modules/opencode-plugin-utf8/src/index.js"]
}
兼容性
| 环境 | 状态 |
|---|---|
| Windows PowerShell | 支持 |
| Windows Python | 支持 |
| macOS / Linux | 无副作用,可安全启用 |
License
MIT