dsh-sansheng-liubu/ds-bot/PATCHES.md

59 lines
2.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 上游补丁记录
上游:`Fei2411/DS-Bot`,固定基线 `84c3cb86b997aec53281b842fd162f3f6b4ee7be`(= npm `ds-bot@0.3.2`)。
本目录是 npm 发布内容(`files` 白名单)加下述补丁,另附仓库根 `NOTICE`。
## M-01:向伴侣插件暴露运行时
```diff
export function apply(ctx, config = {}) {
- createRuntime(ctx, config)
+ const rt = createRuntime(ctx, config)
+ // sansheng M-01: expose the runtime so a companion plugin can create Bots, bind
+ // model settings, and read authoritative goal state. See PATCHES.md.
+ ctx.provide('dsbot-runtime', rt)
}
```
原因:`createRuntime` 的返回值原本直接丢弃,第三方插件无法创建 Bot、设置模型或
读取 `room.goal` 的权威状态。`ctx.provide` 是宿主 cordis 的公开服务注册 API
(`@deepseek-ai/cordis` `ctx.provide(name, value)`),不修改任何业务逻辑。
伴侣插件用法:
```js
const rt = ctx.get('dsbot-runtime', false) // 未安装打过补丁的 ds-bot 时为 undefined
```
影响面:只新增一个服务名 `dsbot-runtime`;不与上游已有服务冲突(全仓无同名)。
行为、工具、页面、状态文件均未改动。
## M-02:保留 DSH 原生设置页
```diff
- id: web
config:
searchProvider: auto
fetchProvider: http
-
-# DS Bot's settings shell holds the sidebar's settings seat ...
-- id: ui-settings-general
- disabled: true
```
原因:上游把 DSH 自己的设置页关掉,改由 DS Bot 的设置壳在 Bot 页面里绘制。
新装、还没有 Bot 时,侧栏就一个设置入口都没有,用户会以为设置页被删了。
本补丁保留宿主原生设置页;DS Bot 自己的设置仍可在其页面里使用。
## 升级步骤
1. 取新版本 npm tarball,解压覆盖本目录(保留本文件与 `NOTICE`)。
2. 重放 M-01;若上游已自行暴露运行时(例如 `ctx.set('dsbot', rt)`),删除本补丁
并同步修改 `sansheng/src/runtime.js` 的取用名。
3. 跑 `sansheng` 的单元测试与安装冒烟(见 `docs/install.md`)。
## 回退
删除本目录、改装 npm `ds-bot@0.3.2` 即可;三省六部在拿不到运行时句柄时仍可
`bind` 已存在的 Bot,只是不能自动建 Bot / 改模型(工具会返回明确错误)。