baoyu-post-to-wechat

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Post to WeChat Official Account

微信公众号内容发布

Language

语言适配

Match user's language: Respond in the same language the user uses. If user writes in Chinese, respond in Chinese. If user writes in English, respond in English.
匹配用户语言:使用用户所使用的语言进行响应。如果用户用中文提问,就用中文回复;如果用户用英文提问,就用英文回复。

Script Directory

脚本目录

Agent Execution: Determine this SKILL.md directory as
SKILL_DIR
, then use
${SKILL_DIR}/scripts/<name>.ts
.
ScriptPurpose
scripts/wechat-browser.ts
Image-text posts (图文)
scripts/wechat-article.ts
Article posting via browser (文章)
scripts/wechat-api.ts
Article posting via API (文章)
Agent执行:将当前SKILL.md所在目录设为
SKILL_DIR
,然后使用
${SKILL_DIR}/scripts/<name>.ts
脚本用途
scripts/wechat-browser.ts
图文发布
scripts/wechat-article.ts
通过浏览器发布文章
scripts/wechat-api.ts
通过API发布文章

Preferences (EXTEND.md)

偏好设置(EXTEND.md)

Use Bash to check EXTEND.md existence (priority order):
bash
undefined
使用Bash检查EXTEND.md文件是否存在(优先级顺序):
bash
undefined

Check project-level first

首先检查项目级目录

test -f .baoyu-skills/baoyu-post-to-wechat/EXTEND.md && echo "project"
test -f .baoyu-skills/baoyu-post-to-wechat/EXTEND.md && echo "project"

Then user-level (cross-platform: $HOME works on macOS/Linux/WSL)

然后检查用户级目录(跨平台:$HOME适用于macOS/Linux/WSL)

test -f "$HOME/.baoyu-skills/baoyu-post-to-wechat/EXTEND.md" && echo "user"

┌────────────────────────────────────────────────────────┬───────────────────┐
│                          Path                          │     Location      │
├────────────────────────────────────────────────────────┼───────────────────┤
│ .baoyu-skills/baoyu-post-to-wechat/EXTEND.md           │ Project directory │
├────────────────────────────────────────────────────────┼───────────────────┤
│ $HOME/.baoyu-skills/baoyu-post-to-wechat/EXTEND.md     │ User home         │
└────────────────────────────────────────────────────────┴───────────────────┘

┌───────────┬───────────────────────────────────────────────────────────────────────────┐
│  Result   │                                  Action                                   │
├───────────┼───────────────────────────────────────────────────────────────────────────┤
│ Found     │ Read, parse, apply settings                                               │
├───────────┼───────────────────────────────────────────────────────────────────────────┤
│ Not found │ Use defaults                                                              │
└───────────┴───────────────────────────────────────────────────────────────────────────┘

**EXTEND.md Supports**: Default theme | Default publishing method (api/browser) | Default author | Chrome profile path
test -f "$HOME/.baoyu-skills/baoyu-post-to-wechat/EXTEND.md" && echo "user"

┌────────────────────────────────────────────────────────┬───────────────────┐
│ 路径 │ 位置 │
├────────────────────────────────────────────────────────┼───────────────────┤
│ .baoyu-skills/baoyu-post-to-wechat/EXTEND.md           │ 项目目录 │
├────────────────────────────────────────────────────────┼───────────────────┤
│ $HOME/.baoyu-skills/baoyu-post-to-wechat/EXTEND.md     │ 用户主目录 │
└────────────────────────────────────────────────────────┴───────────────────┘

┌───────────┬───────────────────────────────────────────────────────────────────────────┐
│ 结果 │ 操作 │
├───────────┼───────────────────────────────────────────────────────────────────────────┤
│ 已找到 │ 读取、解析并应用设置 │
├───────────┼───────────────────────────────────────────────────────────────────────────┤
│ 未找到 │ 使用默认设置 │
└───────────┴───────────────────────────────────────────────────────────────────────────┘

