Skip to content

Add WeChat Official Account Article Studio Mini App - #168

Merged
MyPrototypeWhat merged 4 commits into
MiniMax-AI:mainfrom
xiaobinger:feat/wechat-mp-article-studio
Nov 26, 2026
Merged

MyPrototypeWhat merged 4 commits into
MiniMax-AI:mainfrom
xiaobinger:feat/wechat-mp-article-studio

Conversation

@xiaobinger

@xiaobinger xiaobinger commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Adds wechat-mp-article-studio: a Mini App that turns an article topic, body, cover and illustration requirements, and a visual style into a cover/illustration plan, a duplication check against the previous article, versioned drafts with publish states, and paste-ready inline-styled HTML. Publishing is gated on account authorisation, material access scope, and an available publish interface, so with no WeChat interface connected the app keeps everything as a draft and never claims to have published.

The cover and illustration plan, with a rendered cover and its ratio, pixel target and checklist

The publish gate: account, material and interface all report as not connected, so both publish buttons stay disabled

Tested environment

  • MiniMax Code 3.1.19 on Windows 11 (x64).
  • Minimum client version: MiniMax Code 3.1.6 — the manifest declares toolAccess, which older clients reject. agentAccess, agentConcurrency and surface.window need 3.1.2.
  • Exercised in the app's own Browser tab: created a draft, rendered a cover (11.9 s, 200 image/jpeg served by the app), read the cover/illustration plan, ran the publish check against the live tool inventory, previewed the exported HTML (cover embedded as a base64 JPEG, inline styles only), and deleted drafts singly and in bulk. The console showed no errors and the network log no failed request. The article in the screenshots is synthetic sample content.
  • 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 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 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.
  • The package's own regression tests: node --test "tests/**/*.test.mjs" — 62 checks covering the publish gate's matching, the interface answer, the durable state, the questionnaire flow, the download allowlist and the page.
  • npm run check reports plugins/xiaobinger/wechat-mp-article-studio: OK — no errors and no warnings for this package — and repository: OK.

Not verified

  • The Agent polish turn and the interface publish path were implemented but never triggered: this machine has no WeChat publish interface, and the polish turn was not submitted. Both paths are exercised only by code review.
  • The duplication check is a deterministic text-overlap heuristic, not a semantic comparison. It was checked against hand-made near-duplicates and unrelated articles, not against a large corpus.

Remaining npm run check findings

npm run check runs 92 repository tests; 90 pass. The two failures are the repository's own symlink tests (test/files.test.mjs): creating a symlink on this Windows machine needs Developer Mode or an elevated shell, and the test aborts with EPERM before it reaches any assertion. Both tests build their own fixture under a temporary directory and never touch this package — they fail identically on a clean checkout of main.

New access and minimum client version

  • toolAccess: ["call"] — the app calls connector__matrix__generate_image and connector__matrix__get_asset_url, and reads context.tool.list() for the publish check and for the asset-URL tool's argument schema. This is what raises the minimum client version to 3.1.6.
  • agentAccess: ["session.run"] and agentConcurrency: 2 — one Agent turn, started only when you press 「交给 Agent 润色」. The turn is asked to rewrite the body only; if it requests a tool permission, the request is shown in the page and answered only after you choose Allow once or Deny.
  • No deviceAccess, no hostAccess, no session.read: the app uses no microphone, camera or notification, reads no Host navigation, and reads no other conversation.
  • No process is spawned and no shell is used. State is written only inside context.dataDir; the only outbound traffic is the two Connector calls above plus the download of the signed image URL they return.
Written by MiniMax M3.1 Flash

What the app does

  • Plan — a topic, a body, a cover requirement, an illustration requirement, and one of six built-in styles or your own style produce a cover slot (2.35:1 or 1:1) plus one illustration slot per ## section, each with a ratio, a pixel target, a generation prompt and a short checklist.
  • Render — each slot is a separate connector__matrix__generate_image call at 1K, so one slow image cannot cancel the rest. The asset-URL tool is looked up in the live inventory by provider matrix, and its argument key is read from the tool's own schema rather than guessed.
  • Duplication check — the draft is compared with the previous draft and with the previous published article on title, body and key-point overlap, and reports a percentage with a verdict.
  • Versions and states — editing the body creates a new version of the same article and keeps the older ones. A version is 草稿, 待发布, 已发布(接口) or 已发布(手动).
  • Cleanup — several versions can be selected and deleted together; a published record is protected unless you confirm.
  • 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 file.

Notes for the reviewer

  • The plugin ID is wechat-mp-article-studio; the directory name matches plugin.json.name and the ID is not used anywhere else in the repository. The package is self-contained and depends on no other directory in this repository.
  • miniapp/miniapp.json declares surface.window so the app can be popped out of the side panel into its own window.
  • The body parser understands a small Markdown subset: ## and ### headings, > quotes, - lists and **bold**.
  • The README is English, with README.zh-CN.md alongside it and links between the two.

