dsh-plugin-discourse:让 DSH 智能体通过 REST API 管理 Discourse 论坛

前言

在 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 描述了可复现的调用链,可按下面顺序让智能体操作:

  1. 只读巡检:配置 readOnly: true 与 baseUrl 后,用 discourse_categories 拿分类 id,再用 discourse_topics(如 latest)或 discourse_search 找话题,最后用 discourse_topic 读正文片段。
  2. 发帖与互动:配置有效 apiKey 与 apiUsername(或通过 discourse_login 完成浏览器授权后使用会话),依次 discourse_create_topic、discourse_reply;改文用 discourse_update_post,社区反馈用 discourse_flag_post。
  3. 版主/管理员:在对应 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
羽毛球分组比赛记分
小程序二维码

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

Xiaoye