**EXTEND.md支持配置**:默认主题 | 默认发布方式(api/browser) | 默认作者 | Chrome配置文件路径

Image-Text Posting (图文)

图文发布

For short posts with multiple images (up to 9):
bash
npx -y bun ${SKILL_DIR}/scripts/wechat-browser.ts --markdown article.md --images ./images/
npx -y bun ${SKILL_DIR}/scripts/wechat-browser.ts --title "标题" --content "内容" --image img.png --submit
See references/image-text-posting.md for details.
适用于包含多张图片(最多9张)的短内容发布:
bash
npx -y bun ${SKILL_DIR}/scripts/wechat-browser.ts --markdown article.md --images ./images/
npx -y bun ${SKILL_DIR}/scripts/wechat-browser.ts --title "标题" --content "内容" --image img.png --submit
详情请参阅references/image-text-posting.md

Article Posting Workflow (文章)

文章发布流程

Copy this checklist and check off items as you complete them:
Publishing Progress:
- [ ] Step 0: Load preferences (EXTEND.md)
- [ ] Step 1: Determine input type
- [ ] Step 2: Check markdown-to-html skill
- [ ] Step 3: Convert to HTML
- [ ] Step 4: Validate metadata (title, summary)
- [ ] Step 5: Select method and configure credentials
- [ ] Step 6: Publish to WeChat
- [ ] Step 7: Report completion
复制以下检查清单,完成对应项后勾选:
发布进度:
- [ ] 步骤0:加载偏好设置(EXTEND.md)
- [ ] 步骤1:确定输入类型
- [ ] 步骤2:检查Markdown转HTML技能
- [ ] 步骤3:转换为HTML格式
- [ ] 步骤4:验证元数据(标题、摘要)
- [ ] 步骤5:选择发布方式并配置凭证
- [ ] 步骤6:发布到微信公众号
- [ ] 步骤7:报告完成状态

Step 0: Load Preferences

步骤0:加载偏好设置

Check and load EXTEND.md settings (see Preferences section above).
检查并加载EXTEND.md中的设置(请参阅上方偏好设置章节)。

Step 1: Determine Input Type

步骤1:确定输入类型

Input TypeDetectionAction
HTML filePath ends with
.html
, file exists
Skip to Step 4
Markdown filePath ends with
.md
, file exists
Continue to Step 2
Plain textNot a file path, or file doesn't existSave to markdown, then Step 2
Plain Text Handling:
  1. Generate slug from content (first 2-4 meaningful words, kebab-case)
  2. Create directory and save file:
bash
mkdir -p "$(pwd)/post-to-wechat/$(date +%Y-%m-%d)"
输入类型检测方式操作
HTML文件路径以
.html
结尾且文件存在
跳至步骤4
Markdown文件路径以
.md
结尾且文件存在
继续执行步骤2
纯文本不是文件路径,或文件不存在保存为Markdown文件,然后执行步骤2
纯文本处理
  1. 从内容生成slug(选取前2-4个有意义的单词,采用短横线分隔格式)
  2. 创建目录并保存文件:
bash
mkdir -p "$(pwd)/post-to-wechat/$(date +%Y-%m-%d)"

Save content to: post-to-wechat/yyyy-MM-dd/[slug].md

保存路径:post-to-wechat/yyyy-MM-dd/[slug].md


3. Continue processing as markdown file

**Slug Examples**:
- "Understanding AI Models" → `understanding-ai-models`
- "人工智能的未来" → `ai-future` (translate to English for slug)

3. 按照Markdown文件继续处理

**Slug示例**:
- "Understanding AI Models" → `understanding-ai-models`
- "人工智能的未来" → `ai-future`(转换为英文生成slug)

Step 2: Check Markdown-to-HTML Skill

步骤2:检查Markdown转HTML技能

