Create, format, and publish WeChat Official Account (微信公众号) articles to draft box with stable quality gates (config bootstrap, metadata validation, cover style×palette presets, and publish preflight). Use when user asks to write/format/publish a WeChat article, generate cover image, or push content to 公众号草稿箱.
统一使用工作区 wechat-article.config.json:
{
"appid": "公众号 AppID",
"appsecret": "公众号 AppSecret",
"author": "默认作者名",
"writing": {
"perspective": "第一人称",
"tone": "口语化",
"length": "1500-2500字",
"direction": "科技/AI/产品思考",
"keywords_style": "短句为主,一行不超过30字"
},
"publish": {
"need_open_comment": 1,
"only_fans_can_comment": 0
},
"cover": {
"default_style": "minimal-grid",
"palette": "auto",
"rotate": "sequential",
"seed": "title",
"allowed_styles": ["minimal-grid", "card-editorial", "diagonal-motion", "soft-gradient"],
"allowed_palettes": ["blue-tech", "purple-insight", "green-growth", "orange-energy", "rose-story", "slate-pro"]
},
"preview": {
"send_cover_preview": 1,
"require_confirm_before_publish": 1,
"confirm_keyword": "确认发布"
}
}
若配置不存在,先问完并写入:
appid / appsecretassets/cover-style-palette-preview-grid.jpg)展示风格×配色,让用户选择默认风格palette=auto, rotate=sequential, seed=title)若内置预览图不存在或需要更新,再执行:
python3 scripts/create_cover_preview_grid.py
将预览图发给用户后,必须用中文+编号询问(不要英文术语裸露给用户):
A. 默认风格(4选1)
B. 配色策略(2选1)
C. 配色方案(6选1,仅在 B2 时必选)
D. 轮换方式(2选1,仅在 B1 时必选)
用户回复格式:A2 B1 D1 或 A1 B2 C3。
然后把选择结果持久化到 wechat-article.config.json 的 cover 字段。
配置存在时:用户给主题即可,按流程执行「创作 → 排版 → 封面 → 预览确认 → 草稿发布」。
复制并勾选:
WeChat Article Progress:
- [ ] Step 0: 读取/初始化配置
- [ ] Step 1: 生成文章内容
- [ ] Step 2: 产出 HTML(内联样式)
- [ ] Step 3: 校验元数据(标题/摘要/作者)
- [ ] Step 4: 生成或解析封面图(style × palette)
- [ ] Step 5: 发送预览(文本 + 封面图)并等待确认
- [ ] Step 6: 发布前预检(凭证/依赖/文件)
- [ ] Step 7: 推送草稿
- [ ] Step 8: 返回结果与下一步
wechat-article.config.jsoncover.default_style 缺失:
assets/cover-style-palette-preview-grid.jpg 作为预览图python3 scripts/create_cover_preview_grid.py 生成cover.default_style按配置中的 writing.* 产出正文。
约束:
严格按 references/article-style.md:
<section><p>(16px, line-height 2)<strong style="color:#1a73e8;"><hr>发布前必须有:
title(不能为空)digest(建议 ≤ 120 字)author(优先配置 author)回填顺序:
优先级:
imgs/cover.png(若存在)scripts/create_cover.py 生成 cover.jpg风格:
minimal-gridcard-editorialdiagonal-motionsoft-gradient配色:
blue-techpurple-insightgreen-growthorange-energyrose-storyslate-proauto(按 rotate 策略选色)生成命令(默认)
python3 scripts/create_cover.py \
--title "主标题" \
--subtitle "副标题" \
--style "minimal-grid" \
--palette "auto" \
--rotate "sequential" \
--seed "主标题" \
--output cover.jpg
命令参数优先级:
cover.*在推送草稿前,必须先给用户看预览:
预览内容至少包含:
发送规则:
确认发布(继续)修改封面(仅重做封面)修改正文(回到正文编辑)确认策略(默认):
preview.require_confirm_before_publish = 1 时,未收到 preview.confirm_keyword(默认 确认发布)前,不得执行发布修改封面,保留正文,重新执行 Step 4 后再次预览修改正文,回到 Step 1/2 调整后再次预览发布前必须检查:
python3 可用curl 可用(发布脚本依赖)Pillow 已安装(若需生成封面)appid/appsecret 非空article.html 与封面文件存在缺项时先修复,不要直接发布。
使用:
python3 scripts/publish_draft.py \
--title "文章标题" \
--author "作者名" \
--digest "摘要(120字内)" \
--content-file article.html \
--cover cover.jpg \
--appid <appid> \
--appsecret <appsecret> \
--need-open-comment 1 \
--only-fans-can-comment 0
评论参数优先级:
publish.*固定返回:
media_id