baoyu-post-to-wechat by jimliu/baoyu-skills
npx skills add https://github.com/jimliu/baoyu-skills --skill baoyu-post-to-wechat匹配用户语言:使用用户使用的语言进行回复。如果用户使用中文,则用中文回复;如果用户使用英文,则用英文回复。
代理执行:将此 SKILL.md 目录确定为 {baseDir},然后使用 {baseDir}/scripts/<name>.ts。解析 ${BUN_X} 运行时:如果安装了 bun → 使用 bun;如果 npx 可用 → 使用 npx -y bun;否则建议安装 bun。
| 脚本 | 用途 |
|---|---|
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
scripts/wechat-browser.ts| 图文消息 |
scripts/wechat-article.ts | 通过浏览器发布文章 |
scripts/wechat-api.ts | 通过 API 发布文章 |
scripts/md-to-wechat.ts | Markdown → 微信公众号就绪的 HTML(带图片占位符) |
scripts/check-permissions.ts | 验证环境和权限 |
检查 EXTEND.md 是否存在(优先级顺序):
# macOS, Linux, WSL, Git Bash
test -f .baoyu-skills/baoyu-post-to-wechat/EXTEND.md && echo "project"
test -f "${XDG_CONFIG_HOME:-$HOME/.config}/baoyu-skills/baoyu-post-to-wechat/EXTEND.md" && echo "xdg"
test -f "$HOME/.baoyu-skills/baoyu-post-to-wechat/EXTEND.md" && echo "user"
# PowerShell (Windows)
if (Test-Path .baoyu-skills/baoyu-post-to-wechat/EXTEND.md) { "project" }
$xdg = if ($env:XDG_CONFIG_HOME) { $env:XDG_CONFIG_HOME } else { "$HOME/.config" }
if (Test-Path "$xdg/baoyu-skills/baoyu-post-to-wechat/EXTEND.md") { "xdg" }
if (Test-Path "$HOME/.baoyu-skills/baoyu-post-to-wechat/EXTEND.md") { "user" }
┌────────────────────────────────────────────────────────┬───────────────────┐ │ 路径 │ 位置 │ ├────────────────────────────────────────────────────────┼───────────────────┤ │ .baoyu-skills/baoyu-post-to-wechat/EXTEND.md │ 项目目录 │ ├────────────────────────────────────────────────────────┼───────────────────┤ │ $HOME/.baoyu-skills/baoyu-post-to-wechat/EXTEND.md │ 用户主目录 │ └────────────────────────────────────────────────────────┴───────────────────┘
┌───────────┬───────────────────────────────────────────────────────────────────────────┐ │ 结果 │ 操作 │ ├───────────┼───────────────────────────────────────────────────────────────────────────┤ │ 找到 │ 读取、解析、应用设置 │ ├───────────┼───────────────────────────────────────────────────────────────────────────┤ │ 未找到 │ 运行首次设置 (references/config/first-time-setup.md) → 保存 → 继续 │ └───────────┴───────────────────────────────────────────────────────────────────────────┘
EXTEND.md 支持:默认主题 | 默认颜色 | 默认发布方法 (api/browser) | 默认作者 | 默认开启评论开关 | 默认粉丝评论开关 | Chrome 配置文件路径
最低支持键(不区分大小写,接受 1/0 或 true/false):
| 键 | 默认值 | 映射 |
|---|---|---|
default_author | 空 | 当 CLI/前置元数据未提供 author 时的备用值 |
need_open_comment | 1 | draft/add 请求中的 articles[].need_open_comment |
only_fans_can_comment | 0 | draft/add 请求中的 articles[].only_fans_can_comment |
推荐的 EXTEND.md 示例:
default_theme: default
default_color: blue
default_publish_method: api
default_author: 宝玉
need_open_comment: 1
only_fans_can_comment: 0
chrome_profile_path: /path/to/chrome/profile
主题选项:default, grace, simple, modern
颜色预设:blue, green, vermilion, yellow, purple, sky, rose, olive, black, gray, pink, red, orange (或十六进制值)
值优先级:
EXTEND.md 支持管理多个微信公众号。当存在 accounts: 块时,每个账户可以有自己的凭据、Chrome 配置文件和默认设置。
兼容性规则:
| 条件 | 模式 | 行为 |
|---|---|---|
无 accounts 块 | 单账户 | 当前行为,不变 |
accounts 有 1 个条目 | 单账户 | 自动选择,无提示 |
accounts 有 2+ 个条目 | 多账户 | 发布前提示选择 |
accounts 中有 default: true | 多账户 | 预选默认账户,用户可以切换 |
多账户 EXTEND.md 示例:
default_theme: default
default_color: blue
accounts:
- name: 宝玉的技术分享
alias: baoyu
default: true
default_publish_method: api
default_author: 宝玉
need_open_comment: 1
only_fans_can_comment: 0
app_id: your_wechat_app_id
app_secret: your_wechat_app_secret
- name: AI工具集
alias: ai-tools
default_publish_method: browser
default_author: AI工具集
need_open_comment: 1
only_fans_can_comment: 0
每账户键(可以按账户设置或全局作为备用):default_publish_method, default_author, need_open_comment, only_fans_can_comment, app_id, app_secret, chrome_profile_path
仅全局键(始终在所有账户间共享):default_theme, default_color
在文章发布工作流的步骤 0 和步骤 1 之间插入:
if no accounts block:
→ single-account mode (current behavior)
elif accounts.length == 1:
→ auto-select the only account
elif --account <alias> CLI arg:
→ select matching account
elif one account has default: true:
→ pre-select, show: "Using account: <name> (--account to switch)"
else:
→ prompt user:
"Multiple WeChat accounts configured:
1) <name1> (<alias1>)
2) <name2> (<alias2>)
Select account [1-N]:"
对于选定的别名为 {alias} 的账户:
app_id / app_secretWECHAT_{ALIAS}_APP_ID / WECHAT_{ALIAS}_APP_SECRET (别名大写,连字符 → 下划线).baoyu-skills/.env 中带前缀的键 WECHAT_{ALIAS}_APP_ID~/.baoyu-skills/.env 中带前缀的键WECHAT_APP_ID / WECHAT_APP_SECRET.env 多账户示例:
# Account: baoyu
WECHAT_BAOYU_APP_ID=your_wechat_app_id
WECHAT_BAOYU_APP_SECRET=your_wechat_app_secret
# Account: ai-tools
WECHAT_AI_TOOLS_APP_ID=your_ai_tools_wechat_app_id
WECHAT_AI_TOOLS_APP_SECRET=your_ai_tools_wechat_app_secret
每个账户使用独立的 Chrome 配置文件以实现独立的登录会话:
| 来源 | 路径 |
|---|---|
EXTEND.md 中的账户 chrome_profile_path | 按原样使用 |
| 根据别名自动生成 | {shared_profile_parent}/wechat-{alias}/ |
| 单账户回退 | 共享的默认配置文件(当前行为) |
--account 参数所有发布脚本都接受 --account <alias>:
${BUN_X} {baseDir}/scripts/wechat-api.ts <file> --theme default --account ai-tools
${BUN_X} {baseDir}/scripts/wechat-article.ts --markdown <file> --theme default --account baoyu
${BUN_X} {baseDir}/scripts/wechat-browser.ts --markdown <file> --images ./photos/ --account baoyu
首次使用前,建议运行环境检查。如果用户愿意,可以跳过。
${BUN_X} {baseDir}/scripts/check-permissions.ts
检查:Chrome、配置文件隔离、Bun、辅助功能、剪贴板、粘贴按键、API 凭据、Chrome 冲突。
如果任何检查失败,根据项目提供修复指导:
| 检查 | 修复 |
|---|---|
| Chrome | 安装 Chrome 或设置 WECHAT_BROWSER_CHROME_PATH 环境变量 |
| 配置文件目录 | 共享配置文件位于 baoyu-skills/chrome-profile (参见 CLAUDE.md Chrome 配置文件部分) |
| Bun 运行时 | brew install oven-sh/bun/bun (macOS) 或 npm install -g bun |
| 辅助功能 (macOS) | 系统设置 → 隐私与安全性 → 辅助功能 → 启用终端应用 |
| 剪贴板复制 | 确保 Swift/AppKit 可用 (macOS Xcode CLI 工具: xcode-select --install) |
| 粘贴按键 (macOS) | 同上辅助功能修复 |
| 粘贴按键 (Linux) | 安装 xdotool (X11) 或 ydotool (Wayland) |
| API 凭据 | 按照步骤 2 中的引导设置,或手动在 .baoyu-skills/.env 中设置 |
适用于带多张图片(最多 9 张)的短文:
${BUN_X} {baseDir}/scripts/wechat-browser.ts --markdown article.md --images ./images/
${BUN_X} {baseDir}/scripts/wechat-browser.ts --title "标题" --content "内容" --image img.png --submit
复制此清单,并在完成项目时勾选:
Publishing Progress:
- [ ] Step 0: Load preferences (EXTEND.md)
- [ ] Step 0.5: Resolve account (multi-account only)
- [ ] Step 1: Determine input type
- [ ] Step 2: Select method and configure credentials
- [ ] Step 3: Resolve theme/color and validate metadata
- [ ] Step 4: Publish to WeChat
- [ ] Step 5: Report completion
检查并加载 EXTEND.md 设置(参见上面的偏好设置部分)。
关键:如果未找到,在开始任何其他步骤或提问之前,请完成首次设置。
解析并存储这些默认值以供后续步骤使用:
default_theme (默认 default)default_color (如果未设置则省略 — 应用主题默认值)default_authorneed_open_comment (默认 1)only_fans_can_comment (默认 0)| 输入类型 | 检测 | 操作 |
|---|---|---|
| HTML 文件 | 路径以 .html 结尾,文件存在 | 跳转到步骤 3 |
| Markdown 文件 | 路径以 .md 结尾,文件存在 | 继续到步骤 2 |
| 纯文本 | 不是文件路径,或文件不存在 | 保存为 markdown,继续到步骤 2 |
纯文本处理:
mkdir -p "$(pwd)/post-to-wechat/$(date +%Y-%m-%d)"
# Save content to: post-to-wechat/yyyy-MM-dd/[slug].md
3. 继续作为 markdown 文件处理
Slug 示例:
understanding-ai-modelsai-future (为 slug 翻译成英文)询问发布方法(除非在 EXTEND.md 或 CLI 中指定):
| 方法 | 速度 | 要求 |
|---|---|---|
api (推荐) | 快 | API 凭据 |
browser | 慢 | Chrome,登录会话 |
如果选择 API - 检查凭据:
# macOS, Linux, WSL, Git Bash
test -f .baoyu-skills/.env && grep -q "WECHAT_APP_ID" .baoyu-skills/.env && echo "project"
test -f "$HOME/.baoyu-skills/.env" && grep -q "WECHAT_APP_ID" "$HOME/.baoyu-skills/.env" && echo "user"
# PowerShell (Windows)
if ((Test-Path .baoyu-skills/.env) -and (Select-String -Quiet -Pattern "WECHAT_APP_ID" .baoyu-skills/.env)) { "project" }
if ((Test-Path "$HOME/.baoyu-skills/.env") -and (Select-String -Quiet -Pattern "WECHAT_APP_ID" "$HOME/.baoyu-skills/.env")) { "user" }
如果凭据缺失 - 引导设置:
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)
选择位置后,提示输入值并写入 .env:
WECHAT_APP_ID=<user_input>
WECHAT_APP_SECRET=<user_input>
解析主题(首次匹配胜出,如果已解析则不要询问用户):
--theme 参数default_theme(在步骤 0 中加载)default解析颜色(首次匹配胜出):
--color 参数default_color(在步骤 0 中加载)验证元数据,来自前置元数据(markdown)或 HTML 元标签(HTML 输入):
| 字段 | 如果缺失 |
|---|---|
| 标题 | 提示:"输入标题,或按 Enter 键从内容自动生成" |
| 摘要 | 提示:"输入摘要,或按 Enter 键自动生成(推荐用于 SEO)" |
| 作者 | 使用回退链:CLI --author → 前置元数据 author → EXTEND.md default_author |
自动生成逻辑:
article_type=news 必需):
--cover 则使用。coverImage, featureImage, cover, image)。imgs/cover.png。关键:发布脚本在内部处理 markdown 转换。不要预先将 markdown 转换为 HTML — 直接传递原始的 markdown 文件。这确保 API 方法将图片渲染为 <img> 标签(用于 API 上传),而浏览器方法使用占位符(用于粘贴替换工作流)。
Markdown 引用默认值:
--no-cite。API 方法(接受 .md 或 .html):
${BUN_X} {baseDir}/scripts/wechat-api.ts <file> --theme <theme> [--color <color>] [--title <title>] [--summary <summary>] [--author <author>] [--cover <cover_path>] [--no-cite]
关键:始终包含 --theme 参数。即使使用 default 也不要省略。仅当用户或 EXTEND.md 明确设置了 --color 时才包含它。
draft/add 负载规则:
POST https://api.weixin.qq.com/cgi-bin/draft/add?access_token=ACCESS_TOKENarticle_type:news (默认) 或 newspicnews,包含 thumb_media_id (封面是必需的)need_open_comment (默认 1)only_fans_can_comment (默认 0)author 解析:CLI --author → 前置元数据 author → EXTEND.md default_author如果脚本参数未公开两个评论字段,仍要确保最终的 API 请求体包含解析后的值。
浏览器方法(接受 --markdown 或 --html):
${BUN_X} {baseDir}/scripts/wechat-article.ts --markdown <markdown_file> --theme <theme> [--color <color>] [--no-cite]
${BUN_X} {baseDir}/scripts/wechat-article.ts --html <html_file>
对于 API 方法,包含草稿管理链接:
WeChat Publishing Complete!
Input: [type] - [path]
Method: API
Theme: [theme name] [color if set]
Article:
• Title: [title]
• Summary: [summary]
• Images: [N] inline images
• Comments: [open/closed], [fans-only/all users]
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)]
对于浏览器方法:
WeChat Publishing Complete!
Input: [type] - [path]
Method: Browser
Theme: [theme name] [color if set]
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)]
| 主题 | 参考 |
|---|---|
| 图文参数,自动压缩 | references/image-text-posting.md |
| 文章主题,图片处理 | references/article-posting.md |
| 功能 | 图文 | 文章 (API) | 文章 (浏览器) |
|---|---|---|---|
| 纯文本输入 | ✗ | ✓ | ✓ |
| HTML 输入 | ✗ | ✓ | ✓ |
| Markdown 输入 | 标题/内容 | ✓ | ✓ |
| 多张图片 | ✓ (最多 9 张) | ✓ (内联) | ✓ (内联) |
| 主题 | ✗ | ✓ | ✓ |
| 自动生成元数据 | ✗ | ✓ | ✓ |
默认封面回退 (imgs/cover.png) | ✗ | ✓ | ✗ |
评论控制 (need_open_comment, only_fans_can_comment) | ✗ | ✓ | ✗ |
| 需要 Chrome | ✓ | ✗ | ✓ |
| 需要 API 凭据 | ✗ | ✓ | ✗ |
| 速度 | 中等 | 快 | 慢 |
对于 API 方法:
.baoyu-skills/.env 中设置对于浏览器方法:
配置文件位置(优先级顺序):
<cwd>/.baoyu-skills/.env~/.baoyu-skills/.env| 问题 | 解决方案 |
|---|---|
| 缺少 API 凭据 | 按照步骤 2 中的引导设置 |
| 访问令牌错误 | 检查 API 凭据是否有效且未过期 |
| 未登录 (浏览器) | 首次运行打开浏览器 - 扫描二维码登录 |
| 未找到 Chrome | 设置 WECHAT_BROWSER_CHROME_PATH 环境变量 |
| 标题/摘要缺失 | 使用自动生成或手动提供 |
| 无封面图片 | 添加前置元数据封面或在文章目录中放置 imgs/cover.png |
| 评论默认值错误 | 检查 EXTEND.md 键 need_open_comment 和 only_fans_can_comment |
| 粘贴失败 | 检查系统剪贴板权限 |
通过 EXTEND.md 进行自定义配置。有关路径和支持的选项,请参阅偏好设置部分。
每周安装
14.4K
仓库
GitHub Stars
11.3K
首次出现
Jan 19, 2026
安全审计
安装于
opencode13.3K
gemini-cli12.9K
codex12.7K
cursor12.5K
github-copilot12.0K
amp11.6K
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.
Agent Execution : Determine this SKILL.md directory as {baseDir}, then use {baseDir}/scripts/<name>.ts. Resolve ${BUN_X} runtime: if bun installed → bun; if npx available → npx -y bun; else suggest installing bun.
| Script | Purpose |
|---|---|
scripts/wechat-browser.ts | Image-text posts (图文) |
scripts/wechat-article.ts | Article posting via browser (文章) |
scripts/wechat-api.ts | Article posting via API (文章) |
scripts/md-to-wechat.ts | Markdown → WeChat-ready HTML with image placeholders |
scripts/check-permissions.ts | Verify environment & permissions |
Check EXTEND.md existence (priority order):
# macOS, Linux, WSL, Git Bash
test -f .baoyu-skills/baoyu-post-to-wechat/EXTEND.md && echo "project"
test -f "${XDG_CONFIG_HOME:-$HOME/.config}/baoyu-skills/baoyu-post-to-wechat/EXTEND.md" && echo "xdg"
test -f "$HOME/.baoyu-skills/baoyu-post-to-wechat/EXTEND.md" && echo "user"
# PowerShell (Windows)
if (Test-Path .baoyu-skills/baoyu-post-to-wechat/EXTEND.md) { "project" }
$xdg = if ($env:XDG_CONFIG_HOME) { $env:XDG_CONFIG_HOME } else { "$HOME/.config" }
if (Test-Path "$xdg/baoyu-skills/baoyu-post-to-wechat/EXTEND.md") { "xdg" }
if (Test-Path "$HOME/.baoyu-skills/baoyu-post-to-wechat/EXTEND.md") { "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 │ Run first-time setup (references/config/first-time-setup.md) → Save → Continue │ └───────────┴───────────────────────────────────────────────────────────────────────────┘
EXTEND.md Supports : Default theme | Default color | Default publishing method (api/browser) | Default author | Default open-comment switch | Default fans-only-comment switch | Chrome profile path
First-time setup: references/config/first-time-setup.md
Minimum supported keys (case-insensitive, accept 1/0 or true/false):
| Key | Default | Mapping |
|---|---|---|
default_author | empty | Fallback for author when CLI/frontmatter not provided |
need_open_comment | 1 | articles[].need_open_comment in draft/add request |
only_fans_can_comment |
Recommended EXTEND.md example :
default_theme: default
default_color: blue
default_publish_method: api
default_author: 宝玉
need_open_comment: 1
only_fans_can_comment: 0
chrome_profile_path: /path/to/chrome/profile
Theme options : default, grace, simple, modern
Color presets : blue, green, vermilion, yellow, purple, sky, rose, olive, black, gray, pink, red, orange (or hex value)
Value priority :
EXTEND.md supports managing multiple WeChat Official Accounts. When accounts: block is present, each account can have its own credentials, Chrome profile, and default settings.
Compatibility rules :
| Condition | Mode | Behavior |
|---|---|---|
No accounts block | Single-account | Current behavior, unchanged |
accounts with 1 entry | Single-account | Auto-select, no prompt |
accounts with 2+ entries | Multi-account | Prompt to select before publishing |
accounts with default: true | Multi-account | Pre-select default, user can switch |
Multi-account EXTEND.md example :
default_theme: default
default_color: blue
accounts:
- name: 宝玉的技术分享
alias: baoyu
default: true
default_publish_method: api
default_author: 宝玉
need_open_comment: 1
only_fans_can_comment: 0
app_id: your_wechat_app_id
app_secret: your_wechat_app_secret
- name: AI工具集
alias: ai-tools
default_publish_method: browser
default_author: AI工具集
need_open_comment: 1
only_fans_can_comment: 0
Per-account keys (can be set per-account or globally as fallback): default_publish_method, default_author, need_open_comment, only_fans_can_comment, app_id, app_secret, chrome_profile_path
Global-only keys (always shared across accounts): default_theme, default_color
Insert between Step 0 and Step 1 in the Article Posting Workflow:
if no accounts block:
→ single-account mode (current behavior)
elif accounts.length == 1:
→ auto-select the only account
elif --account <alias> CLI arg:
→ select matching account
elif one account has default: true:
→ pre-select, show: "Using account: <name> (--account to switch)"
else:
→ prompt user:
"Multiple WeChat accounts configured:
1) <name1> (<alias1>)
2) <name2> (<alias2>)
Select account [1-N]:"
For a selected account with alias {alias}:
app_id / app_secret inline in EXTEND.md account blockWECHAT_{ALIAS}_APP_ID / WECHAT_{ALIAS}_APP_SECRET (alias uppercased, hyphens → underscores).baoyu-skills/.env with prefixed key WECHAT_{ALIAS}_APP_ID~/.baoyu-skills/.env with prefixed keyWECHAT_APP_ID / WECHAT_APP_SECRET.env multi-account example :
# Account: baoyu
WECHAT_BAOYU_APP_ID=your_wechat_app_id
WECHAT_BAOYU_APP_SECRET=your_wechat_app_secret
# Account: ai-tools
WECHAT_AI_TOOLS_APP_ID=your_ai_tools_wechat_app_id
WECHAT_AI_TOOLS_APP_SECRET=your_ai_tools_wechat_app_secret
Each account uses an isolated Chrome profile for independent login sessions:
| Source | Path |
|---|---|
Account chrome_profile_path in EXTEND.md | Use as-is |
| Auto-generated from alias | {shared_profile_parent}/wechat-{alias}/ |
| Single-account fallback | Shared default profile (current behavior) |
--account ArgumentAll publishing scripts accept --account <alias>:
${BUN_X} {baseDir}/scripts/wechat-api.ts <file> --theme default --account ai-tools
${BUN_X} {baseDir}/scripts/wechat-article.ts --markdown <file> --theme default --account baoyu
${BUN_X} {baseDir}/scripts/wechat-browser.ts --markdown <file> --images ./photos/ --account baoyu
Before first use, suggest running the environment check. User can skip if they prefer.
${BUN_X} {baseDir}/scripts/check-permissions.ts
Checks: Chrome, profile isolation, Bun, Accessibility, clipboard, paste keystroke, API credentials, Chrome conflicts.
If any check fails , provide fix guidance per item:
| Check | Fix |
|---|---|
| Chrome | Install Chrome or set WECHAT_BROWSER_CHROME_PATH env var |
| Profile dir | Shared profile at baoyu-skills/chrome-profile (see CLAUDE.md Chrome Profile section) |
| Bun runtime | brew install oven-sh/bun/bun (macOS) or npm install -g bun |
| Accessibility (macOS) | System Settings → Privacy & Security → Accessibility → enable terminal app |
| Clipboard copy | Ensure Swift/AppKit available (macOS Xcode CLI tools: xcode-select --install) |
| Paste keystroke (macOS) | Same as Accessibility fix above |
For short posts with multiple images (up to 9):
${BUN_X} {baseDir}/scripts/wechat-browser.ts --markdown article.md --images ./images/
${BUN_X} {baseDir}/scripts/wechat-browser.ts --title "标题" --content "内容" --image img.png --submit
See references/image-text-posting.md for details.
Copy this checklist and check off items as you complete them:
Publishing Progress:
- [ ] Step 0: Load preferences (EXTEND.md)
- [ ] Step 0.5: Resolve account (multi-account only)
- [ ] Step 1: Determine input type
- [ ] Step 2: Select method and configure credentials
- [ ] Step 3: Resolve theme/color and validate metadata
- [ ] Step 4: Publish to WeChat
- [ ] Step 5: Report completion
Check and load EXTEND.md settings (see Preferences section above).
CRITICAL : If not found, complete first-time setup BEFORE any other steps or questions.
Resolve and store these defaults for later steps:
default_theme (default default)default_color (omit if not set — theme default applies)default_authorneed_open_comment (default 1)only_fans_can_comment (default 0)| Input Type | Detection | Action |
|---|---|---|
| HTML file | Path ends with .html, file exists | Skip to Step 3 |
| Markdown file | Path ends with .md, file exists | Continue to Step 2 |
| Plain text | Not a file path, or file doesn't exist | Save to markdown, continue to Step 2 |
Plain Text Handling :
mkdir -p "$(pwd)/post-to-wechat/$(date +%Y-%m-%d)"
# Save content to: post-to-wechat/yyyy-MM-dd/[slug].md
3. Continue processing as markdown file
Slug Examples :
understanding-ai-modelsai-future (translate to English for slug)Ask publishing method (unless specified in EXTEND.md or CLI):
| Method | Speed | Requirements |
|---|---|---|
api (Recommended) | Fast | API credentials |
browser | Slow | Chrome, login session |
If API Selected - Check Credentials :
# macOS, Linux, WSL, Git Bash
test -f .baoyu-skills/.env && grep -q "WECHAT_APP_ID" .baoyu-skills/.env && echo "project"
test -f "$HOME/.baoyu-skills/.env" && grep -q "WECHAT_APP_ID" "$HOME/.baoyu-skills/.env" && echo "user"
# PowerShell (Windows)
if ((Test-Path .baoyu-skills/.env) -and (Select-String -Quiet -Pattern "WECHAT_APP_ID" .baoyu-skills/.env)) { "project" }
if ((Test-Path "$HOME/.baoyu-skills/.env") -and (Select-String -Quiet -Pattern "WECHAT_APP_ID" "$HOME/.baoyu-skills/.env")) { "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>
Resolve theme (first match wins, do NOT ask user if resolved):
--theme argumentdefault_theme (loaded in Step 0)defaultResolve color (first match wins):
--color argumentdefault_color (loaded in Step 0)Validate metadata from frontmatter (markdown) or HTML meta tags (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)" |
| Author | Use fallback chain: CLI --author → frontmatter author → EXTEND.md default_author |
Auto-Generation Logic :
article_type=news):
--cover if provided.coverImage, featureImage, cover, image).imgs/cover.png.CRITICAL : Publishing scripts handle markdown conversion internally. Do NOT pre-convert markdown to HTML — pass the original markdown file directly. This ensures the API method renders images as <img> tags (for API upload) while the browser method uses placeholders (for paste-and-replace workflow).
Markdown citation default :
--no-cite only if the user explicitly wants to keep ordinary external links inline.API method (accepts .md or .html):
${BUN_X} {baseDir}/scripts/wechat-api.ts <file> --theme <theme> [--color <color>] [--title <title>] [--summary <summary>] [--author <author>] [--cover <cover_path>] [--no-cite]
CRITICAL : Always include --theme parameter. Never omit it, even if using default. Only include --color if explicitly set by user or EXTEND.md.
draft/add payload rules:
POST https://api.weixin.qq.com/cgi-bin/draft/add?access_token=ACCESS_TOKENarticle_type: news (default) or newspicnews, include thumb_media_id (cover is required)need_open_comment (default 1)only_fans_can_comment (default 0)If script parameters do not expose the two comment fields, still ensure final API request body includes resolved values.
Browser method (accepts --markdown or --html):
${BUN_X} {baseDir}/scripts/wechat-article.ts --markdown <markdown_file> --theme <theme> [--color <color>] [--no-cite]
${BUN_X} {baseDir}/scripts/wechat-article.ts --html <html_file>
For API method , include draft management link:
WeChat Publishing Complete!
Input: [type] - [path]
Method: API
Theme: [theme name] [color if set]
Article:
• Title: [title]
• Summary: [summary]
• Images: [N] inline images
• Comments: [open/closed], [fans-only/all users]
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] [color if set]
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)]
| Topic | Reference |
|---|---|
| Image-text parameters, auto-compression | references/image-text-posting.md |
| Article themes, image handling | references/article-posting.md |
| Feature | Image-Text | Article (API) | Article (Browser) |
|---|---|---|---|
| Plain text input | ✗ | ✓ | ✓ |
| HTML input | ✗ | ✓ | ✓ |
| Markdown input | Title/content | ✓ | ✓ |
| Multiple images | ✓ (up to 9) | ✓ (inline) | ✓ (inline) |
| Themes | ✗ | ✓ | ✓ |
| Auto-generate metadata | ✗ | ✓ | ✓ |
Default cover fallback (imgs/cover.png) | ✗ |
For API method :
.baoyu-skills/.envFor Browser method :
Config File Locations (priority order):
<cwd>/.baoyu-skills/.env~/.baoyu-skills/.env| Issue | Solution |
|---|---|
| Missing API credentials | Follow guided setup in Step 2 |
| 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 WECHAT_BROWSER_CHROME_PATH env var |
| Title/summary missing | Use auto-generation or provide manually |
| No cover image | Add frontmatter cover or place imgs/cover.png in article directory |
| Wrong comment defaults | Check EXTEND.md keys need_open_comment and only_fans_can_comment |
Custom configurations via EXTEND.md. See Preferences section for paths and supported options.
Weekly Installs
14.4K
Repository
GitHub Stars
11.3K
First Seen
Jan 19, 2026
Security Audits
Gen Agent Trust HubWarnSocketPassSnykFail
Installed on
opencode13.3K
gemini-cli12.9K
codex12.7K
cursor12.5K
github-copilot12.0K
amp11.6K
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
102,200 周安装
0articles[].only_fans_can_comment in draft/add request |
| Paste keystroke (Linux) | Install xdotool (X11) or ydotool (Wayland) |
| API credentials | Follow guided setup in Step 2, or manually set in .baoyu-skills/.env |
author resolution: CLI --author → frontmatter author → EXTEND.md default_author| ✓ |
| ✗ |
Comment control (need_open_comment, only_fans_can_comment) | ✗ | ✓ | ✗ |
| Requires Chrome | ✓ | ✗ | ✓ |
| Requires API credentials | ✗ | ✓ | ✗ |
| Speed | Medium | Fast | Slow |
| Paste fails | Check system clipboard permissions |