HwFee/HwFee-dsh--plugins-cds-theme ↗★ 0

dsh-cds-theme

将DSH界面重映射为Claude暖灰设计主题 适合喜爱Claude视觉风格、追求极致排版与动效美感的DSH用户。

套件
dsh-cds-theme
相容性
待驗證
版本
0.1.1
最近更新
2026年10月19日

安裝

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:HwFee/HwFee-dsh#ef06b50508f65c3bd61dbb14a7d28d8061665a84&path:plugins/cds-theme

dsh-cds-theme

DeepSeek Harness 的 Claude Design System (CDS) 完整主题插件:将宿主整套 --dsw-* 设计令牌精准映射至 CDS 规范,呈现中性灰表面阶梯、陶土橙强调色、hsla(0,0%,8%,α) 发丝边框、双层弥散阴影与三层焦点环,并对输入框、代码块、消息行、聊天 Markdown 正文进行深度的组件级视觉打磨,将思考状态提示重塑为陶土呼吸微光。插件内嵌 6 个 Anthropic 官方可变字体文件(Sans/Serif/Mono × Roman/Italic),将 Claude 7 阶字号阶梯与暗色字重光渗补偿映射至宿主排印令牌,并将首页问候语替换为标准的衬线 Display 排印。Markdown 表格优化为闭合发丝边框、浅底表头、完整单元格内边距与等宽数字;引用块补齐对称下边距。设置文案严格适配宿主语言(中英文界面纯净无混杂);提供「深度思考提示使用原版蓝」等细粒度调节开关。

A Claude Design System (CDS) theme for DeepSeek Harness. It remaps the host's whole --dsw-* token set to CDS: a neutral-grey surface ladder, a clay-orange accent, hsla(0,0%,8%,α) hairline borders, a two-layer diffuse shadow, a three-layer focus ring, plus component-level refinement for inputs, code blocks, message rows and the chat markdown body, and a clay breathing glint for the thinking label. Six real Anthropic variable faces ship in fonts/ (Sans/Serif/Mono × Roman/Italic); the Claude 7-tier type ladder and dark-mode weight compensation ride the host's typography tokens, and the hero greeting uses the reference's serif display type. Chat markdown tables become a closed hairline frame with a tinted header, restored cell insets and tabular numerals, and blockquotes get the bottom margin the host leaves out. Settings copy follows the host language — pure Chinese in zh, pure English in en — and a “thinking-label colour” switch restores the host's original blue for the “Deep diving…” line only.

提供明暗两套配色方案。设置项划分为两个面板:主题定制承载主题模式切换及八个外观旋钮(强调色预设、表面暖度、圆角比例、阴影强度、组件级细化、思考提示配色、长文本粘贴智能转存、中文优先使用主题字体),通用设置中则保留「启用 CDS 主题」总开关 ——「主题定制」在设置侧边栏中与「通用」「账户」同级呈现(拥有专属滑块图标),而非挤占「通用」面板。命名遵循明确的区分约定:因宿主在「通用」面板中原生包含名为「外观 / Appearance」的色彩模式行(浅色 / 深色 / 跟随系统),故本插件专属页面命名为「主题定制 / Theme」,并在页面导语中明确指引原生明暗模式的位置。

Two palettes (light/dark). The rows live on two settings pages: Theme carries the theme-mode row plus eight appearance knobs (accent, surface warmth, radius, elevation, component refinement, the thinking-label colour, long-paste-as-a-file and prefer-calibrated-Chinese), while General keeps only the “Enable CDS theme” master switch. Theme is a real page in the settings sidebar — a sibling of General and Account, with its own slider glyph — not a group inside General. The name is deliberately distinct from the host's own 「外观 / Appearance」 row (the light/dark/system cubes, which stay in General), and the page intro says so.

它做了什么 · What it does