熊兵 added 2 commits November 26, 2026 16:46
Adds plugins/xiaobinger/wechat-mp-article-studio: a workbench that turns an article topic, body, cover and illustration requirements, and a visual style into a cover/illustration plan, a duplication check against the previous article, versioned drafts with publish states, and paste-ready inline-styled HTML.

Publishing is gated on account authorisation, material access scope, and an available publish interface. With no WeChat interface connected the app keeps everything as a draft and never claims to have published.

MyPrototypeWhat commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

We confirmed several blocking issues at 82b07e7f4a5e0c5747a4677a3eba4f7ce72af73b. This PR should not be merged until they are fixed.

Publish-interface matching is too broad, and a connector error can still be recorded as a successful publish. classify runs substring matches with no word boundaries against provider, server, tool, and description across the full tool inventory (publishing.mjs). In a list constructed to the shape in this repository's docs/tool.md, an unrelated tool is treated as a publish interface if its description contains "WeChat official account draft", or if the same sentence contains both "WeChat" and "Publish/draft". If immediate contains media, the tool is also treated as a media-asset interface, so all three gates confirm. publishViaInterface takes the first match in the list and calls target.name. In this probe, the call actually issued was mcp__notes__search, with the article HTML in the arguments. Connector results also do not inspect value: MCP tools are checked only for isError (publishing.mjs). When the probe returned {errcode:40001}, the result was still treated as success and then written as published_api. Interface publish has no window.confirm; only manual publish does. This probe used descriptors constructed to the document shape, not a sample from a real Host tool inventory. The issue is which entry was classified as the publish interface, not that the UI label and the call target pointed at different tools.

After state.json is corrupted, the next mutate / commit overwrites the original file with empty state (store.mjs). On init, the original file is kept at first and a 「未覆盖」 notice is written, but the page does not render snapshot.notice. A later rename then overwrites the original file, and there is no backup. This was reproduced.

A polish turn that includes a questionnaire cannot save a new version. When there is no questionnaire, start() does commit. In the questionnaire shape used in this repository, requestId sits on the outer object. answerQuestion reads record.question.requestId, gets an empty value, and returns 「问题上下文已失效」, without calling agent.answer or commit (polisher.mjs). Even if the questionnaire object itself carries requestId, the success path only marks the state as done and still does not commit. The call also uses the key questionId, not the requestId required by the docs. When the state is done, the client always shows 「润色完成,已保存为新版本」. This finding is from a code review and an out-of-repo mock, not a real Agent turn.

Separately, downloadAsset has no host allowlist. The URL comes from a tool return value. If the tool returns an internal-network address, the process will request it and will follow 302 redirects. Please tighten this as well.

Please tighten publish-tool matching, judge success or failure from the connector's actual result, avoid overwriting the original file when the state file is corrupt, call commit after a successful questionnaire polish, and make the UI match whether a save actually happened. Please also add regression tests. We'll review the updated commit.

…ionnaire polish

Addresses the blocking findings from the review at 82b07e7.

- classify() now matches a tool by its identity (provider/server/tool) only and
  on whole tokens. A description that mentions a WeChat official account draft
  no longer promotes an unrelated tool, immediate is no longer media, and the
  role keyword has to come from the operation name. A draft interface such as
  draft_add is not a publish interface.
- publishViaInterface() lists and classifies the inventory again, then picks a
  target that declares a field for the article body and sends only the names
  that tool declares, so the article is never handed to a tool that cannot
  receive it.
- Success is read from what the interface returned. An MCP result with isError
  or an error code in structuredContent or a content block is a failure, and a
  Connector payload with a non-zero errcode/code, success:false or a non-empty
  failed_items is a failure. The version is only written as published_api
  after that.
- Interface publish asks for a confirmation, like the manual one does.
- A state file that cannot be read is moved aside as state.corrupt-<stamp>.json
  with its bytes intact instead of being overwritten, the page renders the
  notice that names the copy, and the previous good state is kept as
  state.backup.json.
- A polish turn with a questionnaire keeps the requestId beside the
  questionnaire, answers with requestId as the docs require, and commits the
  result as a new version. The page only says a version was saved when one
  really was.
- downloadAsset() accepts only HTTPS URLs on an Alibaba Cloud OSS host and
  checks every redirect hop against the same rule.
- Adds tests/ with 36 regression checks.
@xiaobinger

Copy link
Copy Markdown
Contributor Author

Fixed in 4202c81. Point by point.

