前言¶
在 DeepSeek Harness(DSH)裏接 Discourse,常見做法是手寫 REST 調用、自己拼鑑權,再讓模型在對話裏「記住」話題 id、版主權限邊界。一旦要搜帖、讀串、發帖、審 flagged 隊列或改站點設置,上下文還容易因長帖被撐爆。
dsh-plugin-discourse 把上述能力收成 Host 側一組模型工具,走 Discourse REST API,並支持瀏覽器 scoped User API Key 登錄。下面按定位、工具清單、安裝、配置與注意點說明用法。
這是什麼¶
dsh-plugin-discourse 是維護者 AkarinLiu 發佈的 DSH bundle 插件(npm 包名 dsh-plugin-discourse,當前資料版本 1.1.0,MIT 許可,要求 Node >=20)。在社區目錄 SkillHub 中歸類爲聯網工具。
插件在一個 Host 裏註冊 17 個面向模型的 discourse_* 工具。數據路徑可概括爲:
User → DSH agent → discourse_* tools → Discourse REST API → forum
智能體可以搜索論壇、讀話題與用戶資料、發帖與回覆,並在具備相應賬號權限時執行版主、管理員在 Web 後臺能做的操作;還可以通過用戶瀏覽器完成 scoped User API Key 授權。
核心功能:17 個工具¶
README 按能力分組。下表概括各工具職責及是否需要 API Key(或更高角色)。列表與翻頁結果默認有上限(默認 12 條、最多 50 條),帖子正文會裁剪,避免檢索灌滿模型上下文;返回保留 id,便於後續 discourse_topic 等讀詳情。
| Tool | 分組 | 作用 | Key / 角色 |
|---|---|---|---|
discourse_login |
auth | 瀏覽器授權、會話上報、處理歷史 payload、取消待授權、登出 | 否 |
discourse_search |
read | 搜索話題、帖子、用戶 | 否 |
discourse_topics |
read | 列出 latest/new/unread/top 或某一分類 |
否 |
discourse_topic |
read | 讀單個話題及帖子片段 | 否 |
discourse_categories |
read | 列出分類與子分類及 id | 否 |
discourse_user |
read | 讀用戶資料(角色、信任等級、活動計數等) | 否 |
discourse_create_topic |
author | 在指定分類與標籤下建話題 | 是 |
discourse_reply |
author | 回覆話題,可指定回覆某帖 | 是 |
discourse_update_post |
author | 替換帖子正文 | 是 |
discourse_flag_post |
author | 標記 spam / 不當 / 跑題等 | 是 |
discourse_review_queue |
moderate | 列出待審 flagged 項 | moderator |
discourse_delete_post |
moderate | 刪除或永久銷燬帖子 | moderator |
discourse_restore_post |
moderate | 恢復已刪帖 | moderator |
discourse_admin_users |
admin | 按狀態與排序搜索用戶目錄 | admin |
discourse_moderate_user |
admin | 封禁、禁言、解除處罰、激活賬號等 | admin |
discourse_site_settings |
admin | 讀取或按名稱修改站點設置 | admin |
discourse_admin_stats |
admin | 以時間序列讀取儀表盤報表 | admin |
插件爲 Host-only:無需構建步驟、無額外依賴、無客戶端資源。
安裝與啓用¶
bundle 插件安裝到某一個 DSH profile,並在該 profile 的 bundle 列表中選中。官方推薦優先用 Web UI:DSH 的 bundle 安裝器會在寫入包之前替換已有拷貝或本地鏈接;CLI 側則是較薄的 pnpm 封裝。
1、Web UI(推薦)¶
打開 Settings → Plugins → Install bundle,任選一種標識安裝:
- npm 包名:
dsh-plugin-discourse - GitHub 引用:
github:AkarinLiu/dsh-plugin-discourse - 或本地目錄路徑(開發與調試場景)
安裝後 DSH 會裝入包、加入 profile 的 bundle 列表並激活。
2、CLI(npm)¶
launcher 會把 plugin 之後的參數交給 pnpm,因此這是普通 pnpm 安裝,而非 Web UI 那套 bundle 安裝器邏輯:
dsh plugin --profile desktop add dsh-plugin-discourse
CLI 安裝完成後,仍需在 Plugins 頁面(或通過 plugin_manager 工具)選中一次 dsh-plugin-discourse,profile 纔會把它記爲 bundle。
3、移除¶
在 Plugins 頁面卸載該 bundle,會同時去掉依賴與 bundle 條目。
替換或升級包後,建議重啓 Harness,以便新的模塊生成加載。
Windows:本地鏈接換 npm 包時的 EPERM¶
若曾用本地目錄安裝,node_modules\dsh-plugin-discourse 可能是目錄聯接(junction)。部分情況下後續 npm 安裝無法替換聯接,會出現 EPERM: operation not permitted, rename ...。可按倉庫自帶 doctor 修復後重裝:
node scripts/doctor.mjs --profile desktop --fix
dsh plugin --profile desktop add dsh-plugin-discourse
亦可按 README 所示手動刪除 junction 後重試。上述 doctor 腳本來自插件倉庫發佈內容,需在已安裝或解壓的包目錄中執行。
配置論壇地址與鑑權¶
默認寫在插件自帶的 cordis.patch.yml(作爲 bundle 層由 DSH 應用)。要把工具指向你的站點,在當前 profile 的 cordis.patch.yml(路徑:$DSH_HOME/profiles/<name>/cordis.patch.yml)中增加覆蓋。loader 覆蓋會整段替換該行的 config,因此要保留的鍵需全部寫回。
示例(將 baseUrl 換成你的論壇):
- id: discourse
name: dsh-plugin-discourse
config:
baseUrl: https://forum.example.com
apiKey: ''
apiUsername: ''
readOnly: true
timeoutMs: 20000
maxItems: 12
authMode: auto
loginScopes: read,write,session_info
loginClientId: dsh-plugin-discourse
loginApplicationName: DeepSeek Harness
loginTimeoutMs: 600000
要點(與 README 表一致的部分):
baseUrl:Discourse 站點根 URL。apiKey/apiUsername:Discourse User API Key 與對應用戶名;寫操作及版主/管理員工具通常需要有效 Key。readOnly: true:適合先只讀驗證搜索與讀帖,再改爲可寫。maxItems:與工具側列表上限一致(默認 12)。authMode、loginScopes等:配合discourse_login做瀏覽器 scoped 授權。
未在資料中完整列出的其他配置鍵,以 GitHub README 的 Configure 章節 爲準。
典型用法(對話側流程)¶
資料未給出固定 prompt 模板,但 README 描述了可復現的調用鏈,可按下面順序讓智能體操作:
- 只讀巡檢:配置
readOnly: true與baseUrl後,用discourse_categories拿分類 id,再用discourse_topics(如latest)或discourse_search找話題,最後用discourse_topic讀正文片段。 - 發帖與互動:配置有效
apiKey與apiUsername(或通過discourse_login完成瀏覽器授權後使用會話),依次discourse_create_topic、discourse_reply;改文用discourse_update_post,社區反饋用discourse_flag_post。 - 版主/管理員:在對應 Discourse 賬號具備 moderator / admin 權限時,使用
discourse_review_queue、discourse_delete_post/discourse_restore_post,或discourse_moderate_user、discourse_site_settings、discourse_admin_stats等。
每一步依賴上一步返回的 id,與插件「結果帶 id、正文裁剪」的設計一致。
適用場景與注意¶
適合誰:需要把 Discourse 納入 DSH 工作流的人——例如論壇運維、社區值班、在Harness 裏做站內檢索與合規處理的智能體作者。社區目錄將其放在聯網工具類,強調的是對外部論壇 API 的訪問,而非本地文件或單機工具。
權限與安全:
- 工具以當前 DSH 進程所配置的 Key、登錄會話與 Discourse 賬號權限執行;管理員類工具等同於在後臺操作用戶與站點設置,安裝前應閱讀 源碼與許可證(MIT),並只在受信環境配置
apiKey。 - 先用
readOnly: true與只讀工具驗證連通性,再開放寫操作與版主能力。 - SkillHub 等社區目錄與 DeepSeek / 幻方無官方從屬關係;DSH 生態原則是「一切皆插件」,本文介紹的是社區維護的 bundle,而非官方應用商店條目。
結尾¶
dsh-plugin-discourse 把 Discourse 的讀、寫、審覈與站點管理收成 17 個 Host 工具,並限制列表與正文長度,便於在智能體對話裏穩定調用 REST API。安裝可走 Web UI bundle 安裝器或 dsh plugin --profile <name> add dsh-plugin-discourse,論壇地址與鑑權在 profile 的 cordis.patch.yml 中覆蓋。
- 目錄頁:https://www.skillhub.cn/plugins/AkarinLiu/dsh-plugin-discourse
- 源碼與文檔:https://github.com/AkarinLiu/dsh-plugin-discourse