Skip if: Input is
.html
file
Skill Discovery:
bash
undefined
跳过条件:输入为
.html
文件
技能检测
bash
undefined

Check if baoyu-markdown-to-html exists

检查baoyu-markdown-to-html是否存在

test -f skills/baoyu-markdown-to-html/SKILL.md && echo "found"

| Result | Action |
|--------|--------|
| Found | Read its SKILL.md, continue to Step 3 |
| Multiple skills | AskUserQuestion to choose |
| Not found | Show installation suggestion |

**When Not Found**:
No markdown-to-html skill found.
Options: A) Cancel - install the skill first B) Continue - provide HTML file manually
undefined
test -f skills/baoyu-markdown-to-html/SKILL.md && echo "found"

| 结果 | 操作 |
|--------|--------|
| 已找到 | 读取其SKILL.md,继续执行步骤3 |
| 存在多个技能 | 询问用户选择对应技能 |
| 未找到 | 显示安装建议 |

**未找到时的提示**:
未找到Markdown转HTML技能。
选项: A) 取消 - 先安装该技能 B) 继续 - 手动提供HTML文件
undefined

Step 3: Convert Markdown to HTML

步骤3:将Markdown转换为HTML

Skip if: Input is
.html
file
  1. Ask theme preference (unless specified in EXTEND.md or CLI):
ThemeDescription
default
经典主题 - 传统排版,标题居中带底边,二级标题白字彩底
grace
优雅主题 - 文字阴影,圆角卡片,精致引用块
simple
简洁主题 - 现代极简风,不对称圆角,清爽留白
  1. Execute conversion (using the discovered skill):
bash
npx -y bun ${MD_TO_HTML_SKILL_DIR}/scripts/main.ts <markdown_file> --theme <theme>
  1. Parse JSON output to get:
    htmlPath
    ,
    title
    ,
    author
    ,
    summary
    ,
    contentImages
跳过条件:输入为
.html
文件
  1. 询问主题偏好(除非EXTEND.md或CLI中已指定):
主题描述
default
经典主题 - 传统排版,标题居中带底边,二级标题白字彩底
grace
优雅主题 - 文字阴影,圆角卡片,精致引用块
simple
简洁主题 - 现代极简风,不对称圆角,清爽留白
  1. 执行转换(使用检测到的技能):
bash
npx -y bun ${MD_TO_HTML_SKILL_DIR}/scripts/main.ts <markdown_file> --theme <theme>
  1. 解析JSON输出,获取:
    htmlPath
    ,
    title
    ,
    author
    ,
    summary
    ,
    contentImages

Step 4: Validate Metadata

步骤4:验证元数据

Check extracted metadata from Step 3 (or HTML meta tags if direct HTML input).
FieldIf Missing
TitlePrompt: "Enter title, or press Enter to auto-generate from content"
SummaryPrompt: "Enter summary, or press Enter to auto-generate (recommended for SEO)"
Auto-Generation Logic:
  • Title: First H1/H2 heading, or first sentence
  • Summary: First paragraph, truncated to 120 characters
检查步骤3中提取的元数据(如果是直接HTML输入则检查HTML元标签)。
字段缺失时的操作
标题提示:"请输入标题,或按回车键从内容自动生成"
摘要提示:"请输入摘要,或按回车键自动生成(推荐用于SEO)"
自动生成逻辑
  • 标题:第一个H1/H2标题,或第一句话
  • 摘要:第一段内容,截断至120字符

Step 5: Select Publishing Method and Configure

步骤5:选择发布方式并配置

Ask publishing method (unless specified in EXTEND.md or CLI):
MethodSpeedRequirements
api
(Recommended)
FastAPI credentials
browser
SlowChrome, login session
If API Selected - Check Credentials:
bash
undefined
询问发布方式(除非EXTEND.md或CLI中已指定):
方式速度要求
api
(推荐)
快速API凭证
browser
缓慢Chrome浏览器、已登录会话
选择API方式时 - 检查凭证
bash
undefined

