dsh-plugin-wepre

by shujitech

1 工作流与自动化github收录于 08-23

DeepSeek Harness 插件:把单屏内容卡片从 dsh agent 会话发布到 WePre Next

DeepSeek Harness plugin: publish single-screen content cards to WePre Next from a dsh agent session

安装

dsh plugin --profile web add github:shujitech/dsh-plugin-wepre

GitHub 源码安装:首次需按提示配置 allowBuilds 构建授权后重试

安装与环境配置指引、插件开发教程见 DSH 中文社区文档 ↗

安装即在你的机器上以你的权限运行第三方代码——它可读写文件、使用凭据、访问网络,DSH 的工具审批不会为插件代码加沙箱。「检测到 manifest」仅代表发现 dsh.bundle / dsh.plugin 清单,不构成兼容性或安全审查;安装前请审阅源码,不熟悉的插件先在不含密钥的环境试用。

README

目录

English | 中文

DeepSeek Harness(dsh)插件:让 agent 在对话中把单屏内容卡片直接发布到 WePre Next —— 一个在 AI 生成的等待时间向用户推送单屏离线卡片的平台。

装上这个插件后,一次对话就能走完「写卡片 → 发布上线」的全流程:

你:    做一张番茄钟卡片,发到 WePre
agent: <写 index.html,调用 wepre_publish>
agent: 质检门禁拦下了——390x600 视口 OVERFLOW_Y,我来修…… <改完重新发布>
agent: 已发布。contentId=cnt_xxx,版本 v1(质检:通过)

安装

dsh plugin --profile web add dsh-plugin-wepre

验证配置层已组合,然后启动:

dsh --profile web --dump-config   # 能看到 "# == dsh-plugin-wepre" 层
dsh --profile web

插件是纯 ESM JavaScript、无构建步骤,也支持直接从 git 安装:

dsh plugin --profile web add github:shujiTech/dsh-plugin-wepre

agent 获得的能力

注册到 ctx.tools 的五个模型可见工具:

工具 作用
wepre_request_code 发送登录验证码(短信 / 邮箱)
wepre_login 用验证码登录,会话 Cookie 持久化到本机
wepre_whoami 查询当前登录状态
wepre_publish 把 index.html / .zip 卡片通过服务端质检门禁发布上线
wepre_qa_report 查询某个内容的完整质检报告(各视口 issue)

工具描述里内置了 WePre 的内容规则(单屏布局、禁网络请求、禁外部资源、wepre-next:execute 消息约定)和质检修复闭环:门禁返回 QA_GATE_FAILED 时,agent 会逐条阅读结构化的分视口 issue、修复卡片、带同一个 contentId 重新发布——全程无需人工介入。

鉴权

wepre_publish / wepre_qa_report 按以下顺序取凭证:

  1. 配置项 token —— WePre 发布页签发的短时发布令牌
  2. WEPRE_PUBLISH_TOKEN 环境变量
  3. 持久化登录会话 —— 由 wepre_login 创建,写入 sessionFile(默认 ~/.dsh/wepre-session.json,权限 0600)

交互使用直接让 agent 登录即可:「用 13800138000 登录 WePre」——它会发验证码、向你要码、存好会话。CI / headless 场景(dsh --profile headless "…")请配置 token。

配置

在 profile 的 cordis.patch.yml 中覆盖插件行(patch 会整体替换该行的 config,保留的键要全部重写):

- id: wepre-publish
  name: dsh-plugin-wepre
  config:
    endpoint: 'https://wepre.cn/next-test'
    token: !!js process.env.WEPRE_PUBLISH_TOKEN
    sessionFile: '/home/me/.dsh/wepre-session.json'
键 默认值 含义
endpoint https://wepre.cn/next-test WePre Next 站点根
token — 短时发布令牌(Bearer)
sessionFile ~/.dsh/wepre-session.json 登录会话持久化文件

发布调用的细节

wepre_publish 对应 POST /next-test/api/next-contents(multipart)。参数:title、path(绝对路径,.html 或 .zip)、description、contentId(原地版本更新时传)、changeNote、versionLabel、downloadEnabled(默认 false),以及 manifest 字段 viewports(all/desktop/mobile)、interaction(execute/passive)、capabilities。

成功返回 contentId、versionId、versionNumber 和质检状态。遇到 QA_GATE_FAILED(HTTP 422)时返回结构化 issues 与 reportId(作为正常返回值而非异常),agent 可据此迭代修复。上传前工具还会本地预检 WePre 禁用字样(fetch、localStorage、Worker、overflow:auto 等)与外链,作为非阻断警告返回。

内容规则速览

WePre Next 卡片是单屏、离线、沙箱化的页面:单个 index.html(或根目录含它的 zip);根容器 100dvh + overflow:hidden;禁 overflow:auto/scroll;禁网络请求 / localStorage / Worker(注释中出现这些字样也会被拒);禁外部资源与根绝对路径;execute 模式卡片须监听 wepre-next:execute postMessage 触发主操作。完整约定见站内《WePre Next 内容发布规范》。

开发

纯 ESM JavaScript,无构建步骤。行为测试用 mock WePre 服务器驱动全部工具:

npm install
npm test

许可证

MIT

原始 README: https://github.com/shujiTech/dsh-plugin-wepre/blob/main/README.zh.md ↗