@acedatacloud/skills 2026.713.4 → 2026.713.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/package.json +1 -1
  2. package/skills/xiaohongshu/README.md +36 -0
  3. package/skills/xiaohongshu/SKILL.md +173 -0
  4. package/skills/xiaohongshu/requirements.txt +1 -0
  5. package/skills/xiaohongshu/scripts/vendor/LICENSE.autoclaw-xiaohongshu-skills +21 -0
  6. package/skills/xiaohongshu/scripts/vendor/title_utils.py +57 -0
  7. package/skills/xiaohongshu/scripts/vendor/xhs/__init__.py +1 -0
  8. package/skills/xiaohongshu/scripts/vendor/xhs/cdp.py +830 -0
  9. package/skills/xiaohongshu/scripts/vendor/xhs/comment.py +283 -0
  10. package/skills/xiaohongshu/scripts/vendor/xhs/errors.py +92 -0
  11. package/skills/xiaohongshu/scripts/vendor/xhs/feed_detail.py +550 -0
  12. package/skills/xiaohongshu/scripts/vendor/xhs/feeds.py +49 -0
  13. package/skills/xiaohongshu/scripts/vendor/xhs/human.py +79 -0
  14. package/skills/xiaohongshu/scripts/vendor/xhs/like_favorite.py +188 -0
  15. package/skills/xiaohongshu/scripts/vendor/xhs/login.py +377 -0
  16. package/skills/xiaohongshu/scripts/vendor/xhs/publish.py +1088 -0
  17. package/skills/xiaohongshu/scripts/vendor/xhs/publish_long_article.py +293 -0
  18. package/skills/xiaohongshu/scripts/vendor/xhs/publish_video.py +183 -0
  19. package/skills/xiaohongshu/scripts/vendor/xhs/search.py +226 -0
  20. package/skills/xiaohongshu/scripts/vendor/xhs/selectors.py +97 -0
  21. package/skills/xiaohongshu/scripts/vendor/xhs/stealth.py +316 -0
  22. package/skills/xiaohongshu/scripts/vendor/xhs/types.py +473 -0
  23. package/skills/xiaohongshu/scripts/vendor/xhs/urls.py +30 -0
  24. package/skills/xiaohongshu/scripts/vendor/xhs/user_profile.py +111 -0
  25. package/skills/xiaohongshu/scripts/xiaohongshu.py +1178 -0
  26. package/skills/xiaohongshu/tests/test_xiaohongshu.py +605 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acedatacloud/skills",
3
- "version": "2026.713.4",
3
+ "version": "2026.713.5",
4
4
  "description": "Agent Skills for AceDataCloud AI services — music, image, video generation, LLM chat, web search. Compatible with Claude Code, GitHub Copilot, Gemini CLI, OpenAI Codex, and 30+ AI coding agents.",
