baoyu-post-to-wechat
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePost 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 , then use .
SKILL_DIR${SKILL_DIR}/scripts/<name>.ts| Script | Purpose |
|---|---|
| Image-text posts (图文) |
| Article posting via browser (文章) |
| Article posting via API (文章) |
Agent执行:将当前SKILL.md所在目录设为,然后使用。
SKILL_DIR${SKILL_DIR}/scripts/<name>.ts| 脚本 | 用途 |
|---|---|
| 图文发布 |
| 通过浏览器发布文章 |
| 通过API发布文章 |
Preferences (EXTEND.md)
偏好设置(EXTEND.md)
Use Bash to check EXTEND.md existence (priority order):
bash
undefined使用Bash检查EXTEND.md文件是否存在(优先级顺序):
bash
undefinedCheck 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 pathtest -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 --submitSee 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 Type | Detection | Action |
|---|---|---|
| HTML file | Path ends with | Skip to Step 4 |
| Markdown file | Path ends with | Continue to Step 2 |
| Plain text | Not a file path, or file doesn't exist | Save to markdown, then Step 2 |
Plain Text Handling:
- Generate slug from content (first 2-4 meaningful words, kebab-case)
- Create directory and save file:
bash
mkdir -p "$(pwd)/post-to-wechat/$(date +%Y-%m-%d)"| 输入类型 | 检测方式 | 操作 |
|---|---|---|
| HTML文件 | 路径以 | 跳至步骤4 |
| Markdown文件 | 路径以 | 继续执行步骤2 |
| 纯文本 | 不是文件路径,或文件不存在 | 保存为Markdown文件,然后执行步骤2 |
纯文本处理:
- 从内容生成slug(选取前2-4个有意义的单词,采用短横线分隔格式)
- 创建目录并保存文件:
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 file
.htmlSkill Discovery:
bash
undefined跳过条件:输入为文件
.html技能检测:
bash
undefinedCheck 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.
Suggested installation:
https://github.com/JimLiu/baoyu-skills/blob/main/skills/baoyu-markdown-to-html/SKILL.md
Options:
A) Cancel - install the skill first
B) Continue - provide HTML file manually
undefinedtest -f skills/baoyu-markdown-to-html/SKILL.md && echo "found"
| 结果 | 操作 |
|--------|--------|
| 已找到 | 读取其SKILL.md,继续执行步骤3 |
| 存在多个技能 | 询问用户选择对应技能 |
| 未找到 | 显示安装建议 |
**未找到时的提示**:
未找到Markdown转HTML技能。
选项:
A) 取消 - 先安装该技能
B) 继续 - 手动提供HTML文件
undefinedStep 3: Convert Markdown to HTML
步骤3:将Markdown转换为HTML
Skip if: Input is file
.html- Ask theme preference (unless specified in EXTEND.md or CLI):
| Theme | Description |
|---|---|
| 经典主题 - 传统排版,标题居中带底边,二级标题白字彩底 |
| 优雅主题 - 文字阴影,圆角卡片,精致引用块 |
| 简洁主题 - 现代极简风,不对称圆角,清爽留白 |
- Execute conversion (using the discovered skill):
bash
npx -y bun ${MD_TO_HTML_SKILL_DIR}/scripts/main.ts <markdown_file> --theme <theme>- Parse JSON output to get: ,
htmlPath,title,author,summarycontentImages
跳过条件:输入为文件
.html- 询问主题偏好(除非EXTEND.md或CLI中已指定):
| 主题 | 描述 |
|---|---|
| 经典主题 - 传统排版,标题居中带底边,二级标题白字彩底 |
| 优雅主题 - 文字阴影,圆角卡片,精致引用块 |
| 简洁主题 - 现代极简风,不对称圆角,清爽留白 |
- 执行转换(使用检测到的技能):
bash
npx -y bun ${MD_TO_HTML_SKILL_DIR}/scripts/main.ts <markdown_file> --theme <theme>- 解析JSON输出,获取:,
htmlPath,title,author,summarycontentImages
Step 4: Validate Metadata
步骤4:验证元数据
Check extracted metadata from Step 3 (or HTML meta tags if direct HTML input).
| Field | If Missing |
|---|---|
| Title | Prompt: "Enter title, or press Enter to auto-generate from content" |
| Summary | Prompt: "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):
| Method | Speed | Requirements |
|---|---|---|
| Fast | API credentials |
| Slow | Chrome, login session |
If API Selected - Check Credentials:
bash
undefined询问发布方式(除非EXTEND.md或CLI中已指定):
| 方式 | 速度 | 要求 |
|---|---|---|
| 快速 | API凭证 |
| 缓慢 | Chrome浏览器、已登录会话 |
选择API方式时 - 检查凭证:
bash
undefinedCheck 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:
- Visit https://mp.weixin.qq.com
- Go to: 开发 → 基本配置
- 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>
undefinedtest -f "$HOME/.baoyu-skills/.env" && grep -q "WECHAT_APP_ID" "$HOME/.baoyu-skills/.env" && echo "user"
**凭证缺失时 - 引导配置**:
未找到微信API凭证。
获取凭证步骤:
- 访问https://mp.weixin.qq.com
- 进入:开发 → 基本配置
- 复制AppID和AppSecret
保存位置选择:
A) 项目级:.baoyu-skills/.env(仅当前项目生效)
B) 用户级:~/.baoyu-skills/.env(所有项目生效)
用户选择位置后,提示输入值并写入`.env`:
WECHAT_APP_ID=<用户输入>
WECHAT_APP_SECRET=<用户输入>
undefinedStep 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
详细参考文档
| Topic | Reference |
|---|---|
| Image-text parameters, auto-compression | references/image-text-posting.md |
| Article themes, image handling | references/article-posting.md |
| 主题 | 参考链接 |
|---|---|
| 图文发布参数、自动压缩 | references/image-text-posting.md |
| 文章主题、图片处理 | references/article-posting.md |
Feature Comparison
功能对比
| Feature | Image-Text | Article (API) | Article (Browser) |
|---|---|---|---|
| Plain text input | ✗ | ✓ | ✓ |
| HTML input | ✗ | ✓ | ✓ |
| Markdown input | Title/content | ✓ (via skill) | ✓ (via skill) |
| Multiple images | ✓ (up to 9) | ✓ (inline) | ✓ (inline) |
| Themes | ✗ | ✓ | ✓ |
| Auto-generate metadata | ✗ | ✓ | ✓ |
| Requires Chrome | ✓ | ✗ | ✓ |
| Requires API credentials | ✗ | ✓ | ✗ |
| Speed | Medium | Fast | Slow |
| 功能 | 图文 | 文章(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):
- Environment variables
<cwd>/.baoyu-skills/.env~/.baoyu-skills/.env
API方式要求:
- 微信公众号API凭证
- 可通过步骤5引导配置,或手动在中设置
.baoyu-skills/.env
浏览器方式要求:
- Google Chrome浏览器
- 首次运行:登录微信公众号(会话将被保留)
Markdown转换要求:
- Markdown转HTML技能(例如)
baoyu-markdown-to-html - 如果未安装,流程将提示安装
配置文件位置(优先级顺序):
- 环境变量
<cwd>/.baoyu-skills/.env~/.baoyu-skills/.env
Troubleshooting
故障排查
| Issue | Solution |
|---|---|
| No markdown-to-html skill | Install |
| Missing API credentials | Follow guided setup in Step 5 |
| Access token error | Check if API credentials are valid and not expired |
| Not logged in (browser) | First run opens browser - scan QR to log in |
| Chrome not found | Set |
| Title/summary missing | Use auto-generation or provide manually |
| Paste fails | Check system clipboard permissions |
| 问题 | 解决方案 |
|---|---|
| 缺少Markdown转HTML技能 | 从推荐URL安装 |
| 缺失API凭证 | 按照步骤5的引导配置 |
| 访问令牌错误 | 检查API凭证是否有效且未过期 |
| 未登录(浏览器方式) | 首次运行将打开浏览器 - 扫码登录 |
| 未找到Chrome | 设置环境变量 |
| 标题/摘要缺失 | 使用自动生成或手动提供 |
| 粘贴失败 | 检查系统剪贴板权限 |
Extension Support
扩展支持
Custom configurations via EXTEND.md. See Preferences section for paths and supported options.
可通过EXTEND.md进行自定义配置。路径及支持的选项请参阅偏好设置章节。