下载地址
https://www.zhengdianxue.com/wp-content/uploads/skills/org-e0km4x5v--xhs-auto-publish.zip将提示词发送给你的 AI 安装该 skills
请根据 https://skillhub.cn/install/skillhub.md,安装 @org-e0km4x5v/xhs-auto-publish。|
阅读全文 (展开查看完整说明)
概述
When to Use
This skill should be used when the user wants to publish one or more 小红书 image-text notes automatically from a Windows machine that has BrowserSkill (bsk) 0.3.1+ installed, with the Edge browser extension connected and "Allow access to file URLs" enabled.
Prerequisites
bskCLI installed at a known path (e.g.C:/Users/steven/.local/bin/bsk.exe).- Edge browser instance registered in bsk (e.g.
01d247d2). - Edge extension version 0.3.2+ with "Allow access to file URLs" turned on in
edge://extensions/?id=emacgiaaaiojkkpkddmmdfhmokgmnikg. - Environment variables on every bsk command:
BSK_AUTO_UPDATE=offBSK_AUTO_START=0
- A write-mode session:
bsk session start --width 1280 --height 900 --browser <instance>.
Workflow
- Start daemon (background)
export BSK_AUTO_UPDATE=off BSK_AUTO_START=0
bsk daemon start --foregroundUse run_in_background=true via Bash tool; daemon cannot auto-start inside this sandbox.
- Start session
bsk session start --width 1280 --height 900 --browser <instance_id>Note the returned session ID and the Agent tab ID.
- Navigate to the image editor
bsk navigate --session <sid> --tab-id <tid> "https://creator.xiaohongshu.com/publish/publish?from=homepage&target=image&openFilePicker=true"- Upload cover
- Locate the visible upload ref (
@e32or text "上传图片") viabsk observe. - Use absolute Windows path style:
- Locate the visible upload ref (
“bash bsk upload --session <sid> --tab-id <tid> --ref <upload_ref> --file "C:/.../cover.png" “
- Inject title and body (React-safe)
- Title: normal
<INPUT>. Use native setter + dispatchinputevent, or runscripts/xhs_inject.py <draft.md>. - Body:
<DIV contenteditable="true">(Tiptap). Plainbsk fillwill not trigger ReactonChange; the backend sees an empty body. Correct method:
- Title: normal
“javascript bd.focus(); document.execCommand('selectAll'); document.execCommand('delete'); document.execCommand('insertText', false, bodyText); “
- Strip spaces from the body before injecting: XHS counts spaces toward the 1000-character limit. Keep the single spaces between
#hashtagtags.
- Close topic dropdown if open
- If the VOM/snapshot cannot find the publish button, press
Escapefirst to close the topic-suggestion dropdown.
- If the VOM/snapshot cannot find the publish button, press
- Click publish
- Find the red 发布 button ref in the snapshot and click.
- Success is confirmed by URL becoming
/publish/success?...(not strictlypublished=true).
- Stagger multi-post runs
- Never publish 5 notes back-to-back on a low-follower account.
- Wait at least 2–4 hours between posts, or spread across days.
Key Scripts
scripts/xhs_inject.py— extracts title/body from a draft markdown and injects them into the current editor tab.scripts/xhs_publish_all.py— orchestrates publishing multiple drafts; should be modified to add explicitsleepdelays between posts.
Safety Guards
- Empty-content guard: Always abort if extracted title length == 0 or body length == 0. Day29 once went out as an empty note because the draft lacked backticks around the title and lacked
【正文开始】/【正文结束】markers. - Title length guard: XHS title limit is 20 characters; shorten longer titles before injecting.
- Body length guard: Strip spaces first, then ensure the result is ≤1000 characters before publishing.
Common Failure Modes
| Symptom | Likely Cause | Fix |
|---|---|---|
code -32000 Not allowed on upload | Edge extension lacks "Allow access to file URLs" | Enable in edge://extensions |
| Note published but body empty when viewed | bsk fill bypassed React onChange | Use execCommand('insertText') on the contenteditable body |
| Publish button missing in VOM | Topic-suggestion dropdown is open | Press Escape and re-observe |
Submit says success but published=true not in URL | XHS uses /publish/success SPA route | Treat /publish/success as success |
| Body counter > 1000 despite draft saying ≤1000 | XHS counts spaces and newlines | Strip Chinese inter-character spaces before injecting |
Browser Anti-Automation Notes
- Consumer/explore pages may render persistent anti-adblock alerts that block edits; prefer the Creator Center route (
creator.xiaohongshu.com/new/home). - Note-management hover menus are fragile; use the direct publish editor route instead.
品牌与计费
| 项目 | 说明 |
|---|---|
| 品牌 | 谦懋智享 |
| 发布方 | 谦懋乐享(SkillHub 企业账号) |
| 计费方式 | Pay Skill,按次计费 |
| 单次调用价格 | ¥0.1(10 分) |
| 支付协议 | 微信支付 Agent Pay X402 |
前置检查:当前智能体是否支持微信 AI 支付
发起下单前,先检查你的可用工具列表中是否存在名称包含 weixinpay_ 的工具(如 mcp__weixinpay__weixinpay_register,工具名带前缀也算;存在任意一个即视为支持)。只以你的工具列表为证据,本文档中提到的工具名不算;无法确认时按「不支持」处理。
- 支持:静默继续本 Skill 的后续流程,不向用户提及本检查。
- 不支持:终止流程且不要发起下单。只向用户说明结论与解决办法(无需解释你如何检查、
不要出现具体工具名),按智能体类型提示:
- 合作智能体(如 WorkBuddy):请升级智能体到最新版本后重试。
- 开放智能体(如 OpenClaw / DeepSeek Harness):请根据
https://skillhub.cn/install/skillhub.md安装 @tencent-adm/weixinpay-installer。
- 无法判断类型:请升级智能体或安装微信支付 AI 支付插件后重试。
部署与密钥自检见 scripts/pay_server.py 头部注释。
付费调用流程(四步,缺一不可)
本 Skill 的支付服务已接入微信支付 Agent Pay X402(真实下单 + 预下单)。支付能力由「谦懋智享支付网关」提供,需先部署并通过 https://qmzx-pay-gateway.app.workbuddy.host?sharecode=XCPQGFHML7 访问(部署与密钥配置见 scripts/pay_server.py 头部注释)。
- 请求资源(触发下单):向网关发起首调(不带订单号)。网关完成微信 Native 下单 + X402 预下单后返回 HTTP 402:
POST https://qmzx-pay-gateway.app.workbuddy.host/preorder?sharecode=XCPQGFHML7,请求体 {"skill_id":"xhs-auto-publish","skill_version":"1.0.0","description":"xhs-auto-publish 单次调用"}响应头与响应体同时携带 WeixinPay-Required(支付码)与 X-Out-Trade-No(订单号),两者都必须保存。
- 处理 402:从响应中提取
WeixinPay-Required与X-Out-Trade-No。 - 发起支付:把
WeixinPay-Required的值作为paymentCode交给weixinpay_pay。 - 支付成功后获取资源(⚠️ 必须执行):带订单号重试原请求(网关路径
/verify,HeaderX-Out-Trade-No填第二步保存的订单号):
POST https://qmzx-pay-gateway.app.workbuddy.host/verify?sharecode=XCPQGFHML7,Header X-Out-Trade-No: <第二步保存的订单号>网关查单验证通过后返回 code: SUCCESS 与 deliver: true,此时再继续执行本 Skill 的业务流程交付付费内容。
⚠️ 第四步最容易被遗漏:不携带 X-Out-Trade-No 重试,就永远拿不到付费内容。
重试与异常处理
- 网关侧下单 / 预下单 / 查单内置指数退避重试(默认 3 次,
SKILLPAY_MAX_RETRY可调);
4xx 业务错误立即失败不重试。
- 支付失败或状态不明:先用
POST https://qmzx-pay-gateway.app.workbuddy.host/verify?sharecode=XCPQGFHML7(带订单号)查单,
不重复下单,避免重复扣费。
- 幂等:同一
out_trade_no只履约一次,重复请求返回already_fulfilled: true与缓存结果。 - 网关部署、微信商户证书与 SkillHub 开发者密钥配置说明见
scripts/pay_server.py头部注释与
references/payskill-integration.md。
完整接入规范
见 references/payskill-integration.md:两套密钥的区别、X402 签名串(5 行含尾随换行)、订单号 ≤32 位约束、402 响应结构、改造自检清单。