post-to-wechat
Installation
SKILL.md
post-to-wechat
Language
- Respond in the user's language.
Resolve Base Directory
- Set
{baseDir}to the directory containing thisSKILL.md.
Scripts
| Script | Purpose |
|---|---|
scripts/cdp_export.ts |
Drive the web app + WeChat backend via CDP, export HTML, and copy/paste rich text |
Choose the path
- Use
scripts/cdp_export.tsfor HTML export through the web app, browser automation, rich-text copy, theme selection through the web app, or direct posting into WeChat Official Account backend. - Prefer
scripts/cdp_export.tsfor end-to-end verification because it exercises the real web app behavior.
Non-negotiables
- Use Chrome CDP for browser automation; do not use
agent-browserfor this skill. - Default to the "复制富文本" button path; only use selection copy when explicitly requested or the button fails.
- When
--wechatis enabled, treat "fill metadata + paste body + save draft" as the default workflow.
Prereqs
- Node.js 24+ available (
node);scripts/cdp_export.tsrelies on native TypeScript execution. - Default web app:
https://wechat.reshub.vip. - Do not start a local web server unless the user explicitly asks for local development or debugging.
- Chrome/Edge with remote debugging enabled for
--cdp, or allow--launch-localto start a local Chrome. - Logged-in WeChat Official Account session if using
--wechat.
Workflow
- Determine whether the user wants HTML export only, rich-text copy, or full WeChat draft automation.
- Run
scripts/cdp_export.tswith the minimal flags required. - If the user mentions themes, pass
?theme=<name>through--appor--theme. - If the user mentions WeChat posting, add
--wechatand pass metadata overrides when available. - After execution, report what was actually completed: HTML generated, rich text copied, WeChat draft filled, cover uploaded, original marked, draft saved.
Quick start
HTML export through the web app:
node {baseDir}/scripts/cdp_export.ts \
--markdown-file "article.md" \
--app "https://wechat.reshub.vip/?theme=minimal" \
--cdp "http://127.0.0.1:9222" \
--action export-html
CDP copy only:
node {baseDir}/scripts/cdp_export.ts \
--markdown-file "article.md" \
--app "https://wechat.reshub.vip" \
--cdp "http://127.0.0.1:9222" \
--action copy-rich
CDP + WeChat backend:
node {baseDir}/scripts/cdp_export.ts \
--markdown-file "article.md" \
--app "https://wechat.reshub.vip" \
--cdp "http://127.0.0.1:9222" \
--action copy-rich \
--wechat
Theme preselection:
node {baseDir}/scripts/cdp_export.ts \
--markdown-file "article.md" \
--app "https://wechat.reshub.vip/?theme=minimal" \
--cdp "http://127.0.0.1:9222" \
--action copy-rich
Full draft example:
node {baseDir}/scripts/cdp_export.ts \
--markdown-file "article.md" \
--app "https://wechat.reshub.vip/?theme=default" \
--cdp "http://127.0.0.1:9222" \
--action copy-rich \
--wechat \
--title "测试标题" \
--author "测试作者" \
--summary "这是一段测试摘要。" \
--cover "./cover.png"
Inputs and metadata
- Accept Markdown via
--markdown-file, stdin, or--markdowntext. - Parse frontmatter:
title,author,summary,coverImage,featureImage,cover,image. - Allow CLI overrides:
--title,--author,--summary,--cover. - Default
--wechatsaves draft unless--no-submit. - Default to mark original unless
--no-original. - If both frontmatter and CLI args exist, CLI args win.
Defaults that matter
- Default app URL:
https://wechat.reshub.vip - Default CDP URL:
http://127.0.0.1:9222 - Default action:
copy-rich - Default copy strategy: click the "复制富文本" button
- Default WeChat behavior: save draft
- Default original behavior: enabled
- Default slow-down:
--delay-scale 3 - Default jitter:
--jitter-ms 800
Theme selection
- Add
?theme=<name>to the app URL to preselect a theme. - Support built-in themes plus locally saved theme drafts.
- See
references/theme-lab.mdfor import/export format and naming rules.
Common flags
--markdown-file <path>: read Markdown from file.--markdown "<text>": pass Markdown directly.--theme <name>: select theme when supported by the script.--app <url>: override web app URL.--cdp <url>: connect to an existing Chrome CDP endpoint.--launch-local: launch a local Chrome if none is already running.--wechat: open WeChat Official Account backend and paste content.--title,--author,--summary,--cover: override parsed metadata.--no-submit: do everything except save draft.--no-original: skip original declaration flow.--copy-strategy selection: fallback copy mode.
Timing and stability
- Use
--delay-scaleand--jitter-msto slow down UI steps and add random jitter. - Keep waits generous on WeChat backend UI transitions.
Vendoring external deps
- If a script needs third-party packages, vendor them under
{baseDir}/scripts/vendor/and reference viafile:in{baseDir}/scripts/package.json. - Keep vendor dependencies pinned and minimal.
References
references/wechat-cdp.md: CDP flow, selectors, and original declaration steps.references/theme-lab.md: theme draft import/export and URL selection rules.references/troubleshooting.md: common failure modes and fixes.
Report back to the user
- State which script was used.
- State whether the result was HTML only, copied rich text, or pasted into WeChat backend.
- If
--wechatwas used, state whether title, author, summary, cover, original declaration, and draft save each succeeded. - If something failed, mention the exact step and whether the content itself was still produced.