GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - heyuan29171/retc-opencode-reasoning-translator: OpenCode Desktop GUI plugin: live Simplified Chinese translation of the model's English reasoning in a side panel (retc = reasoning english to chinese).

BranchesTags
Open more actions menu

Latest commit

 

History

27 Commits
27 Commits

Folders and files

NameName
Last commit message
Last commit date
examples
examples
 
 
src
src
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
tsconfig.json
tsconfig.json
 
 
vite.config.ts
vite.config.ts
 
 

Repository files navigation

retc — reasoning english to chinese

OpenCode Desktop 的 GUI 插件:把模型的**英文思考过程(reasoning)**实时翻译成简体中文,显示在会话右侧的独立面板里。

  • 侧栏面板「思考译文」,灰色背景 + 黑色文字,和正文明显分开
  • 边思考边翻译:服务端订阅 session.reasoning.* 事件,按句切块翻译后推给面板
  • 面板顶部可切换翻译模型(列出所有已配置模型)
  • 完全不写会话消息:零上下文占用,压缩/摘要也不会有残留
  • 不弹额外窗口,不修改 OpenCode 本体

环境要求

  • OpenCode Desktop 2.2.0+(桌面插件 API;在 2.3.0 上开发)
  • Node.js 22+(只用于构建 GUI 包)

安装

git clone https://github.com/heyuan29171/retc-opencode-reasoning-translator.git
cd retc-opencode-reasoning-translator
npm install
npm run build

在 ~/.config/opencode/opencode.json 里加:

{
  "plugins": ["<absolute-path-to-retc>"]
}

完全退出并重新打开 OpenCode Desktop。进入会话后,右侧面板会多一个「思考译文」标签;也可以从侧栏 + 菜单或命令面板 retc: 思考译文 打开。

使用

  • 默认翻译模型:zhipuai/glm-5.3-flash(1500 万 tokens 资源包,翻译短句足够用)
  • 请求失败会自动回落:目标模型 → zhipuai/glm-5.3-flashx(300 万 tokens)→ zhipuai/glm-5.3-flash,两个都失败才报错;不再回落 glm-4.5-air(新资源包不含该模型,会报 1113)
  • 面板右上角的下拉框可以切换翻译模型,选择会保存在插件自己的 storage 里
  • 直连请求读取 auth.json 里的 zhipuai key,或环境变量 ZHIPUAI_API_KEY;其他 provider 走 OpenCode 的 generate

模型与请求参数

GLM-5.3 系列(glm-5.3-flash、glm-5.3-flashx)强制思考,不能关闭:

  • 传 thinking: { type: "disabled" } 会返回 400、code 1210(该模型强制思考,不支持关闭思考,请使用 low/high/max)
  • 因此请求里不传 thinking,改用 reasoning_effort: "low" 把思考压到最低档;翻译是短任务,不需要 high / max
  • 同时按官方推荐传 temperature: 1、top_p: 0.95

流式响应会先吐 delta.reasoning_content(思考帧)再吐 delta.content(译文帧),插件只取 delta.content;如果整段只有思考、没有译文,按失败处理(面板显示错误,不会一直转圈)。

错误处理:

情况 行为
HTTP 429 / code 1305(并发已满) 等 800ms 重试一次
code 1113(无可用资源包) 不重试,直接报「资源包不足」并交给回落链
只有 reasoning_content、无 content 抛错,面板显示 error

工作原理

server 部分(@opencode/plugin)
  session.reasoning.started / delta / ended
    → 按句切块(≥120 字符)
    → ctx.experimental.generate.text() 逐块翻译
    → RPC 事件 reasoning 推给 GUI

GUI 部分(./gui-experimental,Vite 打包)
  Panel(侧栏)+ Style(灰色主题 CSS)
    → 订阅 RPC 事件,按 session 过滤
    → 流式渲染,自动滚动

整个流程只读事件,不写消息、不碰会话内容。

开发

npm run watch
npm run typecheck
  • GUI 改动:本地目录的 ./gui-experimental 重新构建后,Desktop 会重新加载 GUI
  • server 改动:需要重启 OpenCode Desktop

排错

  • 插件没加载:看 OpenCode 日志里的 loading plugin / failed to load plugin
  • 面板没有译文:确认当前模型会产出 reasoning;确认 provider 有可用额度
  • GUI 改完没生效:重新 npm run build,必要时重启 Desktop

License

MIT

About

OpenCode Desktop GUI plugin: live Simplified Chinese translation of the model's English reasoning in a side panel (retc = reasoning english to chinese).

Topics

chineseopencodeopencode-desktopopencode-guiopencode-pluginreasoningtranslationzhipuai

Resources

Readme
MIT license
Activity

Stars

1 star

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.