Loading...
Loading...
Compare original and translation side by side
SKILL_DIR${SKILL_DIR}/scripts/<name>.ts| Script | Purpose |
|---|---|
| Image-text posts (图文) |
| Article posting via browser (文章) |
| Article posting via API (文章) |
| Verify environment & permissions |
SKILL_DIR${SKILL_DIR}/scripts/<name>.ts| 脚本 | 用途 |
|---|---|
| 发布贴图(图文)内容 |
| 通过浏览器发布文章 |
| 通过API发布文章 |
| 验证环境与权限 |
undefinedundefined
┌────────────────────────────────────────────────────────┬───────────────────┐
│ Path │ Location │
├────────────────────────────────────────────────────────┼───────────────────┤
│ .canghe-skills/canghe-post-to-wechat/EXTEND.md │ Project directory │
├────────────────────────────────────────────────────────┼───────────────────┤
│ $HOME/.canghe-skills/canghe-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](references/config/first-time-setup.md)) → Save → Continue │
└───────────┴───────────────────────────────────────────────────────────────────────────┘
**EXTEND.md Supports**: Default theme | 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](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` | `0` | `articles[].only_fans_can_comment` in `draft/add` request |
**Recommended EXTEND.md example**:
```md
default_theme: default
default_publish_method: api
default_author: 苍何
need_open_comment: 1
only_fans_can_comment: 0
chrome_profile_path: /path/to/chrome/profile
┌────────────────────────────────────────────────────────┬───────────────────┐
│ 路径 │ 位置类型 │
├────────────────────────────────────────────────────────┼───────────────────┤
│ .canghe-skills/canghe-post-to-wechat/EXTEND.md │ 项目目录 |
├────────────────────────────────────────────────────────┼───────────────────┤
│ $HOME/.canghe-skills/canghe-post-to-wechat/EXTEND.md │ 用户主目录 │
└────────────────────────────────────────────────────────┴───────────────────┘
┌───────────┬───────────────────────────────────────────────────────────────────────────┐
│ 检查结果 │ 对应操作 │
├───────────┼───────────────────────────────────────────────────────────────────────────┤
│ 已找到 │ 读取、解析并应用配置 │
├───────────┼───────────────────────────────────────────────────────────────────────────┤
│ 未找到 │ 执行首次设置([references/config/first-time-setup.md](references/config/first-time-setup.md)) → 保存配置 → 继续操作 │
└───────────┴───────────────────────────────────────────────────────────────────────────┘
**EXTEND.md支持配置项**:默认主题 | 默认发布方式(api/browser) | 默认作者 | 默认开启评论开关 | 默认仅粉丝可评论开关 | Chrome配置文件路径
首次设置指引:[references/config/first-time-setup.md](references/config/first-time-setup.md)
**最低支持配置项**(大小写不敏感,接受`1/0`或`true/false`):
| 配置项 | 默认值 | 说明 |
|-----|---------|---------|
| `default_author` | 空 | 当CLI/前置元数据未提供`author`时的 fallback 值 |
| `need_open_comment` | `1` | 对应`draft/add`请求中`articles[].need_open_comment`字段 |
| `only_fans_can_comment` | `0` | 对应`draft/add`请求中`articles[].only_fans_can_comment`字段 |
**推荐的EXTEND.md示例**:
```md
default_theme: default
default_publish_method: api
default_author: 苍何
need_open_comment: 1
only_fans_can_comment: 0
chrome_profile_path: /path/to/chrome/profilenpx -y bun ${SKILL_DIR}/scripts/check-permissions.ts| Check | Fix |
|---|---|
| Chrome | Install Chrome or set |
| Profile dir | Ensure |
| Bun runtime | |
| Accessibility (macOS) | System Settings → Privacy & Security → Accessibility → enable terminal app |
| Clipboard copy | Ensure Swift/AppKit available (macOS Xcode CLI tools: |
| Paste keystroke (macOS) | Same as Accessibility fix above |
| Paste keystroke (Linux) | Install |
| API credentials | Follow guided setup in Step 5, or manually set in |
npx -y bun ${SKILL_DIR}/scripts/check-permissions.ts| 检查项 | 修复方案 |
|---|---|
| Chrome浏览器 | 安装Chrome或设置环境变量 |
| 配置文件目录 | 确保 |
| Bun运行时 | 执行 |
| 无障碍权限(macOS) | 系统设置 → 隐私与安全性 → 无障碍 → 启用终端应用权限 |
| 剪贴板复制 | 确保Swift/AppKit可用(macOS需安装Xcode CLI工具: |
| 粘贴快捷键(macOS) | 与上述无障碍权限修复方案一致 |
| 粘贴快捷键(Linux) | 安装 |
| API凭证 | 按照步骤5的引导设置,或手动在 |
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 --submitnpx -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 --submitPublishing 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, cover)
- [ ] 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:反馈完成结果default_authorneed_open_comment1only_fans_can_comment0default_authorneed_open_comment1only_fans_can_comment0| 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 |
mkdir -p "$(pwd)/post-to-wechat/$(date +%Y-%m-%d)"| 输入类型 | 检测方式 | 操作 |
|---|---|---|
| HTML文件 | 路径以 | 直接跳至步骤4 |
| Markdown文件 | 路径以 | 继续执行步骤2 |
| 纯文本 | 不是文件路径或文件不存在 | 保存为Markdown文件后,继续执行步骤2 |
mkdir -p "$(pwd)/post-to-wechat/$(date +%Y-%m-%d)"
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).htmlundefined.htmlundefined
| Result | Action |
|--------|--------|
| Found | Read its SKILL.md, continue to Step 3 |
| Multiple skills | AskUserQuestion to choose |
| Not found | Show installation suggestion |
**When Not Found**:
undefined
| 检测结果 | 操作 |
|--------|--------|
| 已找到 | 读取其SKILL.md,继续执行步骤3 |
| 存在多个技能 | 询问用户选择具体技能 |
| 未找到 | 显示安装建议 |
**未找到技能时的提示**:
undefined.html| Theme | Description |
|---|---|
| 经典主题 - 传统排版,标题居中带底边,二级标题白字彩底 |
| 优雅主题 - 文字阴影,圆角卡片,精致引用块 |
| 简洁主题 - 现代极简风,不对称圆角,清爽留白 |
npx -y bun ${MD_TO_HTML_SKILL_DIR}/scripts/main.ts <markdown_file> --theme <theme>htmlPathtitleauthorsummarycontentImages.html| 主题 | 描述 |
|---|---|
| 经典主题 - 传统排版,标题居中带底边,二级标题白字彩底 |
| 优雅主题 - 文字阴影,圆角卡片,精致引用块 |
| 简洁主题 - 现代极简风,不对称圆角,清爽留白 |
npx -y bun ${MD_TO_HTML_SKILL_DIR}/scripts/main.ts <markdown_file> --theme <theme>htmlPathtitleauthorsummarycontentImages| 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 |
article_type=news--covercoverImagefeatureImagecoverimageimgs/cover.png| 字段 | 缺失时的处理 |
|---|---|
| 标题 | 提示:"请输入标题,或按回车键从内容自动生成" |
| 摘要 | 提示:"请输入摘要,或按回车键自动生成(推荐用于SEO)" |
| 作者 | 使用 fallback 链:CLI参数 |
article_type=news--covercoverImagefeatureImagecoverimageimgs/cover.png| Method | Speed | Requirements |
|---|---|---|
| Fast | API credentials |
| Slow | Chrome, login session |
undefined| 方式 | 速度 | 要求 |
|---|---|---|
| 快 | 需要API凭证 |
| 慢 | 需要Chrome浏览器及登录会话 |
undefined
**If Credentials Missing - Guide Setup**:
After location choice, prompt for values and write to `.env`:
undefined
**若凭证缺失 - 引导配置**:
用户选择保存位置后,提示输入凭证值并写入`.env`:
undefinednpx -y bun ${SKILL_DIR}/scripts/wechat-api.ts <html_file> [--title <title>] [--summary <summary>] [--author <author>] [--cover <cover_path>]draft/addPOST https://api.weixin.qq.com/cgi-bin/draft/add?access_token=ACCESS_TOKENarticle_typenewsnewspicnewsthumb_media_idneed_open_comment1only_fans_can_comment0author--authorauthordefault_authornpx -y bun ${SKILL_DIR}/scripts/wechat-article.ts --html <html_file>npx -y bun ${SKILL_DIR}/scripts/wechat-api.ts <html_file> [--title <title>] [--summary <summary>] [--author <author>] [--cover <cover_path>]draft/addPOST https://api.weixin.qq.com/cgi-bin/draft/add?access_token=ACCESS_TOKENarticle_typenewsnewspicnewsthumb_media_idneed_open_comment1only_fans_can_comment0author--authorauthordefault_authornpx -y bun ${SKILL_DIR}/scripts/wechat-article.ts --html <html_file>WeChat Publishing Complete!
Input: [type] - [path]
Method: API
Theme: [theme name]
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]
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
使用主题:[主题名称]
文章信息:
• 标题:[标题]
• 摘要:[摘要]
• 内嵌图片数量:[N]
• 评论设置:[开启/关闭],[仅粉丝可评论/所有用户可评论]
发布结果:
✓ 草稿已保存至微信公众号
• media_id: [media_id]
后续操作:
→ 管理草稿:https://mp.weixin.qq.com(登录后进入「内容管理」→「草稿箱」)
生成的文件:
[• post-to-wechat/yyyy-MM-dd/slug.md(若输入为纯文本)]
[• slug.html(转换后的HTML文件)]微信公众号发布完成!
输入内容:[类型] - [路径]
发布方式:浏览器
使用主题:[主题名称]
文章信息:
• 标题:[标题]
• 摘要:[摘要]
• 内嵌图片数量:[N]
发布结果:
✓ 草稿已保存至微信公众号
生成的文件:
[• post-to-wechat/yyyy-MM-dd/slug.md(若输入为纯文本)]
[• slug.html(转换后的HTML文件)]| 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 | 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 | ✗ | ✓ | ✓ |
Default cover fallback ( | ✗ | ✓ | ✗ |
Comment control ( | ✗ | ✓ | ✗ |
| Requires Chrome | ✓ | ✗ | ✓ |
| Requires API credentials | ✗ | ✓ | ✗ |
| Speed | Medium | Fast | Slow |
| 功能 | 贴图 | 文章(API方式) | 文章(浏览器方式) |
|---|---|---|---|
| 纯文本输入 | ✗ | ✓ | ✓ |
| HTML输入 | ✗ | ✓ | ✓ |
| Markdown输入 | 仅标题/内容 | ✓(需依赖技能) | ✓(需依赖技能) |
| 多张图片 | ✓(最多9张) | ✓(内嵌) | ✓(内嵌) |
| 主题支持 | ✗ | ✓ | ✓ |
| 元数据自动生成 | ✗ | ✓ | ✓ |
默认封面 fallback( | ✗ | ✓ | ✗ |
评论控制( | ✗ | ✓ | ✗ |
| 依赖Chrome浏览器 | ✓ | ✗ | ✓ |
| 依赖API凭证 | ✗ | ✓ | ✗ |
| 发布速度 | 中等 | 快 | 慢 |
.canghe-skills/.envcanghe-markdown-to-html<cwd>/.canghe-skills/.env~/.canghe-skills/.env.canghe-skills/.envcanghe-markdown-to-html<cwd>/.canghe-skills/.env~/.canghe-skills/.env| 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 |
| No cover image | Add frontmatter cover or place |
| Wrong comment defaults | Check |
| Paste fails | Check system clipboard permissions |
| 问题 | 解决方案 |
|---|---|
| 未找到Markdown转HTML技能 | 从推荐地址安装 |
| API凭证缺失 | 按照步骤5的引导配置 |
| Access Token错误 | 检查API凭证是否有效且未过期 |
| 未登录(浏览器方式) | 首次运行会打开浏览器 - 扫码登录即可 |
| 未找到Chrome浏览器 | 设置环境变量 |
| 标题/摘要缺失 | 使用自动生成功能或手动提供 |
| 无封面图片 | 添加前置元数据封面字段,或在文章目录下放置 |
| 评论默认值错误 | 检查EXTEND.md中的 |
| 粘贴失败 | 检查系统剪贴板权限 |