Check project-level

检查项目级目录

test -f .baoyu-skills/.env && grep -q "WECHAT_APP_ID" .baoyu-skills/.env && echo "project"
test -f .baoyu-skills/.env && grep -q "WECHAT_APP_ID" .baoyu-skills/.env && echo "project"

Check user-level

检查用户级目录

test -f "$HOME/.baoyu-skills/.env" && grep -q "WECHAT_APP_ID" "$HOME/.baoyu-skills/.env" && echo "user"

**If Credentials Missing - Guide Setup**:
WeChat API credentials not found.
To obtain credentials:
  1. Visit https://mp.weixin.qq.com
  2. Go to: 开发 → 基本配置
  3. Copy AppID and AppSecret
Where to save? A) Project-level: .baoyu-skills/.env (this project only) B) User-level: ~/.baoyu-skills/.env (all projects)

After location choice, prompt for values and write to `.env`:
WECHAT_APP_ID=<user_input> WECHAT_APP_SECRET=<user_input>
undefined
test -f "$HOME/.baoyu-skills/.env" && grep -q "WECHAT_APP_ID" "$HOME/.baoyu-skills/.env" && echo "user"

**凭证缺失时 - 引导配置**:
未找到微信API凭证。
获取凭证步骤:
  1. 访问https://mp.weixin.qq.com
  2. 进入:开发 → 基本配置
  3. 复制AppID和AppSecret
保存位置选择: A) 项目级:.baoyu-skills/.env(仅当前项目生效) B) 用户级:~/.baoyu-skills/.env(所有项目生效)

用户选择位置后,提示输入值并写入`.env`:
WECHAT_APP_ID=<用户输入> WECHAT_APP_SECRET=<用户输入>
undefined

Step 6: Publish to WeChat

步骤6:发布到微信公众号

API method:
bash
npx -y bun ${SKILL_DIR}/scripts/wechat-api.ts <html_file> [--title <title>] [--summary <summary>]
Browser method:
bash
npx -y bun ${SKILL_DIR}/scripts/wechat-article.ts --html <html_file>
API方式
bash
npx -y bun ${SKILL_DIR}/scripts/wechat-api.ts <html_file> [--title <title>] [--summary <summary>]
浏览器方式
bash
npx -y bun ${SKILL_DIR}/scripts/wechat-article.ts --html <html_file>

Step 7: Completion Report

步骤7:完成报告

For API method, include draft management link:
WeChat Publishing Complete!

Input: [type] - [path]
Method: API
Theme: [theme name]

Article:
• Title: [title]
• Summary: [summary]
• Images: [N] inline images

Result:
✓ Draft saved to WeChat Official Account
• media_id: [media_id]

Next Steps:
→ Manage drafts: https://mp.weixin.qq.com (登录后进入「内容管理」→「草稿箱」)

Files created:
[• post-to-wechat/yyyy-MM-dd/slug.md (if plain text)]
[• slug.html (converted)]
For Browser method:
WeChat Publishing Complete!

Input: [type] - [path]
Method: Browser
Theme: [theme name]

Article:
• Title: [title]
• Summary: [summary]
• Images: [N] inline images

Result:
✓ Draft saved to WeChat Official Account

Files created:
[• post-to-wechat/yyyy-MM-dd/slug.md (if plain text)]
[• slug.html (converted)]
API方式的报告,包含草稿管理链接:
微信公众号发布完成!

输入:[类型] - [路径]
方式:API
主题:[主题名称]

文章信息:
• 标题:[标题]
• 摘要:[摘要]
• 图片:[N] 张内嵌图片

结果:
✓ 草稿已保存至微信公众号
• media_id: [media_id]

下一步操作:
→ 管理草稿:https://mp.weixin.qq.com(登录后进入「内容管理」→「草稿箱」)

