Repository navigation
docs: add a COT translation adapter example - #75
Merged
Merged
Conversation
The official COT translation bundle registers translated reasoning on `conversation.chat.reasoning.body`, and the reading view replaces that view, so enabling the bundle cannot paint translation here. aa2246740#76's text-transform seam is the supported way in, but the docs only sketch a synchronous uppercase example. Add a worked adapter under `examples/cot-translation-reader/` that registers `reasoning`, reads `ctx.cotTranslation` lazily, splits completed paragraphs to `maxTextChars`, caches results per block, and leaves the source on screen when a request fails. The new section in `docs/extension-points.md` records the four traps: synchronous `read`, no half-written streaming tail, per-block caching, and `undefined` on failure.
LingMoe404
force-pushed
the
feat/reasoning-translation
branch
from
October 29, 2026 07:55
ad507bf to
c734a9d
Compare
aa2246740
added a commit
that referenced
this pull request
Nov 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
官方「思考过程机器翻译」组合包把译文注册在
conversation.chat.reasoning.body插槽上,而阅读页用自己的卡片渲染思考,那个插槽不会渲染——所以装了翻译包,在阅读页看起来像没翻译。#76 已经给出了正确方向:
dsh-better-display.text-transform缝,翻译由第三方插件注册。但docs/extension-points.md目前只有一个同步的大写示例;真实翻译要异步批次、要subscribe、要按blockKey缓存、要在流式过程中只翻已完成段落——这些没有可抄的版本。这个 PR 改了什么
examples/cot-translation-reader/:一个可运行的参考适配器reasoningtransformer,read保持同步,请求排进微任务,完成后subscribe通知重绘;ctx.cotTranslation的limits()取目标语言与单次上限,按上限切分已完成段落;blockKey缓存译文,源文本变长时只请求新增段落;undefined(保留原文),卸载时不再发布。cordis.patch.yml与独立tsconfig.json,可以直接在本地 profile 里试。docs/extension-points.md:新增「接官方思考翻译(cotTranslation)」一节,写明limits()/translate()的调用形状,以及四个坑(同步read、不发半句话、按块缓存、失败回undefined)。CHANGELOG.md:Unreleased 条目。不改
lib/,不改运行时行为,纯文档与示例。验证
npx tsc -p examples/cot-translation-reader通过npm run typecheck、npm run lint、node scripts/check-agents-md.mjs通过npx vitest run --project unit:39 个文件通过;唯一失败是tests/skill-status.test.ts的 Windows 路径断言(本机环境问题,Linux CI 不复现)备注
package.json的files不含examples),仅供仓库内参考。