Publish-interface matching. classify now reads only the tool's identity — provider, server, tool — and matches whole tokens, with camel case split first (freePublish → free + publish). description is never read. The role keyword must come from the operation name, and the tool must be named 公众号 in its namespace or in its own name. For the descriptors in your probe:

  • a tool whose description contains "WeChat official account draft" is not a 公众号 tool at all, because neither notes nor search says so;
  • immediate tokenises to immediate, never to media;
  • a tool whose description mentions both WeChat and Publish is likewise ignored.

The role words are now publish, freepublish, submit, 发布, 群发 for the publish gate and material, materials, media, thumb, thumbnail for the asset gate. A draft interface (draft_add, add_news) is not a publish interface, so it cannot open the gate.

Which tool is called. publishViaInterface lists the inventory again and classifies that fresh result instead of trusting the label shown earlier. It then picks a target that declares a field for the article body and builds the arguments from that tool's own inputSchema, sending only the names it declares (title, content, thumb_media_id, articles, …). A tool that declares no such field is not called at all — mcp__notes__search only declares query, so the article HTML is never handed to it.

Success is read from the answer. An MCP result is a failure when isError is set, when structuredContent carries a non-zero errcode/code, or when a content block parses to such a payload. A Connector result is a failure when its payload carries a non-zero errcode/code, success: false, an error/errmsg field, or a non-empty failed_items; {errcode:40001} is now a failure and the draft stays a draft. published_api is written only after that verdict is positive. Interface publish also asks for a confirmation now, like the manual one does.

A damaged state file. On init, a state file that cannot be read is moved aside as state.corrupt-<stamp>.json with its bytes intact — it is never overwritten — and the notice names that copy. The page renders snapshot.notice as a dismissible banner. If the file cannot even be moved, writes to state.json are blocked for the session and go to state.recovered.json instead. The previous good state is additionally kept as state.backup.json on every write. Verified on a throwaway data directory: the damaged bytes survive, the banner appears, and a later write leaves the copy untouched.

A questionnaire polish. The requestId is now kept beside the questionnaire rather than read out of it, so it is found on the question.requested event and on result.pendingQuestion, exactly where docs/agent.md puts it. answerQuestion calls agent.answer({ sessionId, requestId, answers }) — requestId, as the Node API requires, not questionId — and on a finished answer it commits the body as a new version through the same commit the questionnaire-free path uses. The record carries committed and committedVersion, and the page says 「润色完成,已保存为 v2」 only when a version really was written; a failed save reports the failure instead.

The download host. downloadAsset accepts only https URLs whose host matches <bucket>.oss-<region>.aliyuncs.com (in practice matrix-internal-cn.oss-cn-shanghai.aliyuncs.com). Literal addresses, loopback and link-local hosts, and every other host are refused. Redirects are followed by hand and every hop is checked against the same rule, so a 302 cannot move the request to another host.

Regression tests. tests/ adds 36 checks, run with node --test "tests/**/*.test.mjs":

  • publishing.test.mjs — the descriptor cases above, errcode / isError / content verdicts, argument building, and that no tool is called when none qualifies;
  • store.test.mjs — byte preservation, the notice, and that a later write does not touch the original;
  • polisher.test.mjs — the questionnaire flow, the requestId key, and the commit;
  • images.test.mjs — the host allowlist, including the user@host trick;
  • client.test.mjs — the page renders the notice and the detail view survives a run with no polish state.

Two notes for the re-review. The Agent polish turn and the interface publish path still have not run against a real Agent or a real WeChat interface on this machine; both are covered by mocks, and the PR body says so. And the page test caught a null-state crash in my own first attempt at the polish-status wording, which is why client.test.mjs exists.

Copy link
Copy Markdown
Collaborator

We re-reviewed 4202c81a61f4e0a50573dec15240eab2426c7ee7. The earlier blockers are fixed: publish-tool matching, the corrupted-state overwrite, and the questionnaire polish path that did not commit. The new plugin tests are 36/36 with node --test "tests/**/*.test.mjs". This still should not be merged, because of a new issue in error handling.

findErrorMarker (publishing.mjs) treats any non-empty errmsg as an error. In an independent probe, {errcode:0, errmsg:"ok"} was judged a failure after the tool had already been called, so the draft was not recorded as published. The success fixtures in the plugin tests use {code:0, message:"ok"} and have no errmsg, so they do not catch this. Please treat a successful errcode or code as success even when errmsg is a non-empty status string such as "ok", and add a regression for that shape.

A few secondary points that are not merge blockers on their own: submit is still in the publish-term list; when several tools match, the first one with a body field is used, and the confirm dialog does not name the tool; the download allowlist accepts any <bucket>.oss-<region>.aliyuncs.com host, and a 302 to another OSS host is still followed. Please tighten these as well if you can.

As you noted, the Agent polish turn and the interface publish path are still only covered by mocks, not a real Agent turn or a real WeChat publish interface. We'll re-review against the new commit.