生成的文件:
[• post-to-wechat/yyyy-MM-dd/slug.md(如果是纯文本输入)]
[• slug.html(转换后的文件)]
浏览器方式的报告
微信公众号发布完成!

输入:[类型] - [路径]
方式:浏览器
主题:[主题名称]

文章信息:
• 标题:[标题]
• 摘要:[摘要]
• 图片:[N] 张内嵌图片

结果:
✓ 草稿已保存至微信公众号

生成的文件:
[• post-to-wechat/yyyy-MM-dd/slug.md(如果是纯文本输入)]
[• slug.html(转换后的文件)]

Detailed References

详细参考文档

TopicReference
Image-text parameters, auto-compressionreferences/image-text-posting.md
Article themes, image handlingreferences/article-posting.md
主题参考链接
图文发布参数、自动压缩references/image-text-posting.md
文章主题、图片处理references/article-posting.md

Feature Comparison

功能对比

FeatureImage-TextArticle (API)Article (Browser)
Plain text input
HTML input
Markdown inputTitle/content✓ (via skill)✓ (via skill)
Multiple images✓ (up to 9)✓ (inline)✓ (inline)
Themes
Auto-generate metadata
Requires Chrome
Requires API credentials
SpeedMediumFastSlow
功能图文文章(API方式)文章(浏览器方式)
纯文本输入
HTML输入
Markdown输入仅标题/内容✓(通过技能转换)✓(通过技能转换)
多张图片✓(最多9张)✓(内嵌)✓(内嵌)
主题支持
元数据自动生成
需要Chrome浏览器
需要API凭证
速度中等快速缓慢

Prerequisites

前置条件

For API method:
  • WeChat Official Account API credentials
  • Guided setup in Step 5, or manually set in
    .baoyu-skills/.env
For Browser method:
  • Google Chrome
  • First run: log in to WeChat Official Account (session preserved)
For Markdown conversion:
  • A markdown-to-html skill (e.g.,
    baoyu-markdown-to-html
    )
  • If not installed, the workflow will suggest installation
Config File Locations (priority order):
  1. Environment variables
  2. <cwd>/.baoyu-skills/.env
  3. ~/.baoyu-skills/.env
API方式要求
  • 微信公众号API凭证
  • 可通过步骤5引导配置,或手动在
    .baoyu-skills/.env
    中设置
浏览器方式要求
  • Google Chrome浏览器
  • 首次运行:登录微信公众号(会话将被保留)
Markdown转换要求
  • Markdown转HTML技能(例如
    baoyu-markdown-to-html
  • 如果未安装,流程将提示安装
配置文件位置(优先级顺序):
  1. 环境变量
  2. <cwd>/.baoyu-skills/.env
  3. ~/.baoyu-skills/.env

Troubleshooting

故障排查

IssueSolution
No markdown-to-html skillInstall
baoyu-markdown-to-html
from suggested URL
Missing API credentialsFollow guided setup in Step 5
Access token errorCheck if API credentials are valid and not expired
Not logged in (browser)First run opens browser - scan QR to log in
Chrome not foundSet
WECHAT_BROWSER_CHROME_PATH
env var
Title/summary missingUse auto-generation or provide manually
Paste failsCheck system clipboard permissions
问题解决方案
缺少Markdown转HTML技能从推荐URL安装
baoyu-markdown-to-html
缺失API凭证按照步骤5的引导配置
访问令牌错误检查API凭证是否有效且未过期
未登录(浏览器方式)首次运行将打开浏览器 - 扫码登录
未找到Chrome设置环境变量
WECHAT_BROWSER_CHROME_PATH
标题/摘要缺失使用自动生成或手动提供
粘贴失败检查系统剪贴板权限

Extension Support

扩展支持

Custom configurations via EXTEND.md. See Preferences section for paths and supported options.
可通过EXTEND.md进行自定义配置。路径及支持的选项请参阅偏好设置章节。