Skip to main content

rebrand-plugin/packages/react/examples/rebrand-plugin

16Stars2Forks1Issues0Watchers

Provides a library for runtime patching, replacing, and decorating DSH plugins, aiding in plugin development and customization.

Evidence5/5methodologySourceInstallMaintenanceDSH versionSecurity scan
Machine-auditedInstall commandRepo verifieddsh-plugin topicLicenseREADMEAI wiki

ⓘ This plugin is a sub-package of the CH4ACKO3/dsh-harmony monorepo — stars and activity count the whole repository.

Language
TypeScript
License
MIT
Branch
main
deepseek-harnessdsh-pluginharmonynodejsruntime-patchingtypescript

Install

cmdweb profile
$ dsh plugin --profile web add github:CH4ACKO3/dsh-harmony#path:packages/react/examples/rebrand-plugin

Run the command above in your terminal to install this plugin via the dsh CLI. You can switch Profile in the top-right corner. New to dsh? Read the beginner tutorial

Install via your agent

Install the DeepSeek Harness plugin CH4ACKO3/dsh-harmony/packages/react/examples/rebrand-plugin for me: review the repository at https://github.com/memorax-ai/dsh-harmony first, then run the install command and verify the plugin loads successfully.

Paste this instruction to the DSH Web GUI assistant — it will install and verify for you.

一句话定位

这是 dsh-harmony 仓库里的官方示例插件,用来演示如何用 dsh-harmony-react 的 element() 工厂把 DSH WebUI 侧边栏内置的 BrandWordmark 组件替换为一个渲染 "Custom DSH" 文字的简单 React 组件。

核心能力

  • 在 DSH 启动前把内置侧边栏的 BrandWordmark 组件整体替换为自定义 React 组件,渲染一行加粗的 "Custom DSH" 文字
  • 用 element() 工厂声明目标包、目标版本、文件与选择器,把改写约束在指定范围
  • 通过 harmony.patch.yml 把这个 Patch 注入到 harmony 钩子,无需手动启停
  • 通过浏览器端的 window.__ModuleLoader__.load 把自己实现的 CustomBrand 导出注册到运行时模块加载器,供 Patch 替换时引用
  • 服务端 apply() 为空操作,组件真正渲染逻辑全部在客户端执行

技术实现

  • 语言: TypeScript(服务端 CommonJS,浏览器端 ESNext)
  • 关键依赖: dsh-harmony-react(element 工厂)、react(浏览器端组件渲染)
  • 架构模式: 双形态插件 —— 服务端通过 harmony.patch.yml 把 example-rebrand 注册到 harmony 钩子;浏览器端用 window.__ModuleLoader__.load 注册 CustomBrand 组件;服务端 apply() 为空,所有改写由 Harmony 运行时在模块加载前完成
  • 入口文件: src/index.cts(服务端入口)、src/patch.cts(Patch 定义)、src/client.ts(浏览器端组件注册)

适用场景

适合正在学习 dsh-harmony 的插件作者:当你需要写一个会替换 DSH WebUI 中某个 React 组件的插件时,可以参考这个示例把 element() 工厂、harmony.patch.yml 注入和客户端 Component 注册串起来。它本身只是教学示例,并不提供实际业务功能,普通用户通常不会直接装它。

前置依赖与兼容性

依赖最低版本说明
@deepseek-ai/dsh0.1.0-rc.8+示例所在的子目录依赖 dsh-harmony 框架;patch 目标包版本声明为 0.1.0-rc.8(src/patch.cts:6-9)
Node.js^22.22.3 或 >=24.11.1来自父项目 dsh-harmony 的 engines 字段,子目录 package.json 未单独声明
运行平台Webpackage.json#dsh.client.platform 显式声明为 web,仅在 DSH WebUI 中生效(package.json:14-18)
原生模块无不依赖 node-pty、node:sqlite、node-gyp 等

安装方式

dsh plugin --profile web add github:CH4ACKO3/dsh-harmony/packages/react/examples/rebrand-plugin