5
5
  "keywords": [
6
6
  "agent-skills",
@@ -0,0 +1,36 @@
1
+ # Xiaohongshu Connector Skill
2
+
3
+ AceDataCloud adaptation for operating Xiaohongshu through an encrypted BYOC cookie connector. It runs Chromium directly over CDP inside the existing Skill sandbox; no hosted or long-running MCP server is required.
4
+
5
+ ## Provenance
6
+
7
+ This Skill is rewritten from [`xpzouying/xiaohongshu-mcp`](https://github.com/xpzouying/xiaohongshu-mcp), used by AceDataCloud with permission from its author. The connector-cookie adapter, direct-CDP process isolation, confirmation gates, and Agent Skill integration are AceDataCloud changes.
8
+
9
+ The browser business modules, workflow structure, split preview/confirmation approach, validation ideas, and operational guidance are adapted from MIT-licensed [`autoclaw-cc/xiaohongshu-skills`](https://github.com/autoclaw-cc/xiaohongshu-skills):
10
+
11
+ - Business modules: commit `b043748282a57e347c52f517dfb59819121134ab`.
12
+ - Hardened direct-CDP runtime: commit `406e0590523f`.
13
+ - The upstream MIT license is retained at `scripts/vendor/LICENSE.autoclaw-xiaohongshu-skills`.
14
+
15
+ No AutoClaw browser extension, local WebSocket bridge, persistent Chrome profile, or hosted MCP server is used.
16
+
17
+ ## Capabilities
18
+
19
+ - Login status and connected account identity.
20
+ - Home recommendations, filtered search, note details and comments, and user profiles.
21
+ - Image, video, and formatted text-only long-article publishing.
22
+ - Tags, scheduled publishing, visibility, original declaration, templates, and product binding.
23
+ - Comments, comment replies, likes/unlikes, and favorites/unfavorites.
24
+ - Private messages remain in the Android-only `xhs-dm` Skill.
25
+
26
+ ## Security model
27
+
28
+ - AuthBackend stores the browser-extension cookie jar encrypted.
29
+ - aichat2 injects it as `XIAOHONGSHU_COOKIES` only while this Skill is active.
30
+ - The CLI validates domains and converts Chrome-extension cookie fields to CDP `CookieParam` records.
31
+ - Cookies are injected through `Storage.setCookies` into an incognito Chromium context instead of being passed through files or command arguments.
32
+ - Each command creates a private temporary profile, starts Chromium on a random loopback CDP port, then terminates Chromium and removes the entire profile.
33
+ - Chromium receives a minimal child environment that excludes `XIAOHONGSHU_COOKIES`; Cookie values are never placed in process arguments or model-visible output.
34
+ - Real account writes dry-run unless the invocation ends with `--confirm`; the Skill instructions require a structured user confirmation before that second invocation.
35
+
36
+ Xiaohongshu's web "draft box" is stored in the browser profile rather than the connected account. This Skill deliberately destroys its temporary profile after each command, so it uses code-enforced dry-run previews instead of claiming durable Xiaohongshu drafts. Confirmation is an orchestration policy, not a cryptographic authorization boundary.
@@ -0,0 +1,173 @@
1
+ ---
2
+ name: xiaohongshu
3
+ description: Read, search, preview, publish, and interact on 小红书 / Xiaohongshu / RED using the user's connected account. Supports recommendations, details/comments, profiles, image/video/long-article publishing, schedules, product binding, comments/replies, likes, and favorites. Real writes always dry-run first and require explicit confirmation.
4
+ when_to_use: |
5
+ Trigger when the user asks to use their connected 小红书 / Xiaohongshu / RED account:
6
+ check account status, browse recommendations, search notes, inspect comments or profiles,
7
+ preview or publish image/video/long-article notes, schedule a note, bind products,
8
+ comment/reply, like/unlike, or favorite/unfavorite.
9
+ Private messages are handled by the separate Android-only xhs-dm skill.
10
+ connections: [xiaohongshu]
11
+ allowed_tools: [Bash]
12
+ license: Apache-2.0
13
+ metadata:
14
+ author: acedatacloud
15
+ version: "1.0"
16
+ ---
17
+
18
+ # Xiaohongshu connector
19
+
20
+ Operate the user's real Xiaohongshu account using the login cookies they captured with the ACE extension. The runtime injects `XIAOHONGSHU_COOKIES`; never print, inspect, or pass that value on the command line.
21
+
22
+ This Skill is rewritten for AceDataCloud from the authorized [`xpzouying/xiaohongshu-mcp`](https://github.com/xpzouying/xiaohongshu-mcp) automation engine. Browser modules, workflow, and safety patterns are adapted from MIT-licensed [`autoclaw-cc/xiaohongshu-skills`](https://github.com/autoclaw-cc/xiaohongshu-skills). See [`README.md`](README.md) for pinned commits and provenance.
23
+
24
+ ## Locate the CLI
25
+
26
+ Every Bash call is a fresh shell. Resolve the script at the start of each call:
27
+
28
+ ```sh
29
+ XHS="$SKILL_DIR/scripts/xiaohongshu.py"
30
+ [ -f "$XHS" ] || XHS=$(find /tmp -maxdepth 8 -path '*/skills/*/scripts/xiaohongshu.py' 2>/dev/null | head -1)
31
+ [ -f "$XHS" ] || { echo "xiaohongshu skill runtime not found" >&2; exit 1; }
32
+ ```
33
+
34
+ ## Read operations
35
+
36
+ Run these directly:
37
+
38
+ ```sh
39
+ python3 "$XHS" status
40
+ python3 "$XHS" whoami
41
+ python3 "$XHS" feeds
42
+
43
+ python3 "$XHS" search --keyword "AI Agent"
44
+ python3 "$XHS" search --keyword "旅行" --sort-by 最新 --note-type 图文 --publish-time 一周内
45
+
46
+ python3 "$XHS" detail --feed-id FEED_ID --xsec-token XSEC_TOKEN --xsec-source XSEC_SOURCE
47
+ python3 "$XHS" detail --feed-id FEED_ID --xsec-token XSEC_TOKEN --xsec-source XSEC_SOURCE --load-all-comments --limit 50
48
+ python3 "$XHS" profile --user-id USER_ID --xsec-token XSEC_TOKEN
49
+ ```
50
+
51
+ Search/feed results contain the `feed_id`, `xsec_token`, `xsecSource`, and author `user_id` needed by detail, profile, and interaction commands. Preserve `xsecSource`: recommendation/search rows use `pc_feed`, while rows returned from a user profile use `pc_note`. Do not invent those identifiers.
52
+
53
+ ## Image publishing
54
+
55
+ `publish` accepts 1-18 images. Each `--images` value is either a public HTTPS URL or an existing absolute sandbox path. Text can be inline or read from an absolute UTF-8 file.
56
+
57
+ ```sh
58
+ # Dry-run: validates and shows the exact public write, but changes nothing.
59
+ python3 "$SKILL_DIR/scripts/xiaohongshu.py" publish \
60
+ --title "标题" \
61
+ --content-file /absolute/path/content.txt \
62
+ --images https://cdn.example.com/1.jpg \
63
+ --images /absolute/path/2.png \
64
+ --tags AI --tags 效率 \
65
+ --visibility 仅自己可见
66
+
67
+ # After the dry-run, show the complete preview and use `ask_user_question`.
68
+ # Only after the user selects `确认执行`, repeat the exact command with
69
+ # `--confirm` as its final argument:
70
+ python3 "$XHS" publish \
71
+ --title "标题" \
72
+ --content-file /absolute/path/content.txt \
73
+ --images https://cdn.example.com/1.jpg \
74
+ --tags AI --visibility 仅自己可见 \
75
+ --preview-digest DIGEST \
76
+ --confirm
77
+ ```
78
+
79
+ The CLI defaults every write command to dry-run. Xiaohongshu web drafts live only in the browser profile, while this Skill intentionally destroys its temporary profile after every command to prevent account crossover.
80
+
81
+ After showing the complete dry-run, pause with this exact card shape (replace `PREFIX` with the first 12 characters of `preview_digest`):
82
+
83
+ ```json
84
+ {
85
+ "questions": [{
86
+ "header": "小红书确认",
87
+ "question": "确认执行已展示的小红书写操作?预览摘要 PREFIX",
88
+ "options": [
89
+ {"label": "确认执行", "description": "执行刚刚展示的完整预览"},
90
+ {"label": "取消", "description": "不执行任何账号写操作"}
91
+ ]
92
+ }]
93
+ }
94
+ ```
95
+
96
+ Optional publishing flags:
97
+
98
+ - `--schedule-at <ISO8601>`: 1 hour to 14 days ahead.
99
+ - `--visibility`: `公开可见`, `仅自己可见`, or `仅互关好友可见`.
100
+ - `--original`: declare original content.
101
+ - Repeat `--products` to bind products; the account must have product permissions.
102
+
103
+ ## Video publishing
104
+
105
+ Video must be an existing absolute local path. Remote video URLs are rejected; download the user's supplied file into the sandbox first.
106
+
107
+ ```sh
108
+ python3 "$XHS" publish-video --title "标题" --content "描述" --video /absolute/video.mp4 --tags 视频
109
+ # After explicit confirmation, repeat the exact command with --confirm last:
110
+ python3 "$XHS" publish-video --title "标题" --content "描述" --video /absolute/video.mp4 --tags 视频 --preview-digest DIGEST --confirm
111
+ ```
112
+
113
+ Use Bash's maximum `timeout: 120` for confirmed video operations. Report a timeout without retrying the write, because the publish may already have reached Xiaohongshu.
114
+
115
+ ## Long articles
116
+
117
+ Long articles support a named layout template, an independent post description, scheduling, visibility, original declaration, and products. Inline images are currently rejected because Xiaohongshu's web editor has no upload flow this Skill can verify; image notes remain fully supported. If `--template` is omitted, the first available template is selected.
118
+
119
+ ```sh
120
+ python3 "$SKILL_DIR/scripts/xiaohongshu.py" publish-long \
121
+ --title "长文标题" \
122
+ --content-file /absolute/path/article.txt \
123
+ --description "发布页摘要" \
124
+ --visibility 仅自己可见
125
+
126
+ # After explicit confirmation, repeat the exact command with --confirm last:
127
+ python3 "$XHS" publish-long \
128
+ --title "长文标题" \
129
+ --content-file /absolute/path/article.txt \
130
+ --description "发布页摘要" \
131
+ --visibility 仅自己可见 \
132
+ --preview-digest DIGEST \
133
+ --confirm
134
+ ```
135
+
136
+ ## Interactions
137
+
138
+ Every interaction is a real account write and follows the same dry-run then confirm flow. Repeat the exact previewed command with `--confirm` as the final argument only after explicit confirmation.
139
+
140
+ ```sh
141
+ python3 "$XHS" comment --feed-id ID --xsec-token TOKEN --xsec-source SOURCE --content "评论"
142
+ python3 "$XHS" comment --feed-id ID --xsec-token TOKEN --xsec-source SOURCE --content "评论" --preview-digest DIGEST --confirm
143
+
144
+ python3 "$XHS" reply --feed-id ID --xsec-token TOKEN --xsec-source SOURCE --comment-id COMMENT_ID --content "回复"
145
+ python3 "$XHS" reply --feed-id ID --xsec-token TOKEN --xsec-source SOURCE --comment-id COMMENT_ID --content "回复" --preview-digest DIGEST --confirm
146
+
147
+ python3 "$XHS" like --feed-id ID --xsec-token TOKEN --xsec-source SOURCE
148
+ python3 "$XHS" like --feed-id ID --xsec-token TOKEN --xsec-source SOURCE --preview-digest DIGEST --confirm
149
+ python3 "$XHS" unlike --feed-id ID --xsec-token TOKEN --xsec-source SOURCE --preview-digest DIGEST --confirm
150
+
151
+ python3 "$XHS" favorite --feed-id ID --xsec-token TOKEN --xsec-source SOURCE --preview-digest DIGEST --confirm
152
+ python3 "$XHS" unfavorite --feed-id ID --xsec-token TOKEN --xsec-source SOURCE --preview-digest DIGEST --confirm
153
+ ```
154
+
155
+ For reversible tests or temporary actions, inspect the current `liked` / `collected` state first and restore that exact state afterward.
156
+
157
+ ## Mandatory write policy
158
+
159
+ - Never add `--confirm` until the user has seen the exact dry-run and selected `确认执行` in the required structured confirmation card. Plain prose from the model is not approval.
160
+ - The confirmation card must use header `小红书确认`, exactly `确认执行` / `取消` options, and include the dry-run digest's first 12 hex characters in its question.
161
+ - Repeat the exact previewed arguments and pass its `preview_digest`; if anything changes, the CLI rejects the write and requires a new dry-run.
162
+ - A confirmed write must be one direct `python3 "$SKILL_DIR/scripts/xiaohongshu.py" ... --confirm` command. Never add shell chaining, redirection, command substitution, or wrappers.
163
+ - `--confirm` is honored only as the final argument.
164
+ - Do not batch-comment, mass-like, mass-favorite, or perform unsolicited engagement.
165
+ - Stop immediately on CAPTCHA, verification, risk-control, rate-limit, or account-restriction errors. Do not retry around them.
166
+ - Do not publish external links, contact details, or promotional spam unless the user explicitly supplied and approved them.
167
+ - Scheduled/unattended runs may read or produce dry-run previews only. Xiaohongshu writes always require an interactive confirmation.
168
+
169
+ ## Authentication and errors
170
+
171
+ Authentication belongs to the Connector, not this skill. It does not expose QR login or cookie deletion. If status reports logged out, ask the user to reconnect at <https://auth.acedata.cloud/user/connections> using the ACE extension.
172
+
173
+ The browser automation follows Xiaohongshu's web UI and can drift. Report the exact safe error summary; never dump runtime logs, environment variables, cookies, or `xsec_token` values in errors or write previews.
@@ -0,0 +1 @@
1
+ urllib3==2.2.3
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Auto-Claw-CC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,57 @@
1
+ """UTF-16 标题长度计算,对应 Go pkg/xhsutil/title.go。"""
2
+
3
+ from __future__ import annotations
4
+
5
+ MAX_TITLE_LENGTH = 20
6
+
7
+
8
+ def truncate_title(s: str, max_length: int = MAX_TITLE_LENGTH) -> str:
9
+ """将标题裁剪到 max_length 以内(逐字符从末尾去除)。
10
+
11
+ Args:
12
+ s: 原始标题。
13
+ max_length: 最大允许长度(默认 20)。
14
+
15
+ Returns:
16
+ 满足长度要求的标题字符串。
17
+ """
18
+ if calc_title_length(s) <= max_length:
19
+ return s
20
+ while s and calc_title_length(s) > max_length:
21
+ s = s[:-1]
22
+ return s
23
+
24
+
25
+ def calc_title_length(s: str) -> int:
26
+ """计算小红书标题长度。
27
+
28
+ 规则(同 Go CalcTitleLength):
29
+ - 非 ASCII 字符(中文、全角符号、emoji 代码单元等)算 2
30
+ - ASCII 字符算 1
31
+ - 最终结果向上取整除以 2,上限 MAX_TITLE_LENGTH = 20
32
+
33
+ Emoji 按 UTF-16 码元计数:
34
+ - 基础 emoji(如 ✨ U+2728, BMP)= 1 码元 → 权重 2 → 贡献 1
35
+ - SMP emoji(如 💇 U+1F487,surrogate pair)= 2 码元 → 权重 4 → 贡献 2
36
+ - ZWJ 序列(如 💇‍♀️)= 5 码元 → 权重 10 → 贡献 5
37
+ - 旗帜(如 🇨🇳,2 个 regional indicator)= 4 码元 → 权重 8 → 贡献 4
38
+
39
+ Examples:
40
+ >>> calc_title_length("你好世界")
41
+ 4
42
+ >>> calc_title_length("hello")
43
+ 3
44
+ >>> calc_title_length("OOTD穿搭分享")
45
+ 6
46
+ >>> calc_title_length("💇\u200d♀️")
47
+ 5
48
+ """
49
+ byte_len = 0
50
+ encoded = s.encode("utf-16-le")
51
+ for i in range(0, len(encoded), 2):
52
+ code_unit = int.from_bytes(encoded[i : i + 2], "little")
53
+ if code_unit > 127:
54
+ byte_len += 2
55
+ else:
56
+ byte_len += 1
57
+ return (byte_len + 1) // 2
@@ -0,0 +1 @@
1
+ """小红书 CDP 自动化核心包。"""