层 Layer机制 Mechanism覆盖 Coverage
配色令牌 Tokensctx.theme.overrideTokens131 个配色/形状令牌:表面阶梯、文本三阶、边框四档、品牌双轨、状态色、代码 diff、菜单/侧栏/气泡、滚动条、onboarding
字体 Faces构建时内联 data:font/woff2(file:// 基址作源码运行的回退)6 个可变 woff2,字体族名与参考完全一致:anthropic-sans / anthropic-serif / anthropic-mono(wght 300–800, opsz 16–48),在任意文档 origin 下都能加载
排印 Typographyctx.theme.overrideTokens130 个排印令牌:17 个 markdown 角色 × 6 个宿主变量 + 文本/代码字族角色 + 13 级 UI 阶梯 × 2 个 token;7 阶字号、行高、每个参考元素的字重与暗色减薄
形状与动效 Shape & motion同上 same圆角六档(输入框 28→20px,气泡 20→18px)、阴影三档、CDS 缓动曲线
海拔阴影 Elevation插件样式表 !important--dsw-elevation-panel/prominent/soft
组件细化 Refinement插件样式表 stylesheet输入框三态阴影、焦点环、代码块、菜单双环、滚动条、思考标签的陶土呼吸微光、消息操作栏悬停显现、滚动渐隐遮罩、代码块横幅/折叠头细节
Markdown 正文 Markdown body结构定位 + 自有 data-cds-table 属性 + 插件样式表聊天表格:合拢 .5px 发丝框 + 10px 圆角、表头浅底、恢复首尾列内边距、末行去重线、等宽数字;引用块补回下边距(已验收,常驻)
问候语衬线 Hero serif结构定位 + 自有 data-cds-greeting 属性空白会话标题换成参考的衬线 display 排印(38px / 1.2 / wght 330 / opsz 48)
双语设置 Bilingual settingsctx.locale.register + 槽位 locale:10 行设置(20 条标题/说明) + 4 个色板名 + 3 个主题模式名,zh 纯中文、en 纯英文,切语言即重渲染
设置页 Settings pagessettings.section + 自有子槽位 settings.appearance.item「主题定制 / Theme」是与「通用」「账户」同级的一页(order: 1),九个外观行(「主题模式」+ 八个旋钮)挂在自己的子账本上;总开关仍在「通用」。宿主没有设置外壳时全部行回落到通用列表
中文优先 Prefer Chinesebody 上重声明完整 --font-anthropic-* 组合 + 设置开关默认开启:正文/代码的中文先命中内嵌、校准字重的思源黑体,再落到系统字体;首页问候语仍走思源宋体。关闭即恢复原顺序。手选字体始终优先,字体大 @font-face 表不重建
主题模式 Theme modetheme.getTheme().preference / theme.setTheme(id) / theme/change浅色 / 深色 / 跟随系统,与宿主那一行是同一个持久化偏好(同一写入入口),两处不可能分叉;宿主那行用 CSS 藏在「通用」里
设置页图标 Nav icon结构定位 + 自有内联 SVG(assets/appearance-icon.svg)宿主 navIcon(id) 是硬编码 if-chain、未知 id 一律回落到齿轮;主题页因此没有自己的图标。插件按标签找到侧栏按钮,插入同心方框的 SVG 并隐藏宿主齿轮(可还原),两侧尺寸与描边跟随宿主的 Medium/Regular 两档

为什么令牌必须走 overrideTokens

宿主的 layout 把当前主题的令牌内联写在 `` 上:

for (const [name, value] of Object.entries(snapshot.active.tokens))
  body.style.setProperty(name, value)

内联声明压过任何同等重要性的样式表规则。所以「用 CSS 改 --dsw-alias-bg-base」是无效的 —— 必须换掉令牌表本身。overrideTokens 就是那个接口:它在活动主题之上叠一层,按明暗两种配色分别取值,layout 完全不需要知道有这一层存在。排印令牌(--dsw-font-markdown-*、--dsw-font-family、--ds-font-family-code)走同一个通道,原因相同:宿主自己也把它们声明在 body 上,只有令牌层能改。

The host layout inlines the active theme's tokens onto ``. An inline declaration beats any same-importance stylesheet rule, so editing --dsw-alias-bg-base from CSS does nothing — the token map itself must be swapped. overrideTokens is that interface. The typography tokens travel the same seam for the same reason: the host declares them on body too.

为什么阴影必须走样式表

--dsw-shadow-lv* 声明在 body 上,内联可覆盖。但 --dsw-elevation-* 声明在 body, body * 上 —— 每个后代元素各自持有一份声明,body 的内联值到不了子元素。所以这一层必须用带 !important 的样式表规则。详见 docs/host-hooks.md 第 7 节。

--dsw-shadow-lv* is declared on body, so an inline override works. But --dsw-elevation-* is declared on body, body * — every descendant carries its own copy, so a body inline value never reaches the children. That layer must come from an !important stylesheet rule.

为什么字体单独占一个 ``

插件写两个 ``:静态字体块(STYLE_ID + '/fonts',六个 @font-face,浏览器里是约 970 KB 的内联 data:font/woff2)每次激活只写一次;状态相关规则(约 7.9 KB)进 STYLE_ID 标签,设置变更只重写后者。改动前每次切换都会重建/重新解析整张 ~977 KB 的样式表并重新注册六个字族,这是“点一下卡一下”的来源。字体块在模块作用域缓存,buildCss / buildCssFor 的输出保持逐字节不变 —— 拆分只发生在 DOM 写入层(indexOf/slice 剪掉缓存块)。主开关关闭时只清空规则标签,字体标签保留(字族令牌已回到宿主默认,@font-face 无人引用;删掉它们会让全文档字形回退系统字体并触发整页字体重排,那正是“关闭很慢”的原因);只有插件卸载才移除两个标签。

Two `` tags: the static font block (STYLE_ID + '/fonts', six @font-face faces = ~970 KB of inlined data URLs in the browser) is written ONCE per activation, while the state-dependent rules (~7.9 KB) live in STYLE_ID and are the only thing rewritten on a settings change. Before the split every toggle rebuilt and re-parsed a ~977 KB sheet and re-registered six faces — that was the lag. The font string is cached at module scope; buildCss/buildCssFor output stays byte-identical (the split is a DOM-write concern: slice the cached block out with indexOf). With the master switch OFF only the rules tag is emptied and the fonts tag is KEPT (the family tokens revert to host defaults, so the faces are unreferenced; removing them would drop every glyph to a system fallback and force a full-document font re-layout — that was the “turn OFF is slow” report); only teardown removes both tags.

为什么 enabled 的开关不会自激

宿主主题服务在 overrideTokens() 内部同步发布 theme/change,而本插件自己也订阅该事件并调用 bridge.sync()。没有重入保护时:外层注册还在 overrideTokens() 里没拿到 disposer,重入的 sync 又注册一层并把旧层替换掉,外层随后保存的是已失效层的 disposer —— 之后的“关闭”就永远释放不掉(表现为「只有打开有效,关闭没反应」,重入还会递归爆栈并被设置存储的 try/catch 吞掉)。createThemeBridge 现在一次只允许一个 sync 在飞(syncing 标志),注册与释放都原子完成;测试驱动 false→true→false→true 全链路,断言字族标签只写 1 次、每次开启只有 1 个活动层、每次切换最多 1 次规则标签写入。

The host theme service publishes theme/change synchronously from inside overrideTokens(), and this plugin subscribes and calls bridge.sync() from it. Without a re-entrancy guard the outer registration had not yet stored the disposer when a nested sync registered a replacement layer; the outer call then kept the disposer of the replaced layer, so every later OFF silently did nothing (the symptom “only ON works”, plus a recursive overflow swallowed by the settings store). createThemeBridge now allows one sync at a time (syncing), so register/release are atomic. The test drives false→true→false→true end to end and asserts the fonts tag is written once, exactly one active layer per ON, and at most one rules-tag write per flip.

字体 · Fonts

fonts/ 里是 6 个真实的 Anthropic 可变字体(从 anthropic.com 的 web 字体包取样,wght 300→800;Sans/Serif 另有 opsz 16→48)。client/src/fonts.js 用参考完全一致的族名声明它们:

字体族 FamilyRomanItalic用途 Role
anthropic-sansAnthropicSans-Roman-Web.woff2AnthropicSans-Italic-Web.woff2正文、UI 文本(--dsw-font-family)
anthropic-serifAnthropicSerif-Roman-Web.woff2AnthropicSerif-Italic-Web.woff2首屏问候语(--font-anthropic-serif)
anthropic-monoAnthropicMono-Roman-Web.woff2AnthropicMono-Italic-Web.woff2代码、行内代码(--ds-font-family-code)

中文回退 · The CJK fallback

Anthropic 的三个字体族没有任何 CJK 字形(实测:AnthropicSans-Roman 625 个码位、CJK 统一表意文字 0 个,unicode-range 一个都没写,与 anthropic.com 线上文件的 SHA256 完全一致)。所以中文必须另有回退,而回退选谁由字重阶梯决定,不是审美决定。

主题会发出 8 个字重(typography.js 的 WEIGHTS):330 / 360 / 400 / 460 / 500 / 550 / 580 / 660,其中 360/460/550 是暗色视网膜补偿——它是暗色模式读起来和浅色一致的全部机制。

苹方 PingFang SC思源黑体 Noto/Source Han Sans
字重静态:本机只有 Regular 400 + Semibold 600可变 100–900
8 个字重能呈现几种2 种(6 个值互相不可辨)8 种全部可辨
暗色补偿全部失效全部生效
随主题分发不可(All rights reserved + Apple 商标,无许可字段)可(SIL OFL 1.1)

因此选思源黑体。两款字体骨架几乎相同(同字号下字面高度差 1.3%),差别只在这个。

为什么需要轴偏移。 思源在相同名义字重下比 Anthropic Sans 细约 17%(实测竖干,同 em:Anthropic 400 = 0.0943,思源 400 = 0.0758)。而字体回退是按字符的,font-weight 却是整段一个值——中文不可能向浏览器要一个和英文不同的数字。avar 表正是为此存在:它在插值前把用户坐标映射到设计坐标。于是 font-weight: 400 会画出竖干等宽于 Anthropic Sans 400 的那个设计字重。

断点是按浏览器实测校准的,不是按轮廓坐标:第一版用轮廓测量,Chrome 自己的插值和栅格化让它偏细 0.8–6.3%。校准后残差 0.0–0.7%(330–580),660 档 -2.8%——主题的 bold 竖干比思源 900 轴顶还宽,这一档只能留一点点偏细,不伪造映射。

CSS 字重330360400460500550580660
avar 映射到设计坐标404441490567622705754850

为什么是子集。 全量思源可变字体 5.37 MB(宋体 7.70 MB),内联成 base64 是 17.5 MB 的提交产物。所以随主题走的是 7000 常用字 + 全套 CJK 标点 + ASCII:NotoSansSC-Shifted-VF.woff2 1.72 MB(可变 + avar)、NotoSerifSC-Shifted-330.woff2 1.22 MB(静态,问候语只用 330 一档)。子集外的生僻字落到栈里下一档的同一款字体("Noto Sans SC" 就在后面),所以仍是思源,只是没有轴偏移——单个字看不出来。重新生成用 python tools/build-cjk-fonts.py。

顺带修掉参考仓库的一个缺陷。 参考的 --font-anthropic-serif 结尾是 var(--font-cjk-sans-fallback)——衬线栈后面挂的是黑体,所以首屏问候语里英文是衬线、中文是黑体,一个行内两种骨架。本插件改用 --font-cjk-serif(思源宋体),问候语现在是一个字体。

字体族 Family文件用途 Role
anthropic-cjkNotoSansSC-Shifted-VF.woff2中文正文、UI 文本
anthropic-cjk-serifNotoSerifSC-Shifted-330.woff2中文首屏问候语

Anthropic's three families carry NO CJK glyphs at all (measured: 625 codepoints in AnthropicSans-Roman, zero CJK unified ideographs, no unicode-range, byte-identical to the file anthropic.com serves today). Chinese therefore needs a fallback, and the choice is decided by the WEIGHT LADDER, not by taste: the theme emits eight weights (330/360/400/460/500/550/580/660), three of which are the dark-mode retinal compensation. Stock PingFang is two static files, so it collapses those eight into two; Noto/Source Han is variable, so all eight survive, and it is SIL OFL so it can ship. Source Han is ~17% lighter than Anthropic Sans at the same nominal weight, and font-weight is one value for a whole run while fallback is per-character — so an avar table remaps user-space weight onto the design coordinate whose stem matches. The breakpoints are calibrated against BROWSER-rendered stems (outline coordinates landed 0.8-6.3% light); residual error is 0.0-0.7% for 330-580 and -2.8% at 660, where the theme's bold is wider than Noto's 900 axis ceiling. The faces are a 7000-ideograph subset (~3 MB total instead of 13 MB) because a full pair would inline to 17.5 MB; a rarer glyph falls through to the same installed family a rung later. The reference's serif stack is also fixed here: it ended in the SANS CJK chain, so Chinese in the greeting rendered as a sans beside a serif Latin.

@font-face 的六个 src 在构建时内联为 data:font/woff2:client/src/font-assets.js 导入 fonts/ 里的二进制,tools/build-client.mjs 用 esbuild 的 dataurl loader 把每个 woff2 变成 data URL,所以 client/client.js 里没有任何路径。这是唯一在桌面外壳(文档 origin 为 dsh-app://app)里能真正加载字体的方式:路由地址会落到 app 协议处理器上 404,file:// 被当作本地资源拦截,绝对 http://127.0.0.1: 又是跨源且路由没有 CORS 头。data URL 没有 origin、不需要 token、不经过 CSP。

代码里只剩一条回退(fontSourcesFor,用于没有构建 loader 的源码运行):Host 注入的 file:// 基址 __CDS_THEME_FONT_BASE__(webserver/index-inject 行,运行时由 import.meta.url 计算)。原先还有第二条——同源路由 /dsh-cds-theme/fonts/——已删除:它所在的 URL 分支在任何一个能构建出来的产物里都不会进入(见 lib/index.js 的长注释:内联表总是被填满;缺少二进制时构建直接失败而不是回退;桌面外壳的 dsh-app://app origin 也解析不了路由地址)。路由删除后如果还发它的 URL,那是一个必然 404,所以客户端也不再生成。

fonts/ 在 package.json 的 files 里,link: 安装直接指向本目录。字体只靠内联数据,重建 client/client.js 后刷新页面即可。

The six @font-face sources are INLINED as data:font/woff2 at build time (font-assets.js + esbuild's dataurl loader), so client.js carries no path. That is the only delivery that works in the desktop shell (dsh-app://app origin: route-relative URLs 404 in the app protocol handler, file:// is blocked, absolute http://… is cross-origin without CORS). ONE fallback remains in fontSourcesFor for source runs without the build loader — the Host-injected file:// base. The same-origin webServer route that used to be the other fallback is DELETED: its branch is unreachable in every buildable configuration (the inline table is always populated; a build without the binaries fails outright; the app origin cannot resolve a route URL), and emitting its URL after deletion would be a guaranteed 404.

字体栈 · Font stacks

字体栈在 CJK 那一段有意偏离参考,其余逐字保留。参考 CSS(.reference/open-claude-ui/code-examples/cds-theme.css:205-213)的 CJK 链是四个 macOS 族名——Windows 上一个都不命中,中文落到系统默认;macOS 上命中,但命中的是静态版苹方,8 个字重同样塌成 2 个。所以两平台都不对,必须换。

/* 参考保留:四个 macOS 族名仍然逐字在这,只是退到最后 */
--font-cjk-sans-sc: "PingFang SC";
--font-cjk-sans-tc: "PingFang TC";
--font-cjk-sans-jp: "Hiragino Sans";
--font-cjk-sans-kr: "Apple SD Gothic Neo";

/* 新增:随主题走的中文回退,排在最前 */
--font-cjk-sans: "anthropic-cjk", "Noto Sans SC", "Source Han Sans SC", , "Microsoft YaHei";
--font-cjk-serif: "anthropic-cjk-serif", "Noto Serif SC", "Source Han Serif SC", "Songti SC", SimSun, var(--font-cjk-sans);
--font-cjk-sans-fallback: var(--font-cjk-sans);          /* 参考的旧名指向新链 */

--font-sans-fallbacks: system-ui, "Segoe UI", Roboto, Helvetica, Arial, var(--font-cjk-sans), sans-serif;
--font-anthropic-sans: "anthropic-sans", var(--font-sans-fallbacks);
--font-anthropic-serif: "anthropic-serif", ui-serif, Georgia, "Times New Roman", var(--font-cjk-serif), serif;
--font-anthropic-mono: "anthropic-mono", ui-monospace, "Cascadia Mono", Consolas, var(--font-cjk-sans), monospace;

三处具体改动,每处都有理由:

  1. CJK 链最前面是 anthropic-cjk —— 真正随主题分发的思源黑体,见上一节。
  2. 衬线栈挂 --font-cjk-serif 而不是 --font-cjk-sans-fallback —— 参考的写法让衬线栈后面跟黑体,首屏问候语里中英文是两个骨架。这是参考的缺陷,不是取舍。
  3. 等宽栈补 "Cascadia Mono", Consolas —— 参考只有 ui-monospace, monospace,Windows 上 ui-monospace 不可靠,中文又要有回退,所以显式点名系统等宽。

The stack departs from the reference ONLY in the CJK rungs, for a reason each: the reference's CJK chain is four macOS family names — none resolve on Windows, and on macOS they resolve to the STATIC PingFang, so the theme's eight weights collapse to two there as well. Both platforms are wrong, so the shipped chain puts the real shifted Source Han face first and keeps the reference names behind it as a last resort. The serif chain is also repointed at the SERIF CJK face: the reference ended it in the sans chain, so Chinese in the greeting rendered as a sans beside a serif Latin — a defect, not a tradeoff. The mono chain gains an explicit Windows monospace before its CJK rung, because ui-monospace is unreliable there.

排印 · Typography

字号/行高/字重逐角色对齐参考的 7 阶阶梯(`docs/v1/