An automation tool for publishing content to WeChat Official Accounts. Core features: - Image-and-text publishing: multi-image with caption mode, supports up to 9 images - Article publishing: full Markdown formatting, preserves styles and layout - Automated workflow: uses Chrome CDP to automatically log in, fill forms, and publish - Intelligent compression: automatically compresses titles and content when they exceed limits - Theme support: article publishing supports the default, grace, and simple themes When to use: - The user explicitly requests "publish to WeChat Official Account" or "send to public account" - The user provides a Markdown file or content that needs to be published - The user needs to bulk publish image-and-text content Not suitable for: - The user is only asking how to publish (provide suggestions instead) - The user needs to edit an existing Official Account article (manual operation) - The user needs to publish to other platforms (use the corresponding platform tools)
自动化发布内容到微信公众号, 支持图文和文章两种模式。
# 从 markdown 文件和图片目录生成
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 img1.png --image img2.png --submit
# 仅预览不保存
npx -y bun ${SKILL_DIR}/scripts/wechat-browser.ts --markdown article.md --images ./images/
# 发布 markdown 文章 (默认主题)
npx -y bun ${SKILL_DIR}/scripts/wechat-article.ts --markdown article.md
# 指定主题
npx -y bun ${SKILL_DIR}/scripts/wechat-article.ts --markdown article.md --theme grace
npx -y bun ${SKILL_DIR}/scripts/wechat-article.ts --markdown article.md --theme simple
# 覆盖标题和作者
npx -y bun ${SKILL_DIR}/scripts/wechat-article.ts --markdown article.md --title "自定义标题" --author "作者名"
说明: ${SKILL_DIR} 代表本技能的安装目录, Agent 会在运行时替换为实际路径。
指定 Markdown 文件路径, 自动提取标题和内容。
参数类型: 文件路径 (可选)
功能说明:
使用示例:
npx -y bun ${SKILL_DIR}/scripts/wechat-browser.ts --markdown ./article.md --images ./pics/
Markdown 格式:
---
title: 文章标题
author: 作者名
---
# 这是标题 (如果没有 frontmatter)
这是首段内容, 会被提取为图文内容...
最佳实践:
指定图片目录, 上传目录中所有图片。
参数类型: 目录路径 (可选)
功能说明:
使用示例:
npx -y bun ${SKILL_DIR}/scripts/wechat-browser.ts --markdown article.md --images ./images/
最佳实践:
01-cover.png, 02-content.png直接指定文章标题。
参数类型: 字符串 (可选)
限制: 最多 20 字, 超出自动压缩
使用示例:
npx -y bun ${SKILL_DIR}/scripts/wechat-browser.ts --title "如何提升效率" --content "内容..." --image cover.png
压缩规则:
最佳实践:
直接指定文章内容。
参数类型: 字符串 (可选)
限制: 最多 1000 字, 超出自动压缩
使用示例:
npx -y bun ${SKILL_DIR}/scripts/wechat-browser.ts --title "标题" --content "这是内容..." --image img.png
最佳实践:
指定单个图片文件, 可重复使用添加多张图片。
参数类型: 文件路径 (可选, 可重复)
限制: 最多 9 张图片
使用示例:
npx -y bun ${SKILL_DIR}/scripts/wechat-browser.ts --title "标题" --content "内容" --image img1.png --image img2.png --image img3.png
最佳实践:
保存为草稿, 默认仅预览不保存。
参数类型: 布尔标志 (可选)
默认行为: 不保存, 仅预览
使用场景:
使用示例:
# 仅预览
npx -y bun ${SKILL_DIR}/scripts/wechat-browser.ts --markdown article.md --images ./pics/
# 保存为草稿
npx -y bun ${SKILL_DIR}/scripts/wechat-browser.ts --markdown article.md --images ./pics/ --submit
注意事项:
指定 Chrome 配置文件目录, 保持登录状态。
参数类型: 目录路径 (可选)
默认行为: 使用临时配置文件
使用场景:
使用示例:
npx -y bun ${SKILL_DIR}/scripts/wechat-browser.ts --markdown article.md --images ./pics/ --profile ~/.chrome-wechat
最佳实践:
指定要转换和发布的 Markdown 文件。
参数类型: 文件路径 (必需)
功能说明:
使用示例:
npx -y bun ${SKILL_DIR}/scripts/wechat-article.ts --markdown article.md
支持的 Markdown 语法:
#, ##, ###**text***text*-, 1.>```[text](url)最佳实践:
指定文章主题样式。
参数类型: 字符串 (可选)
可选值:
default - 默认主题, 简洁大方grace - 优雅主题, 适合正式内容simple - 极简主题, 突出内容本身默认值: default
使用示例:
npx -y bun ${SKILL_DIR}/scripts/wechat-article.ts --markdown article.md --theme grace
主题特点:
| 主题 | 适用场景 | 特点 | |------|----------|------| | default | 通用内容 | 平衡美观和可读性 | | grace | 正式文章、专业内容 | 优雅排版, 强调层次 | | simple | 技术文档、教程 | 极简风格, 突出内容 |
最佳实践:
覆盖从 Markdown 提取的标题。
参数类型: 字符串 (可选)
默认行为: 从 Markdown frontmatter 或 H1 提取
使用示例:
npx -y bun ${SKILL_DIR}/scripts/wechat-article.ts --markdown article.md --title "自定义标题"
使用场景:
指定文章作者名。
参数类型: 字符串 (可选)
默认值: 宝玉
使用示例:
npx -y bun ${SKILL_DIR}/scripts/wechat-article.ts --markdown article.md --author "张三"
最佳实践:
指定文章摘要。
参数类型: 字符串 (可选)
使用示例:
npx -y bun ${SKILL_DIR}/scripts/wechat-article.ts --markdown article.md --summary "这是一篇关于..."
最佳实践:
使用预渲染的 HTML 文件替代 Markdown。
参数类型: 文件路径 (可选)
使用场景:
使用示例:
npx -y bun ${SKILL_DIR}/scripts/wechat-article.ts --html article.html
注意事项:
指定 Chrome 配置文件目录。
参数类型: 目录路径 (可选)
功能: 与图文发表的 --profile 参数相同
| 功能 | 图文发表 | 文章发表 | |------|----------|----------| | 多图支持 | 支持 (最多 9 张) | 支持 (内联图片) | | Markdown 支持 | 标题/内容提取 | 完整格式化 | | 自动标题压缩 | 支持 (压缩到 20 字) | 不支持 | | 内容压缩 | 支持 (压缩到 1000 字) | 不支持 | | 主题支持 | 不支持 | 支持 (default, grace, simple) | | 适用场景 | 快速发布多图内容 | 长文章、技术文档 |
解析内容:
处理图片:
自动化发布:
输出结果:
解析 Markdown:
生成 HTML:
[[IMAGE_PLACEHOLDER_N]]自动化发布:
替换图片:
输出结果:
bun 运行时 (通过 npx -y bun 自动安装)问题: 每次运行都需要扫码登录
解决方案: 使用 --profile 参数指定配置文件目录
npx -y bun ${SKILL_DIR}/scripts/wechat-browser.ts --markdown article.md --images ./pics/ --profile ~/.chrome-wechat
问题: 登录后立即退出
解决方案:
问题: 图片上传失败
解决方案:
问题: 图片顺序错误
解决方案:
01-, 02-, 03-问题: 标题被压缩
解决方案:
问题: 内容被压缩
解决方案:
问题: 找不到 Chrome
解决方案: 设置环境变量
export WECHAT_BROWSER_CHROME_PATH="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
问题: 粘贴失败
解决方案:
所有脚本位于本技能的 scripts/ 子目录中。
Agent 执行说明:
SKILL_DIR${SKILL_DIR}/scripts/<script-name>.ts${SKILL_DIR} 替换为实际路径可用脚本:
| 脚本 | 用途 | 说明 |
|------|------|------|
| wechat-browser.ts | 图文发表 | 多图配文模式 |
| wechat-article.ts | 文章发表 | 完整 Markdown 格式 |
| md-to-wechat.ts | Markdown 转换 | 转换为微信 HTML |
| copy-to-clipboard.ts | 剪贴板操作 | 复制内容到剪贴板 |
| paste-from-clipboard.ts | 粘贴操作 | 发送真实粘贴按键 |
# 场景: 有一篇 markdown 文章和一个图片目录
npx -y bun ${SKILL_DIR}/scripts/wechat-browser.ts --markdown ./article.md --images ./xhs-images/
# 执行流程:
# 1. 解析 markdown 元数据:
# - 标题: "如何在一天内彻底重塑你的人生" → "一天内重塑你的人生"
# - 作者: 从 frontmatter 或使用默认值
# 2. 从首段提取内容
# 3. 在 xhs-images/ 中找到 7 张图片
# 4. 打开 Chrome, 导航到微信"图文"编辑器
# 5. 上传所有图片
# 6. 填充标题和内容
# 7. 报告: "图文已发布, 包含 7 张图片。"
# 场景: 发布一篇技术文章, 使用 simple 主题
npx -y bun ${SKILL_DIR}/scripts/wechat-article.ts --markdown ./tech-article.md --theme simple
# 执行流程:
# 1. 解析 markdown, 找到 5 张图片
# 2. 生成带占位符的 HTML
# 3. 打开 Chrome, 导航到微信编辑器
# 4. 粘贴 HTML 内容
# 5. 对每张图片:
# - 选中 [[IMAGE_PLACEHOLDER_1]]
# - 滚动到可见区域
# - 按 Backspace 删除
# - 粘贴图片
# 6. 报告: "文章已编排, 包含 5 张图片。"
# 场景: 批量发布多篇文章
for file in articles/*.md; do
npx -y bun ${SKILL_DIR}/scripts/wechat-browser.ts \
--markdown "$file" \
--images "images/$(basename $file .md)/" \
--submit \
--profile ~/.chrome-wechat
done
# 场景: 完全自定义标题、内容和图片
npx -y bun ${SKILL_DIR}/scripts/wechat-browser.ts \
--title "2024 年度总结" \
--content "回顾这一年的成长与收获..." \
--image cover.png \
--image chart1.png \
--image chart2.png \
--submit
通过 EXTEND.md 自定义配置。
检查路径 (优先级顺序):
.pw-skills/pw-post-to-wechat/EXTEND.md (项目级)~/.pw-skills/pw-post-to-wechat/EXTEND.md (用户级)如果找到, 在工作流之前加载。扩展内容会覆盖默认值。
references/image-text-posting.md 了解详细的图文发表指南references/article-posting.md 了解详细的文章发表指南Edit PDFs with natural-language instructions using the nano-pdf CLI.
Control Sonos speakers (discover/status/play/volume/group).
Terminal Spotify playback/search via spogo (preferred) or spotify_player.
Capture frames or clips from RTSP/ONVIF cameras.
CLI to manage emails via IMAP/SMTP. Use `himalaya` to list, read, write, reply, forward, search, and organize emails from the terminal. Supports multiple accounts and message composition with MML (MIME Meta Language).
Monitor blogs and RSS/Atom feeds for updates using the blogwatcher CLI.
Category:tools