Skip to content
dsh.fish
Bundle

dsh-better-plan-reviewer

DSH web plugin: takes over the plan review card and adds an execution-model selector at its bottom — pick which model will carry out the plan; on approve the plugin switches the session model first, then answers the review so execution runs on the chosen model.

Source
Khellendros97
License
MIT
Updated
Updated 7 days ago

Readme

# dsh-better-plan-reviewer

改装 DSH 的 **plan 审查界面**:把贴在底部的黄色审查卡片换成**悬浮对话框**(居中 + 遮罩),标题用**蓝色**,并在底部提供**执行模型 + 思考强度**选择;点「确认执行」时插件**先切换模型、再批准计划**,然后自动发送「开始执行」让计划用新模型跑起来。还提供「暂存计划」按钮,把计划存档到 `项目/.dsh/plans/` 方便开新会话执行。

## 功能

- **悬浮对话框**:`position:fixed` 居中遮罩,不再贴着底部;标题条为蓝色(`--dsw-static-deepseek-500`),不再是黄色 warn 风格。
- **执行模型选择器**:卡片底部,样式复用 [dsh-better-model-selector](https://github.com/Khellendros97/dsh-better-model-selector) 的下拉样式(搜索 + 分组列表),默认当前会话模型。
- **思考强度选择器**:当前选中的模型公布推理等级(reasoning efforts)时显示滑动条(复用 dms 样式),切换模型时随模型默认等级重置。
- **先切换后执行**:点「确认执行」→ 若模型/强度有变化,先 `await` 模型切换 RPC(失败则不执行、显示错误)→ 再批准计划 → 自动发送一条「开始执行」消息继续对话(仅在有切换时发送)。
- **暂存计划**:把计划 markdown 写入 `<会话 cwd>/.dsh/plans/plan-<日期时间>.md`(走插件 host 半的 `/plan-reviewer/save-plan` 路由,带 Host 头信任围栏),成功后显示落盘路径。

## 原理

DSH 的 plan 审查走 `conversation.composer` 这个 **chain slot**:内置 `@deepseek-ai/dsh-client-ui-user-questions` 在优先级 0 注册 `QuestionComposer`,`plan-review` 意图的问题渲染成审查卡片。本插件以**优先级 -1** 注册到同一条链,`select` 只认领 `plan-review` 形状的请求(与内置收窄规则逐条一致),普通问题流程仍落回内置组件。

- 模型/强度切换经 `ctx.modelDirectories`(`@deepseek-ai/dsh-client-ui-model-selection` 的会话级 `ModelDirectory`)读写,与 composer 模型选择器、`/model` 弹窗共享同一份状态。
- 「开始执行」经 `sessions.binding(sessionId).session.prompt([{type:'text',text}], 'queue')` 发送,等价于用户在输入框提交。
- 「暂存计划」经 `fetch('/plan-reviewer/save-plan')` 打到 host 半路由,host 侧用 `ctx.sessions.get(id).header.cwd` 取会话权威工作目录(不信任客户端路径),写入 `<cwd>/.dsh/plans/`。

## 安装

前置:DSH 已初始化 `web` profile(`dsh web` 能正常运行),Node.js ≥ 20。

> ⚠️ 依赖 DSH 的 `next` 通道:peerDependencies 指向 `@deepseek-ai/*` `^0.1.0-rc.6`。若你的 DSH 走 `latest`(`0.0.1-rc.x`),可能缺少 `modelDirectories` 等服务。

**npm 安装(推荐,自动挂载)**:

```sh
dsh plugin --profile web add dsh-better-plan-reviewer
```

装完**重启 dsh + 硬刷新浏览器**(Cmd/Ctrl+Shift+R)。若报 `minimum release age`(发布不足 24 小时),重跑一次即可。

**从源码安装(开发)**:把本目录拷贝/软链到 `~/.dsh/profiles/web/node_modules/dsh-better-plan-reviewer`,并在 `~/.dsh/profiles/web/cordis.patch.yml` 追加:

```yaml
- insert:
    - id: dsh-better-plan-reviewer
      name: dsh-better-plan-reviewer
```

然后重启 `dsh web` + 硬刷新。

> ⚠️ 本插件含 **host 半**(`/plan-reviewer/save-plan` 路由)。改 client 半后浏览器硬刷新即可;改 host 半后需要重启 `dsh web`。

## 结构

```
dsh-better-plan-reviewer/
├── package.json       # dsh.bundle.patch + dsh.client + exports["./client"]
├── cordis.patch.yml   # 自动挂载补丁(insert 条目)
├── lib/
│   ├── index.js       # host 半:/plan-reviewer/save-plan 路由(暂存计划)
│   └── client.js      # 浏览器半:悬浮审查卡片 + 模型/强度选择 + 先切换后执行 + 暂存
└── tests/
    └── smoke.mjs      # node 直跑测试(收窄 / 接线 / 注入面 / host 路由)
```

## 已知限制

- 已寻址子代理(subagent)会话不提供模型选择,执行模型栏隐藏。
- 下拉/滑动条样式是 dsh-better-model-selector 样式的内联副本(`bpr-` 前缀),不依赖该插件安装。
- 「暂存计划」只写文件、不批准计划;文件名用 host 本地时间 `plan-YYYYMMDD-HHmmss.md`,同秒冲突自动加 `-2`/`-3` 后缀。

Install

dsh plugin --profile web add github:Khellendros97/dsh-better-plan-reviewer

Profile: web

  • This source has no pinned commit, so a later push upstream changes what installs. Prefer pinning a commit.
Source