dsh-plugin-toggle:DSH Web 插件開關面板

前言

在 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

分組可以摺疊。

排序

在同一分組內,排序順序是:

  1. togglable plugins first
  2. 按狀態排序,running first
  3. 按名稱排序

搜索

fuzzy search 會跨多個字段匹配,包括 category。token 可以是 substring 或 subsequence。

運行時 Start / Stop

Start / Stop 調用的是:

entry.update({ disabled })

這是運行時操作,不做 tree.write(),不會重寫 cordis.yml

Core / surface 插件,例如 webserverconnectionsessionagent 等,會標記爲 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: >=20
  • dsh.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.6
  • react ^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
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

小夜