From aec5bcbfab65604681e52ac25dd5b99a66835af6 Mon Sep 17 00:00:00 2001 From: kurihada Date: Wed, 4 Mar 2026 14:22:56 +0800 Subject: [PATCH] feat(skill/xiaohongshu-publish-video): add safe-mode video publish workflow --- skills/xiaohongshu-publish-video/SKILL.md | 214 ++++++++++++++++++ .../agents/openai.yaml | 4 + 2 files changed, 218 insertions(+) create mode 100644 skills/xiaohongshu-publish-video/SKILL.md create mode 100644 skills/xiaohongshu-publish-video/agents/openai.yaml diff --git a/skills/xiaohongshu-publish-video/SKILL.md b/skills/xiaohongshu-publish-video/SKILL.md new file mode 100644 index 0000000..c49da1d --- /dev/null +++ b/skills/xiaohongshu-publish-video/SKILL.md @@ -0,0 +1,214 @@ +--- +name: xiaohongshu-publish-video +description: "Execute XiaoHongShu (小红书) video-note publishing workflow in the creator platform: open publish center, switch to 视频 mode, prepare video assets, upload videos, fill title/body/topics, configure settings, and validate pre-publish state. Use when the user asks to 发布视频笔记, 发视频, or automate web publishing steps before final submit. Prefer user-provided video paths; if no video paths are provided, generate videos via gemini-video-web and consume manifest target paths for upload. Support configurable publish modes (`safe_mode` and `live_mode`)." +--- + +# Xiaohongshu Publish Video + +## Workflow + +1. Confirm account is logged in and creator center is reachable. +2. Open creator publish page and switch to 视频 publishing mode. +3. Prepare video inputs: use user-provided paths first, otherwise generate via gemini-video-web. +4. Upload video and wait for editor panel readiness. +5. Fill title/body/topics and required settings. +6. Validate preview and publish controls. +7. Execute publish behavior according to publish mode. +8. Save publish evidence and return summary. + +## Shared Session Policy + +- Reuse a single Playwright CLI session across all web-automation skills: + - `export PLAYWRIGHT_SHARED_SESSION=codex-shared` +- Use `/Users/xd/java/xhs/tools/pw` as the only Playwright CLI entrypoint. +- Do not pass `--session` directly in skill-specific commands. + +## 1) Enter Creator Publish Page + +- From web homepage, click left sidebar `发布`. +- Expect new tab: `https://creator.xiaohongshu.com/publish/publish?...`. +- Switch to the new tab before continuing. + +## 2) Switch To 视频 Mode + +- Click `上传视频` tab (or equivalent video publish tab text). +- If tab click fails due viewport/position issues: + - Resize viewport to desktop (for example 1440x1000). + - Re-snapshot and retry with latest refs. +- Use `上传视频` area visibility as the final switch-success signal. +- Do not treat tab text click success as completion by itself. + +## 3) Prepare Videos + +- Prefer user-provided absolute file paths when available. +- If user did not provide video paths: + - Generate videos from topic/content using `gemini-video-web`. + - Read the generated manifest JSON and extract `files[*].target_path`. + - Use manifest-derived paths as upload input. +- Ensure at least 1 valid video path exists before entering upload. + +Manifest linkage rules: + +- Trust manifest `status=ok` and `collected_count>=1` before upload. +- If manifest status is not ok, stop and return video-preparation failure. +- Avoid guessing latest files by timestamp when manifest is available. + +## 4) Upload Video + +- Click `上传视频` to open file chooser. +- Upload absolute file paths from Step 3. +- After upload, verify editor state: + - video preview area is visible + - title and body input areas are visible + - upload progress indicator is complete + +Video readiness rule: + +- Wait until transcoding/upload state is done before publish checks. +- If status stays processing beyond timeout, retry snapshot and wait once. +- If still processing, block final publish. + +## 5) Fill Core Content + +- Fill title textbox (`填写标题会有更多赞哦` or equivalent). +- Fill body contenteditable area. +- Insert topics (mandatory): + - Click recommended topic chips, and/or + - Use `话题` button for manual insertion. + - Validate final topic count from actual editor content, not click count. + - Ensure total topic count is >= 5 before proceeding. +- Verify body counter and preview panel update. + +Topic counting rule: + +- Count inserted topic tokens in正文内容(例如 `#话题`)。 +- If token count < 5, continue inserting until count >= 5. +- If repeated insertion still fails to reach 5, block final publish. + +Title/body rule: + +- Title must be non-empty and specific to the video content. +- Body must be non-empty and descriptive (recommended >= 20 Chinese characters). +- If either title or body is empty, block final publish. + +## 6) Configure Settings + +- Do not add location. +- Review content settings: + - `原创声明` + - `公开可见` + - `定时发布` + - other toggles as needed by request. +- Ignore geolocation prompts/errors and keep location empty. + +Video-specific checks: + +- If cover selection is available, confirm a cover is selected. +- If music/subtitle/licensing controls appear, keep defaults unless user explicitly requests changes. + +## 7) Validate Pre-Publish State + +- Confirm right-side preview reflects title/body/topics. +- Confirm title is non-empty. +- Confirm body is non-empty (recommended >= 20 Chinese characters). +- Confirm topic count is >= 5. +- Confirm no location tag is present in preview. +- Confirm uploaded video count is >= 1. +- Confirm video is ready (no active processing indicator). +- Confirm bottom actions are visible: + - `暂存离开` + - `发布` +- Publish hard gate (must all pass): + - title is non-empty + - body is non-empty (recommended >= 20 Chinese characters) + - video count >= 1 + - topic count >= 5 + - location is empty + - video ready state is true +- Default safety behavior: + - Do not click final `发布` unless user explicitly asks for real submission now. + +## 8) Publish Mode + +- `safe_mode` (default): + - Run full workflow and hard-gate checks. + - Never click final `发布`. +- `live_mode`: + - Require explicit user intent for real posting in current turn. + - Click final `发布` only after hard-gate checks pass. + +## 9) Failure Handling (Layered Retries) + +- Video preparation failure: + - If user paths are invalid, ask for corrected absolute paths. + - If gemini generation fails, stop publish flow and return failure reason. +- Manifest linkage failure: + - If manifest missing/invalid/empty, retry reading once. + - If still invalid, stop and return manifest failure. +- Upload failure: + - If upload area blocks or file chooser fails, re-snapshot and retry once. + - If still failing, stop and report upload failure. +- Video processing timeout: + - Retry waiting once with refreshed snapshot. + - If still not ready, block final publish. +- Content validation failure: + - If title/body is empty, refill once and re-check. + - If still empty, block final publish. +- Topic insertion failure: + - Retry insertion via alternate path (chip -> manual topic button). + - If topic count stays < 5, block final publish. +- UI interaction failure: + - On stale refs/click interception/modal cover, wait briefly, re-snapshot, retry once. +- Publish action failure: + - If publish click fails, re-snapshot and retry click once. + - If success page still not reached, return publish-step failure. +- Publish gate failure: + - If any hard gate fails, do not click `发布`; return blocking conditions. + +## 10) Reliability Rules + +- Re-snapshot after: + - tab switches + - upload completion + - dropdown/modal open/close +- On click interception or stale refs: + - wait briefly + - refresh snapshot + - retry with updated refs. + +## 11) Save Publish Evidence + +- On successful live publish: + - Wait for success indicator (for example `发布成功`). + - Capture success screenshot to: + - `/Users/xd/java/xhs/output/playwright/xhs-video-publish-success-.png` + - Record: + - publish time + - title + - uploaded video path list + - screenshot path + +## 12) Return Report + +Return a compact execution summary: + +- uploaded videos count +- title/body/topic/location/video-ready status +- settings changed +- publish mode used (`safe_mode` or `live_mode`) +- whether final publish was intentionally skipped or executed +- evidence info when published (success marker, screenshot path, publish time) + +## Boundaries + +- Do not post misleading or spam content. +- Do not publish real content without clear user confirmation in current turn. +- Do not modify unrelated account settings. +- Never add location information. +- Never proceed to final publish when topic count is < 5. +- Never proceed to final publish when title is empty. +- Never proceed to final publish when body is empty. +- Never proceed to final publish when uploaded video count is < 1. +- Never proceed to final publish when location is non-empty. +- Never proceed to final publish when video processing is unfinished. +- Default to `safe_mode` unless user clearly requests real posting now. diff --git a/skills/xiaohongshu-publish-video/agents/openai.yaml b/skills/xiaohongshu-publish-video/agents/openai.yaml new file mode 100644 index 0000000..9646df4 --- /dev/null +++ b/skills/xiaohongshu-publish-video/agents/openai.yaml @@ -0,0 +1,4 @@ +interface: + display_name: "XHS Publish Video" + short_description: "Publish XHS video notes with manifest linkage, hard gates, and publish modes" + default_prompt: "Use $xiaohongshu-publish-video with PLAYWRIGHT_SHARED_SESSION=codex-shared and run all browser steps via /Users/xd/java/xhs/tools/pw; publish XiaoHongShu video notes by preferring user video paths, otherwise generate via $gemini-video-web and use manifest target paths, enforce hard gates (videos>=1, topics>=5, no location, video-ready=true), and run in safe_mode by default unless live_mode is explicitly requested."