前言¶
在 DSH 的 Web 界面里,插件通常由 profile 和 bundle 装配而成。加载的插件越多,逐个确认某个插件是否启用、是否处于 running 状态就越不方便。
dsh-plugin-toggle 是一个社区维护的 DSH 插件,给 Settings → Plugins 增加一个 Plugin Switch 页面:列出已加载插件的 package.json description、启用状态和 fiber phase,并提供 fuzzy search 与运行时 Start / Stop。它不重写配置文件,适合先观察、再调整插件状态。
这是什么¶
dsh-plugin-toggle 的仓库名是 DamonKoy/dsh-plugin-toggle,维护者是 DamonKoy,许可证为 MIT。
它把已加载的 DSH 插件做成卡片,放在 Web 设置的 Plugins 选项卡里。可以搜索、分组查看、运行时启停,并把每次启停记录到本地 JSONL 文件。
核心功能¶
插件卡片¶
每张插件卡片包含:
- 标题
- entry id
- description
- enabled tag
- phase
其中 description 来自该插件自己的 package.json。
分组¶
插件按以下类别分组:
- core
- UI
- theme
- tools
- fun
- other
分组可以折叠。
排序¶
在同一分组内,排序顺序是:
- togglable plugins first
- 按状态排序,running first
- 按名称排序
搜索¶
fuzzy search 会跨多个字段匹配,包括 category。token 可以是 substring 或 subsequence。
运行时 Start / Stop¶
Start / Stop 调用的是:
entry.update({ disabled })
这是运行时操作,不做 tree.write(),不会重写 cordis.yml。
Core / surface 插件,例如 webserver、connection、session、agent 等,会标记为 Core,不能从该页面停止。其他插件停止时需要两步确认。
使用记录¶
每次 toggle 都会持久化到:
~/.dsh/dsh-plugin-toggle.jsonl
文件保留最近 1000 条记录,并在页面里显示为可折叠的“使用记录”。
持久性¶
该插件以 composition plugin 方式安装,dsh web 重启后仍会保留。
安装与启用¶
方式一:通过 dsh plugin 添加¶
执行:
dsh plugin --profile web add github:DamonKoy/dsh-plugin-toggle
然后重启 dsh web,打开:
Settings → Plugins → Plugin Switch
方式二:作为 profile 依赖添加¶
把仓库加入 profile 依赖,并 include 对应 bundle:
{
"dependencies": {
"dsh-plugin-toggle": "github:DamonKoy/dsh-plugin-toggle"
},
"dsh": {
"profile": {
"bundles": ["dsh-plugin-toggle"]
}
}
}
然后在 profile 目录执行:
pnpm install
再重启 dsh web。
环境与依赖¶
已核实的运行要求如下:
engines.node:>=20dsh.client.platform:web
peer dependencies 包括:
@deepseek-ai/cordis ^4.0.1@deepseek-ai/dsh-client-runtime ^0.1.0-rc.6@deepseek-ai/dsh-host-webserver ^0.1.0-rc.6react ^18.2.0
典型用法¶
1、安装插件并重启 dsh web。
2、打开:
Settings → Plugins → Plugin Switch
3、在搜索框输入插件名、模块、id 或描述片段,过滤目标插件。
4、查看卡片上的 enabled tag 和 phase,确认当前状态。
5、对非 Core 插件点击 Start / Stop;非 Core 插件会有两步确认。
6、打开“使用记录”,查看最近操作。
7、如需程序化访问,可调用同域 HTTP API。
HTTP API¶
该插件暴露 same-origin HTTP API。
查询插件列表¶
GET /plugin-toggle/list
返回:
{
"entries": []
}
查询使用记录¶
GET /plugin-toggle/logs
返回:
{
"records": []
}
记录按 newest first 排列。
设置启用状态¶
POST /plugin-toggle/set
请求体:
{
"entryId": "",
"enabled": true
}
返回:
{
"ok": true
}
或:
{
"message": ""
}
该 POST 请求仅限 same-origin。
注意事项¶
- 该插件会读取已加载插件信息,并提供运行时启停;它会以当前
dsh进程权限运行。安装前建议检查源码与许可证。 - Start / Stop 只影响运行时,不会修改
cordis.yml。 - Core / surface 插件不能通过该页面停止,避免页面自身依赖被停掉。
POST /plugin-toggle/set仅限 same-origin。- 客户端注入配置中,
exports.inject使用的是 service 名slots,不是 package 名;如果在这里使用 package 名,client fiber 会永久挂起。
参考¶
项目源码、issues 和许可证可以查看 GitHub 仓库:
- GitHub: https://github.com/DamonKoy/dsh-plugin-toggle