Skip to main content
F

dsh-rea-switch

frf373/dsh-rea-switch

Adds an on/off switch for the REA MCP server to the DSH settings page by reading and writing the disabled line of the rea-mcp entry in the home-level $DSH_HOME/cordis.patch.yml, the layer DSH applies last and which the plugins-page toggle cannot override; it also restores a missing disabled line on startup with a timestamped backup. Its HTTP routes have no DSH access check, so a web page open in your browser could call them.

Install

dsh plugin --profile web add github:frf373/dsh-rea-switch

README

dsh-rea-switch

在 DSH 设置页开关 REA MCP(逆向工程工具集,229 个工具)。

为什么需要它

REA 由 rea setup --client dsh 写进 home 级补丁 $DSH_HOME/cordis.patch.yml (~/.dsh/cordis.patch.yml)。而补丁的应用顺序是:

bundle 层  →  profile 的 cordis.patch.yml  →  home 级 cordis.patch.yml(最后,优先级最高)

home 层最后应用,所以 GUI 插件页的启用/禁用按钮对 REA 无效 —— 它写的是 profile 层,会被 home 层压掉,DSH 会回一句 a higher-priority layer such as the agent preset overrides it。

另外 REA 官方写入的条目里没有 disabled 字段(DshCordisPatch 里甚至有 entry.delete("disabled"),因为它把 disabled: true 当作"配置损坏")。所以 想关掉 REA,必须自己往那条目里补一行 disabled: true —— 这就是本插件做自愈的原因。

装完发生什么

  1. 启动自愈:插件 apply() 时检查 home 补丁。找到 - id: rea-mcp 但没有 disabled 行,就补一行 disabled: true(写前留 .bak-<时间戳> 备份)。 → 装完插件,REA 默认就是关的。
  2. 设置页入口:设置 → 「REA 开关」,一个大开关 + 状态徽标 + 详细信息 (配置文件路径、disabled 行号与值、启动自愈结果、Host 侧错误记录)。
  3. 打开开关写 disabled: false,关掉写 disabled: true。DSH 监听这份文件, 几秒内热重载,不用重启。

条目完全不存在时(没装 REA),插件只报告 no-entry,不会替你创建 —— 完整的 REA config 含 rea-agents 路径与 Ghidra/JDK/IDA 等环境变量,各机器不同, 猜一个插进去只会得到一个起不来的条目。

界面

设置 → 「REA 开关」:

REA 开关:已启用

关掉之后:

REA 开关:已关闭

安装

本包就是一个标准的 DSH 组合包(dsh.bundle.patch 声明补丁层),安装走 DSH 官方的插件安装通道,没有任何安装脚本,不需要你授权在本机执行安装期代码。

方式一:插件页(DSH Desktop / GUI)

  1. 打开 DSH → 设置 → 插件,点安装入口(按钮可能是「安装」「添加插件」或列表旁的 +)。
  2. 填包的来源,任选其一:
    • npm 包名:dsh-rea-switch
    • tarball 路径:./dsh-rea-switch-0.1.0.tgz(npm pack 的产物)
    • GitHub 仓库:github:frf373/dsh-rea-switch
  3. 安装后回到「插件」列表,确认出现 dsh-rea-switch;插件改动 profile 的 cordis.patch.yml 并热重载,DSH 会提示重新加载窗口。

方式二:命令行(装了 dsh CLI 时)

# 用 npm 上发布的包
dsh plugin --profile <你的 profile> add dsh-rea-switch

# 或直接吃本地 tarball
npm pack
dsh plugin --profile <你的 profile> add ./dsh-rea-switch-0.1.0.tgz

add 会把依赖写进目标 profile 的 package.json,并把本包注册成一个 bundle 层 (--dump-config 里会看到 # == dsh-rea-switch 这一段)。卸载: dsh plugin --profile <name> remove dsh-rea-switch。

方式三:会话里的 agent 工具

在 DSH 会话里直接说「装这个插件」,或让 agent 调:

plugin_manager({ action: "install_bundle", target: "dsh-rea-switch" })

target 可以是包名、tarball 路径或 github:owner/repo。

从源码装(GitHub)

github:frf373/dsh-rea-switch 拉的是源码,本包不含构建步骤(lib/ 直接是成品 CJS),所以不涉及 pnpm 的 allowBuilds 授权。想固定版本就锁 commit: github:frf373/dsh-rea-switch#<sha>。

注意

别在注册了 REA 的 DSH 上跑 rea setup。 实测 rea setup --client dsh --yes 会把条目里的 disabled: 字段整个删掉(DshCordisPatch.js:283 的 entry.delete("disabled")),REA 会重新变成开启状态。同理 rea doctor 报 registration:dsh → config_drift/stale 是误报,可以忽略。

结构

package.json        dsh.bundle.patch + dsh.client.inject 声明,engines.dsh 版本范围
cordis.patch.yml    - insert: - id: dsh-rea-switch / name: dsh-rea-switch
lib/index.js        Host:定位 home 补丁、行级读写 disabled、webServer 路由、启动自愈
lib/client.js       Client:settings.section + settings.section.icon slot 注册、面板 UI
screenshots.json    截图清单(assets/panel-on.png、panel-off.png)

本仓只包含运行插件所需的文件,不含离线验证脚本(它们依赖开发机上的真实 DSH 安装产物,对 clone 下来的人没有意义)。

两条路由(只接受 loopback):

方法路径作用
GET/plugins/dsh-rea-switch/status返回当前状态快照
POST/plugins/dsh-rea-switch/setbody {"enabled": true|false},写回补丁

Related plugins