Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"schemaVersion": 1,
"name": "wechat-mp-article-studio",
"displayName": "公众号图文工作台",
"version": "1.0.0",
"version": "1.1.0",
"description": "输入公众号文章主题与正文,产出封面与插图方案、查重结论、版本管理与可发布内容;发布前须确认账号授权、素材范围与发布接口。",
"author": "xiaobinger",
"icon": "icon.png",
Expand Down
70 changes: 60 additions & 10 deletions plugins/xiaobinger/wechat-mp-article-studio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ and a paste-ready WeChat Official Account (公众号) body.
A tool only counts when its *identity* says so — see [How the publish gate decides](#how-the-publish-gate-decides).
- **Publish-ready content** — the body becomes inline-styled HTML that 公众号 accepts (no class
selectors, no `<style>` block), with the images embedded as data URIs. Preview it, copy it, or
download it as a standalone HTML file.
download it as a standalone HTML file. 「复制正文」 copies the plain body instead, with every
image named by its local path on a line of its own, which is what an interface that uploads
images expects.
- **Re-render one image** — the cover and each illustration can be re-rendered on its own, with the
requirements that are current for this version. The prompt of every slot is shown before it is
generated.
- **Agent polish (optional)** — hand the body to the Agent for rewriting. The result is saved as a
new version and the original version is kept. A turn that asks a question is answered and then
saved exactly like a turn that did not, and the page says so only when a version was really saved.
Expand Down Expand Up @@ -82,6 +87,26 @@ The gate never trusts a tool's prose and never trusts a cached answer.
- **Only declared fields are sent.** The arguments are built from the target tool's own
`inputSchema`. A tool that declares no field for the article body is not called at all, so the
article is never handed to a tool that cannot receive it.
- **The arguments follow the detected interface.** Each part of the article has a role — the title,
the digest, the body, the cover, the images, the kind of message, what to do with it — and every
role is known by a list of names. The first name *that interface itself declares* is the one that
is filled, so an interface that calls its cover `cover_image` is served exactly like one that
calls it `thumb_media_id`, and one that calls its body `article_content` like one that calls it
`content`. The value follows the schema too: the kind is the enum value that means an article,
the action is the enum value that means publish, and the body is the styled HTML unless the
interface takes the images separately or the HTML does not fit its declared limit — then it is
the plain body with the images named inside it.
- **A list argument is built item by item.** An interface may carry the article as a list of one
item instead of a top-level body. Each item is filled only from the names the item schema
declares (`title`, `article_content`, `thumb_media_id` …), and the item's body goes through the
same rule as a top-level one — its own `maxLength`, and plain text when the interface takes the
images separately. When an interface declares both a top-level body and a list, both get the same
chosen body. A list whose items name no field for the body is left unsent rather than filled with
a name the tool never declared, and an item that must carry a field this app cannot name stops
the publish.
- **A missing argument stops the publish.** An interface that asks for something this draft cannot
provide — a draft id that only the console knows, for instance — is not called at all, and the
page says which argument was missing.
- **The answer decides.** Success is read from what the interface returned, not from the absence of
a transport error: an MCP result is a failure when `isError` is set or when its
`structuredContent` or content blocks carry an error code, and a Connector result is a failure
Expand All @@ -100,21 +125,33 @@ The gate never trusts a tool's prose and never trusts a cached answer.
publish check against the live tool inventory, previewed the exported HTML (cover embedded as a
base64 JPEG, inline styles only), and deleted drafts both singly and in bulk. The console showed
no errors and the network log no failed request.
- The publish gate was re-run against the live inventory of this machine (203 tools): all three
checks report 「未接入」 and both publish buttons stay disabled, with no console error.
- The publish gate was re-run against the live inventory of this machine twice. With no 公众号
interface connected (203 tools) all three checks report 「未接入」 and both publish buttons stay
disabled, with no console error. With a 公众号 interface connected, all three are confirmed by
detection, the page lists the two publish interfaces it found and lets you pick one, and the
publish button stays disabled until you do.
- The interface picker was exercised in the app's own Browser tab against a draft whose check record
listed two publish interfaces: the picker is rendered, the publish button stays disabled until an
interface is picked, the pick is sent to the server, and the confirmation dialog names the picked
interface.
- The arguments were built against the live schema of a connected 公众号 interface that publishes a
article from a title, a cover file and a body: the payload carries the title, the digest, the
cover as a local path, the plain body (1,137 characters, inside the 20,000 the interface
declares), the kind, the action and the confirmation — with no required argument missing and
nothing over a declared limit. The interface that can only publish an existing draft id is
refused instead of called.
- 「复制正文」 was exercised in the app's own Browser tab: the clipboard holds the plain body with
the four illustrations named by their local paths, and 「预览」 still shows the styled HTML.
- The damaged-state path was exercised on a throwaway data directory: the damaged file keeps its
exact bytes under `state.corrupt-<stamp>.json`, the page shows the notice that names the copy,
and a later write leaves that copy untouched.
- This package's own tests: `node --test "tests/**/*.test.mjs"` — 62 checks covering the publish
- This package's own tests: `node --test "tests/**/*.test.mjs"` — 93 checks covering the publish
gate's matching, the interface answer, the durable state, the questionnaire flow, the download
allowlist, and the page.
- Not verified: the Agent polish turn and the interface publish path were implemented but never
triggered, because this machine has no WeChat publish interface and the polish turn was not
submitted.
allowlist, the plain body, the asset-path containment, the list arguments, and the page.
- Not verified: the publish call itself was never made, so no article was published from this app
and no result code was read back from a real publish. The Agent polish turn was triggered once in
the app's own Browser tab and its result was saved as a new version; the branch where the Agent
asks a question was not exercised, because that turn did not ask one.

## Data & access

Expand All @@ -125,6 +162,16 @@ The gate never trusts a tool's prose and never trusts a cached answer.
kept as `state.backup.json`. A state file that cannot be read is moved aside under its own name
instead of being overwritten, and the page is told about it. No Host or user files are read or
written.
- **Asset paths are contained** — a path handed to a publish interface is built only from an asset
record's id and extension, both checked: the id must be a plain name the renderer writes
(`randomUUID()`, no separator), the extension must be one of `.jpg`, `.jpeg`, `.png`, `.webp`, and
the resolved file must lie inside `dataDir/assets`. A record that names anything else — an id of
`../secret` or `../../outside` in a hand-edited state file, say — yields no path, and the publish
is refused with 「没有指向本应用的素材目录」 instead of being sent. An image reference that is
already inside the draft body (a pasted `![](file:///C:/…)` or `<img src=…>` line) is kept only
when it resolves inside `dataDir/assets` and dropped otherwise; `https:`, `data:` and relative
references are never turned into a path. So no path outside this plugin's own `dataDir` is ever
named to an interface, whatever the state file or the body contains.
- **Network hosts** — the app makes no request of its own. It calls the Connector tools listed below
and fetches the short-lived signed URL that `connector__matrix__get_asset_url` returns. That URL
must be HTTPS and its host must be the pinned bucket
Expand All @@ -148,8 +195,11 @@ The gate never trusts a tool's prose and never trusts a cached answer.
tool's own schema, so a renamed argument does not break the app. The app also calls
`context.tool.list()` to read the inventory for the publish check, and calls the detected WeChat
publish tool only when the publish gate confirms one exists and that tool declares a field for the
article body. Every call is judged by your own permission rules; if the tool list contains a
WeChat account, material, or publish interface, the publish check reports it as detected evidence.
article body. That call carries the rendered cover and the rendered illustrations as file paths
inside this plugin's own `dataDir`, and the body as text — no file outside the plugin's own
directory is ever named. Every call is judged by your own permission rules; if the tool list
contains a WeChat account, material, or publish interface, the publish check reports it as
detected evidence.
- **Microphone, camera, notifications** — not used.
- **Host navigation read** — not used. The page only follows the Host's light/dark theme, which
needs no permission.
Expand Down
49 changes: 40 additions & 9 deletions plugins/xiaobinger/wechat-mp-article-studio/README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
没有接公众号接口时,内容始终保持为草稿,应用不会声称已发布。判定只看工具的**身份**,不看它的
描述文字,详见[发布门禁如何判定](#发布门禁如何判定)。
- **可发布内容** — 正文转成公众号接受的内联样式 HTML(没有 class 选择器、没有 `<style>` 块),图片
以 base64 内嵌。可以预览、复制,或下载成独立 HTML 文件。
以 base64 内嵌。可以预览、复制,或下载成独立 HTML 文件。「复制正文」复制的是纯文本正文,每张插图
以本地路径单独成行标注 —— 需要自己上传图片的接口要的就是这个形态。
- **单张重渲** — 封面和每张插图都能单独按当前版本的要求重新生成,生成前的提示词就在卡片里写着。
- **Agent 润色(可选)** — 把正文交给 Agent 改写,结果保存为新版本,原版本保留。Agent 中途提问时,
问卷回答完同样会存成新版本;页面只在真的存成功时才说「已保存为新版本」。
- **状态文件损坏** — `state.json` 读不出来时不会被覆盖:原始字节保留为 `state.corrupt-<时间戳>.json`,
Expand Down Expand Up @@ -66,6 +68,19 @@ node --test "tests/**/*.test.mjs"
保持禁用。确认框里会写明选的是哪一个,也只会调用这一个 —— 不会被悄悄换成别的接口。
- **只发接口声明过的字段。** 参数按目标工具自己的 `inputSchema` 生成。接口没有声明能承载正文的字段时
根本不会调用,正文不会被送给一个接不住它的工具。
- **参数跟着检测到的接口走。** 文章的每一部分都有角色 —— 标题、摘要、正文、封面、图片、消息类型、
要做什么 —— 每个角色都有一组常见叫法。哪个叫法是**这个接口自己声明的**,就填那一个:叫
`cover_image` 的接口和叫 `thumb_media_id` 的接口待遇完全一样,叫 `article_content` 的和叫 `content`
的也一样。取值同样看 schema:消息类型取枚举里表示文章的那一项,动作取枚举里表示发表的那一项;
正文默认给内联样式 HTML,但如果接口自己收图片、或者 HTML 超了它声明的长度上限,就换成纯文本正文
并把图片按位置写在里面。
- **列表参数逐项构造。** 有的接口把文章放在只含一项的列表里,而不是顶层正文字段。列表项只按它自己的
schema 声明的名字填(`title`、`article_content`、`thumb_media_id`……),列表项的正文同样走上面那条
规矩 —— 用它自己的 `maxLength`,接口自己收图片时同样换成纯文本正文。接口同时声明顶层正文和列表时,
两处拿到的是同一份选定的正文。列表项里没有任何正文字段时,这一项不会被塞进一个工具没声明过的名字;
列表项要求某个这篇稿件给不出的字段时,同样不调用。
- **缺参数就不发。** 接口要求一个这篇稿件给不出的东西(比如只有后台自己知道的草稿 id),那就不调用,
并在页面上说清缺的是哪个参数。
- **以对方的返回为准。** 成败看接口实际返回了什么,而不是「没报错就算成功」:MCP 结果在 `isError`
为真、或 `structuredContent` 与内容块里带错误码时算失败;Connector 结果在负载里带非零
`errcode` / `code`、`success: false`、或 `failed_items` 非空时算失败。结果码为零时,旁边那句状态串
Expand All @@ -80,16 +95,23 @@ node --test "tests/**/*.test.mjs"
- 在应用自己的 Browser 标签页里做过的客户端验收:新建草稿、渲染封面(11.9 秒,应用自身返回
`200 image/jpeg`)、查看封面与插图方案、对实时工具清单跑发布检查、预览导出 HTML(封面以 base64
JPEG 内嵌、只有内联样式)、单个删除与批量删除草稿;控制台无报错,网络无失败请求。
- 发布门禁在本机的实时清单(203 个工具)上重跑过一次:三项都显示「未接入」,两个发布按钮保持禁用,
控制台无报错。
- 发布门禁在本机的实时清单上重跑过两次:没有公众号接口时(203 个工具)三项都显示「未接入」,两个
发布按钮保持禁用,控制台无报错;接上公众号接口后,三项都由接口检测确认,页面列出检测到的两个
发布接口让你选一个,没选之前发布按钮保持禁用。
- 接口选择器在应用自己的 Browser 标签页里对着一条「检测到两个发布接口」的检查记录跑过:选择器渲染
出来,没选之前发布按钮保持禁用,选定之后会发给服务端,确认框里写明选的是哪一个。
- 参数按本机真实接上的那个公众号接口的 schema 造过一遍:载荷带标题、摘要、以本地路径给出的封面、
1137 字的纯文本正文(在接口声明的 20000 字上限之内)、消息类型、动作和确认标志;没有缺必填参数,
也没有超出任何声明的上限。而那个只能发表已存在草稿 id 的接口,被拒绝而不是被调用。
- 「复制正文」在应用自己的 Browser 标签页里跑过:剪贴板里是纯文本正文,四张插图各以本地路径单独
成行;「预览」仍然是内联样式的 HTML。
- 状态文件损坏这条路径在一个一次性 dataDir 上跑过:损坏文件按原字节保留为
`state.corrupt-<时间戳>.json`,页面提示了这份副本的名字,之后再写也不会动到它。
- 本包自带的测试:`node --test "tests/**/*.test.mjs"` —— 62 项,覆盖发布门禁的匹配、接口返回的判定、
持久化状态、问卷流程、下载白名单和页面。
- 未验证:Agent 润色这一轮和「通过接口发布」这两条路径写完了但没有真正触发 —— 这台机器上没有公众号
发布接口,润色轮次也没有提交。
- 本包自带的测试:`node --test "tests/**/*.test.mjs"` —— 93 项,覆盖发布门禁的匹配、接口返回的判定、
持久化状态、问卷流程、下载白名单、纯文本正文、素材路径边界、列表参数和页面。
- 未验证:「通过接口发布」这次调用本身没有真的发出,所以这篇应用没有真的发布过任何文章,也没有从一次
真实发布里读回结果码。Agent 润色这一轮在应用自己的 Browser 标签页里触发过一次,结果存成了新版本;
Agent 反问的那个分支没有跑过,因为那一轮它没有提问。

## 数据与权限

Expand All @@ -98,6 +120,14 @@ node --test "tests/**/*.test.mjs"
`state.corrupt-<时间戳>.json`(读不出来的状态文件)。`state.json` 用临时文件加 rename 的方式原子替换,
替换前把旧状态留一份 `state.backup.json`。读不出来的状态文件会被移到自己的文件名下,而不是被覆盖,
页面也会收到提示。不读取也不写入任何 Host 或用户文件。
- **素材路径有边界** — 交给发布接口的路径只由素材记录的 id 与扩展名拼出,两者都要过关:id 必须是渲染器
自己写的那种纯名字(`randomUUID()`,不含分隔符),扩展名必须是 `.jpg`、`.jpeg`、`.png`、`.webp` 之一,
拼出来的文件还必须落在 `dataDir/assets` 里面。指向别处的记录 —— 比如手改过的状态文件里写成
`../secret` 或 `../../outside` 的 id —— 拼不出路径,发布会直接以「没有指向本应用的素材目录」拒绝,
而不是把这个路径发出去。正文里本来就有的图片引用(从别处粘进来的 `![](file:///C:/…)` 或
`<img src=…>`)只有在落在 `dataDir/assets` 内时才保留,否则整条引用去掉;`https:`、`data:` 和相对
路径一律不会被当成文件路径。所以无论状态文件或正文里写了什么,交给接口的都不会是插件自己 `dataDir`
以外的文件。
- **网络主机** — 应用自身不发请求。它只调用下面列出的 Connector 工具,并获取
`connector__matrix__get_asset_url` 返回的短时签名地址。该地址必须是 HTTPS,主机必须是写死的那一个
存储桶(`matrix-internal-cn.oss-<region>.aliyuncs.com`,实际是
Expand All @@ -114,8 +144,9 @@ node --test "tests/**/*.test.mjs"
`connector__matrix__get_asset_url` 用来把生成的节点 id 换成下载地址。取地址那个工具是在实时工具清单里
按 provider `matrix` 查出来的,参数名也从它自己的 schema 读,所以上游改名不会让应用失效。应用还会调用
`context.tool.list()` 读取工具清单,用于发布检查;只有在门禁确认存在发布接口、且该接口声明了能承载
正文的字段时,才会真正调用它。每次调用都走你自己的权限规则;如果工具清单里存在公众号的账号、素材或
发布接口,发布检查会把它作为检测到的证据列出来。
正文的字段时,才会真正调用它。这次调用里带的是本插件自己 `dataDir` 里渲染好的封面与插图的**文件
路径**,以及纯文本正文 —— 永远不会提到插件自己目录以外的任何文件。每次调用都走你自己的权限规则;
如果工具清单里存在公众号的账号、素材或发布接口,发布检查会把它作为检测到的证据列出来。
- **麦克风、摄像头、通知** — 未使用。
- **Host 导航读取** — 未使用。页面只跟随 Host 的明暗主题,这不需要权限。
- **状态存放位置** — 这个插件的 Host 私有 `context.dataDir`。除了上面列出的 Connector 调用,不向任何
Expand Down
Loading