findErrorMarker treated any non-empty errmsg as a failure, so a publish that
answered {errcode: 0, errmsg: "ok"} was recorded as not published. The result
code decides first: a zero errcode/code is a success and the status string next
to it is informational, while success=false and a non-empty failed_items still
fail. An explicit error field stays an error beside a zero code.

submit is no longer a publish role word. When more than one publish interface is
detected the page lists them and the user picks one; until then nothing is
published and the publish button stays disabled. Only the picked interface is
called, the confirmation dialog names it, and it is never swapped for another
one. The download allowlist is pinned to the matrix-internal-cn bucket, and a
redirect may no longer leave the host the signed URL named.

Tests: node --test "tests/**/*.test.mjs" (62 checks, up from 36).
@xiaobinger

Copy link
Copy Markdown
Contributor Author

Fixed in d30099c. The blocker and all four secondary points are addressed.

findErrorMarker — a success code now wins over the status string next to it. The result code decides first. errcode: 0, errCode: 0, error_code: 0 or code: 0 means the call succeeded, so errmsg and message are read as status strings and not as failures — {errcode: 0, errmsg: "ok"} is a success, which is exactly what 公众号 answers a successful publish with. A code that names anything else is still a failure ({errcode: 40001} → failure, reason names 40001), and a code that says nothing at all (no code, or a null/empty one) is not read as a success either.

The other failure shapes are unchanged and still fail: success: false, a non-empty failed_items, and an explicit error / errorMessage / error_message field — that last one stays an error even beside a zero code, because the code names the outcome while that field names the failure. errmsg / message are only read as an error when the payload carries no result code, so {errmsg: "invalid credential"} still fails.

Regressions added for exactly the shape you named: {errcode: 0, errmsg: "ok"} as a Connector value, the same shape nested inside data, the same shape as an MCP text block, plus {errcode: 0, errmsg: "ok", failed_items: [...]} (still a failure) and {errcode: 0, errmsg: "ok", success: false} (still a failure). The old {code: 0, message: "ok"} fixture is kept.

submit is no longer a publish-term. The publish role words are now publish, freepublish, 发布, 群发. A submit operation is too generic to name a publish role, so it is not treated as one — mcp__wechat__submit and mcp__wechat__submit_article are both rejected by classify. Regressions cover both.

Several matching tools: you name the one. The first match with a body field is never used any more. When more than one publish interface is detected, the page lists them in a picker and you pick the one to publish through; until that pick is made nothing is published and the publish button stays disabled. Only the picked interface is called — it is never swapped for another one — and if the picked interface declares no field for the article body the publish is refused rather than rerouted. The picked name is stored on the check record and validated server-side: the server rejects a name that is not in the detected list. Regressions cover: two interfaces and no pick (nothing is called), the pick is the one that is called, a picked interface that cannot carry the body (nothing is called, no fallback), and a picked interface that vanished from the live inventory (nothing is called).

The confirmation dialog names the tool. The publish confirmation reads 「将通过「wechat / freepublish」真实提交这篇文章。确认发布?」 — the label of the interface that will actually be called. The manual publish confirmation still names no interface, because it calls none.

The download allowlist is pinned. The host must now be the one bucket, matrix-internal-cn.oss-<region>.aliyuncs.com (in practice matrix-internal-cn.oss-cn-shanghai.aliyuncs.com); the region may differ between environments, the bucket may not. Any other bucket on that domain — other-bucket.oss-cn-shanghai.aliyuncs.com — is refused, as is a literal, loopback or link-local address. Redirects are still followed by hand, and every hop must satisfy both rules: the allowlist and the host the first URL named. A 302 to matrix-internal-cn.oss-cn-beijing.aliyuncs.com is refused, and a 302 to another bucket is refused by the allowlist. Regressions cover all four cases.

Tests. node --test "tests/**/*.test.mjs" — 62/62, up from 36. The new checks are the ones named above: the four findErrorMarker shapes, submit and submit_article, the four interface-selection cases, the four download cases, and five page checks (the picker renders, the publish button stays disabled until a pick, the confirmation names the picked interface, the pick is posted to the server, the manual confirmation names no interface). npm run check reports plugins/xiaobinger/wechat-mp-article-studio: OK and repository: OK.

The README (English and 简体中文) and the PR description were updated to match: the role words, the interface picker, the result-code rule and the pinned bucket are described in both languages, and the test count now reads 62.

One thing stays as it was and is stated in the PR description: the Agent polish turn and the interface publish path are still covered by mocks only — this machine has no WeChat publish interface, and the polish turn was not submitted.

@MyPrototypeWhat
MyPrototypeWhat merged commit 53ffe0c into MiniMax-AI:main Nov 26, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants