dsh-sansheng-liubu/docs/verification/00-baseline.md

111 lines
8.0 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.

# WP0 基线、接口与发布路线
日期:2026-11-13(Asia/Shanghai)
状态:实施前核对记录。后续验证结果按测试 ID 写入本目录其他文件。
## 1. 仓库基线
| 项 | 值 |
| --- | --- |
| 仓库 | `C:\Users\qyh15\三省六部` |
| 分支 | `feat/dsbot` |
| 基准提交 | `3f20f89`(工作树在开工时仅多出交接方案文档) |
| 远端 | `origin https://git.qyhhh.top/newbie/dsh-sansheng-liubu.git` |
| 根工作区 | `workspaces: ["sansheng", "ds-bot"]`,根 `package.json` 不是 DSH 插件 |
| 治理包 | `sansheng/` = `dsh-sansheng-sansheng@0.2.6`(本次发布候选) |
| 团队底座 | `ds-bot/` = `ds-bot@0.3.2-sansheng.6`(上游 `Fei2411/DS-Bot@84c3cb8` + 本地 M-01–M-06) |
| Node | v24.21.0(DSH 随附 `~/.dsh/dsh-runtimes/dsh-primary-runtime/dependencies/node/bin/node.exe`) |
| 桌面宿主 | DeepSeek Harness 0.2.2-rc.3(`resources/runtime/primary-runtime/runtime.json`) |
| 基线测试 | `node --test --test-isolation=none sansheng/test/*.test.js` → 56/56 通过(2026-11-13) |
## 2. 已安装对象(只读核对,不修改)
读取位置:`%USERPROFILE%\.dsh\profiles\desktop`。
| 对象 | 已安装版本 | 状态 |
| --- | --- | --- |
| `dsh-sansheng-liubu-mode` | 0.14.0 | 旧十席工作台,仍在 `dsh.profile.bundles` |
| `workspace-groups-remote` | 1.3.0 | 当前项目树插件,仍在 bundles |
| `dsh-better-sidebar` | 0.32.1 | 右栏页签接入 |
| `dsh-better-chat` | git 源 | 聊天插件,纳入布局回归观察 |
| `ds-bot` | 本仓库 junction(`C:\Users\qyh15\三省六部\ds-bot`) | node_modules 中存在,但 **不在** `dsh.profile.bundles` |
| `dsh-sansheng-sansheng` | 未安装 | 本仓库治理包尚未挂进 desktop profile |
结论:当前桌面运行的是旧十席工作台,不是本仓库新方案。实施只改仓库,不修改 daily profile、node_modules 或代装升级;真实宿主端到端验收需另建测试环境,缺环境时交付候选版本并明确标注。
## 3. 接口契约(只读核对)
来源:本机插件源码、`docs/p0/*.md`、archive-manager / workspace-groups-remote 的客户端实现。所有接口均在运行时用 `ctx.get(name, false)` 或 `ctx.<service>` 探测,不做私有 DOM 操作。
### 3.1 工具拦截与观察
| 能力 | 契约 | 用途 |
| --- | --- | --- |
| `ctx.tools.guard(fn)` | 同步;`fn(exec) => string \| undefined`。返回字符串即拒绝,工具体不执行,模型收到 `isError:true`。根 ctx 注册对 Bot 群 Session 生效。 | `group_goal` 门禁 |
| `ctx.on('tools/execute', (exec, next) => ...)` | 包裹工具执行;`next()` 返回原生结果。 | 派发记录、返工观测 |
| `exec.agent.id` | 执行会话 id。经 DS Bot `state.json` 反查 `chatOwners/groupOwners` 得到 Bot 与群。 | 身份判定 |
| `rt.isBotSession(sessionId)` | DS Bot 运行时判断某会话是否 Bot 会话。`ctx.get('dsbot-runtime')` 获得(M-01)。 | 区分用户会话 / Bot 会话 / 未知过期身份 |
### 3.2 项目树(workspace-groups-remote 1.3.0)
- 项目树注册在 `sidebar.workspaces`;项目 = 宿主 workspace,会话挂在其下。
- 没有第三方可用的"项目行动作"槽位;项目/文件夹行菜单是插件内部实现。
- 宿主的 **原生上下文菜单服务** `contextMenus.register({ id, target, order, observe, resolve })` 可用(archive-manager 同款):`target: "workspace"` 的 `resolve({ workspaceId, path, displayTitle })` 返回菜单项数组 `{ id, label, icon, run, disabled, separatorBefore }`;`target: "session"` 的 `resolve({ sessionId, displayTitle })` 同构。该服务在 `ctx.get('contextMenus')` 或 `ctx.contextMenus`。
- 当前项目推导:`workspaces.list.getSnapshot().items[]` + `sessions.list.getSnapshot().byId`。当前会话取 `retainedBy.mainView > 0` 的唯一会话(旧工作台 0.14.0 已验证的宿主等价事实),再按 `item.sessionIds.includes(sessionId)` 得 `workspaceId`。无明确选择时返回 null,不拿第一个项目冒充。
### 3.3 会话与右栏
| 能力 | 契约 | 用途 |
| --- | --- | --- |
| `ctx.uiWorkspace.openSession(sessionId)` | 打开会话页签;失败时退回 `uiWorkspace.selection.set({ sessionId })` | 点击角色打开真实会话 |
| `ctx.uiWorkspace.startSession(workspaceId)` | 在空工作区创建并打开会话(旧工作台使用的宿主动作);不存在时给出可读错误 | 项目树入口在无会话项目上打开工作台 |
| `ctx.sidebarRightTabs.register({ id, kind, priority, title, keepMounted })` | 注册右栏页签 | 「三省六部」页签 |
| `ctx.slots.register({ name: 'sidebar.right.pane.tab', key }, Component)` | 页签内容 | 三卡与配置 |
| `ctx.slots.register({ name: 'sidebar.right.pane.tab.title', key }, Component)` | 页签标题 | 角标 |
| `ctx.slots.register({ name: 'conversation.session.header.actions', id, order }, Component)` | 会话头按钮 | 「三省」快捷入口 |
| `ctx.get('sidebarRight')` / `ctx.get('betterSidebar')` | 旧版右栏打开接口;`openTabIn(sessionId, kind)` / `openTab({type})` | 兼容回退,不虚报成功 |
### 3.4 DS Bot 运行时(团队底座)
- 运行时暴露:`ctx.provide('dsbot-runtime', rt)`(M-01),只读状态文件 `$DSH_HOME/bot/state.json`。
- 可复用钩子:`createBot/updateBot/deleteBot/createRoom/updateRoom/deleteRoom/applyModel/updateBot/resolveModel`、`deliver`、`goalControl`、`findBot/findRooms/isAdminOf/isMain/selfOf/isBotSession`、`roomOf/roomOfSession`。
- `group_goal` 业务拒绝以普通字符串返回,`isError` 不置位;因此派发结果必须结合目标 revision/id 前后快照判定,不能靠英文错误前缀。
- 记忆作用域:`own`(每 Bot)、`group`(每群)、`team`(所有 Bot 共享)。Team 作用域是跨项目泄漏点,需治理服务按项目拒绝读写。
### 3.5 治理服务(本仓库新增,供 ds-bot 补丁调用)
`sansheng` 启动时 `ctx.provide('sansheng-governance', api)`(若宿主支持):
```js
api = {
version: 3,
projectOfBot(botId) -> { id, name } | undefined,
projectOfRoom(roomId) -> { id, name } | undefined,
checkDelivery({ fromId, toId, roomId }) -> { allow: boolean, reason?: string },
checkMemoryScope({ botId, scope: 'own'|'group'|'team', roomId }) -> { allow: boolean, reason?: string },
}
```
ds-bot 侧只在服务存在时执行检查;不存在时保持上游行为。补丁写入 `ds-bot/PATCHES.md`。
## 4. 数据兼容
- `sansheng` 状态文件默认 `$DSH_HOME/sansheng/state.json`。v2 → v3 迁移:保留 `projects/reviews/dispatches/reworks/events`,新增 `artifacts/leases/seq`;旧字段 `digest` 继续作为 `reviewSubjectDigest` 的别名读取。迁移只补字段,不改写历史记录,不删除旧项目。
- 旧十席工作台数据(`dsh-sansheng-liubu-mode`)与 DS Bot 的 `state.json` 均不迁移、不写入。旧工作台退出方案仅文档说明:升级顺序为先停旧包再启用新包,避免同时注册入口。
- 旧 `ds-bot` 状态文件只读;所有项目绑定保存在 `sansheng` 自己的文件。
## 5. 发布路线
1. 仓库分支 `feat/dsbot` 提交 WP0–WP7 变更;按工作包分提交,每个提交附问题、实现、测试与限制。
2. 推送至 `origin/feat/dsbot`;用 Gitea PR 审查合并(不按历史 URL 擅自推送其他仓库)。
3. 产出两个可安装包的 tarball:`dsh-sansheng-sansheng-<version>.tgz` 与 `ds-bot-<version>.tgz`,附 `docs/verification/` 证据与升级说明。
4. 用户自行决定是否更新日常 desktop profile;本次不代装、不重启用户应用。
## 6. WP0 退出条件核对
- [x] 唯一实现:`sansheng + ds-bot` 三角色方案;旧十席工作台仅历史参考。
- [x] 可构建发布包:两个子包均为 ESM,Node 24 可运行,测试命令已确认。
- [x] 项目树入口无公开项目动作 API → 采用宿主原生 `contextMenus` workspace/session 菜单 + 右栏页签;不使用私有 DOM。
- [x] 不依赖直接修改宿主才能成立的功能;ds-bot 必要补丁均记录在 PATCHES。
- [x] 旧数据保留策略明确,无自动迁移。