配置项

配置类型说明默认值
Patch 目标包harmony.patch.yml 字段把 example-rebrand 注入到 harmony 钩子,使 Patch 在启动时被加载注入 harmony
客户端立即加载package.json#dsh.client设为 true 时 WebUI 启动立即加载该插件的客户端入口立即加载
客户端平台package.json#dsh.client.platform仅在 web 平台加载客户端代码web
目标包与版本src/patch.cts 的 target被改写的 DSH UI 包,固定为 @deepseek-ai/[email protected]0.1.0-rc.8
替换的选择器src/patch.cts 的 select匹配要替换的 React 组件名(BrandWordmark)BrandWordmark
期望匹配数src/patch.cts 的 expect选择器应命中目标的次数,偏离则 Patch 标记为 failed1

常见问题

Q: 安装后侧边栏的品牌字标没有变化,是没生效吗?

A: 大概率是 DSH 没重启。Harmony 改写发生在模块加载前,安装或更新后必须重启 DSH,新组件才会生效;可以打开 WebUI 的"设置 → Harmony"页确认该 Patch 处于 enabled 且未 failed。

Q: 这个插件能用来做实际的换肤、换标识吗?

A: 它本身只渲染一行 "Custom DSH" 文字,不直接用于生产。实际使用时需要把 src/client.ts 里 CustomBrand 的内容换成你想要的 React 组件(文字、Logo SVG、图标等),并修改 src/patch.cts 中的 id 与 module/export,让 Patch 指向你自己的导出。

Q: 目标包升级后这个示例会失效吗?

A: 会。Patch 把目标版本钉在 0.1.0-rc.8,当宿主里 dsh-client-ui-sidebar 升级到该范围之外的版本时,Patch 会进入 failed 状态并不再改写,但不会阻塞 DSH 启动。

Q: 卸载它能恢复原来的侧边栏吗?

A: 可以。Harmony 只在内存中改写编译产物,不会修改 node_modules;移除插件后下次启动 DSH,侧边栏就会恢复成内置 BrandWordmark。

Q: 这个示例支持哪些平台?

A: 仅 Web。package.json#dsh.client.platform 显式声明为 web,所以这个 Patch 只会在 DSH WebUI 启动时被加载,桌面端、纯 CLI 等场景不会生效。

Q: 装上它会不会影响其它 dsh-harmony 插件?

A: 不会。这个示例只针对 BrandWordmark 组件做替换,没有声明与其它 Patch 的 before/after 约束;只要不与别的 Patch 同时改写同一个组件,互不干扰。

上手难度

入门 — 整个示例只有三个源文件、几十行代码,主要作用是教学;想换成自己的组件只需要改 src/client.ts 的 CustomBrand 即可。

已知问题与限制

  • 目标包版本被硬编码到 0.1.0-rc.8:当 @deepseek-ai/dsh-client-ui-sidebar 升级到该范围之外的版本时,Patch 会进入 failed 状态并停止改写(src/patch.cts:6-9)。
  • 仅作为教学示例:CustomBrand 只渲染一行 "Custom DSH" 文字,无实际业务功能,直接安装等同于换上一个占位品牌字标(src/client.ts:7-9)。
  • 仅 web 平台生效:package.json#dsh.client.platform 声明为 web,桌面端与纯 CLI 场景不会加载该 Patch(package.json:14-18)。

Read the usage guide →

Install steps, key points, FAQ and compatibility for this plugin — auto-derived from indexed fields.

Listing badge

Listed on deepseek-plugin.org
[![Listed on deepseek-plugin.org](https://img.shields.io/badge/listed_on-deepseek--plugin.org-007EC6)](https://deepseek-plugin.org/plugins/CH4ACKO3/dsh-harmony/packages/react/examples/rebrand-plugin)

Paste this markdown into your GitHub README to link back to this listing. The badge only states the listing — not a security endorsement.

← Back to plugin directory