@lucasygu/redbook 0.1.14 → 0.2.0

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.
package/README.md CHANGED
@@ -11,6 +11,8 @@
11
11
  > **"帮我安装 `@lucasygu/redbook` 这个小红书 CLI 工具,然后运行 `redbook whoami` 验证是否能正常连接。GitHub 地址:https://github.com/lucasygu/redbook"**
12
12
  >
13
13
  > AI 会自动完成安装、验证连接、处理可能的 Cookie 问题。你只需要确保已在 Chrome 中登录 xiaohongshu.com。
14
+ >
15
+ > 安装完成后,试试:**"帮我分析'AI编程'这个话题在小红书上的竞争格局"** —— AI 会自动搜索关键词、分析互动数据、发现头部博主、给出内容建议。
14
16
 
15
17
  ## 安装
16
18
 
@@ -22,6 +24,16 @@ npm install -g @lucasygu/redbook
22
24
 
23
25
  安装后运行 `redbook whoami` 验证连接。如果遇到 macOS 钥匙串弹窗,请点击"始终允许"。CLI 会自动检测所有 Chrome 配置文件,找到你的小红书登录状态。
24
26
 
27
+ ## 能做什么
28
+
29
+ - **话题研究** —— 搜索关键词,分析哪些话题有流量、哪些是蓝海
30
+ - **竞品分析** —— 找到头部博主,对比粉丝量、互动数据、内容风格
31
+ - **爆款拆解** —— 分析爆款笔记的标题钩子、互动比例、评论主题
32
+ - **内容策划** —— 基于数据发现内容机会,生成有数据支撑的选题建议
33
+ - **受众洞察** —— 从互动信号推断目标用户画像
34
+
35
+ 通过 AI 助手使用时,这些工作流可以自动串联完成。直接使用 CLI 时,每个命令也可以独立运行。
36
+
25
37
  ## 快速开始
26
38
 
27
39
  ```bash
@@ -66,7 +78,7 @@ redbook post --title "测试" --body "..." --images img.png --private
66
78
  | `user <userId>` | 查看用户资料 |
67
79
  | `user-posts <userId>` | 列出用户所有笔记 |
68
80
  | `feed` | 获取推荐页内容 |
69
- | `post` | 发布图文笔记 |
81
+ | `post` | 发布图文笔记(易触发验证码,详见下方说明) |
70
82
  | `topics <关键词>` | 搜索话题/标签 |
71
83
  | `analyze-viral <url>` | 分析爆款笔记(钩子、互动、结构) |
72
84
 
@@ -86,7 +98,15 @@ redbook post --title "测试" --body "..." --images img.png --private
86
98
  | `--type <类型>` | `all`(全部)、`video`(视频)、`image`(图文) | `all` |
87
99
  | `--page <页码>` | 页码 | `1` |
88
100
 
89
- ### 发布选项
101
+ ### 分析选项(analyze-viral)
102
+
103
+ | 选项 | 说明 | 默认值 |
104
+ |------|------|--------|
105
+ | `--comment-pages <n>` | 获取评论页数 | `3` |
106
+
107
+ ### 发布选项(post)
108
+
109
+ 发布功能目前**容易触发验证码**(type=124)。图片上传正常,但发布步骤经常被拦截。如需发布笔记,建议使用浏览器自动化。
90
110
 
91
111
  | 选项 | 说明 |
92
112
  |------|------|
@@ -118,13 +138,19 @@ redbook post --title "测试" --body "..." --images img.png --private
118
138
  安装后自动注册为 Claude Code 技能。在 Claude Code 中使用 `/redbook` 命令:
119
139
 
120
140
  ```
121
- /redbook search "AI编程" # 搜索笔记
122
- /redbook read <url> # 阅读笔记
123
- /redbook user <userId> # 查看博主
124
- /redbook analyze <userId> # 完整博主分析
141
+ /redbook search "AI编程" # 搜索笔记
142
+ /redbook read <url> # 阅读笔记
143
+ /redbook user <userId> # 查看博主
144
+ /redbook analyze-viral <url> # 分析爆款笔记
125
145
  ```
126
146
 
127
- Claude 会自动调用 CLI 命令,解析结果,完成竞品分析、话题研究等复杂任务。
147
+ 技能内置了小红书平台专属的分析模块 —— 关键词矩阵、跨话题热力图、互动信号分类、博主画像、内容机会评分等。你可以直接用自然语言下达复杂任务:
148
+
149
+ - *"分析'AI编程'在小红书的竞争格局,找出蓝海关键词"*
150
+ - *"对比这三个博主的内容策略和互动数据"*
151
+ - *"拆解这篇爆款笔记,告诉我为什么火了"*
152
+
153
+ Claude 会自动组合多个命令,解析 JSON 数据,输出结构化分析报告。
128
154
 
129
155
  ## 编程接口
130
156
 
@@ -168,6 +194,8 @@ A fast CLI tool for [Xiaohongshu (小红书 / RED)](https://www.xiaohongshu.com)
168
194
  > **"Install the `@lucasygu/redbook` Xiaohongshu CLI tool and run `redbook whoami` to verify it works. Repo: https://github.com/lucasygu/redbook"**
169
195
  >
170
196
  > The agent will handle installation, verify the connection, and troubleshoot any cookie issues. Just make sure you're logged into xiaohongshu.com in Chrome first.
197
+ >
198
+ > Once installed, try: **"Analyze the competitive landscape for 'AI编程' on Xiaohongshu"** — the agent will search keywords, analyze engagement data, profile top creators, and suggest content opportunities.
171
199
 
172
200
  ## Install
173
201
 
@@ -179,6 +207,16 @@ Requires Node.js >= 22. Uses cookies from your Chrome browser session — you mu
179
207
 
180
208
  After installing, run `redbook whoami` to verify the connection. If macOS shows a Keychain prompt, click "Always Allow". The CLI auto-detects all Chrome profiles to find your XHS session.
181
209
 
210
+ ## What You Can Do
211
+
212
+ - **Topic research** — Search keywords, analyze which topics have demand vs. gaps
213
+ - **Competitive analysis** — Find top creators, compare followers, engagement, content style
214
+ - **Viral note breakdown** — Analyze title hooks, engagement ratios, comment themes
215
+ - **Content planning** — Discover content opportunities with data-backed topic suggestions
216
+ - **Audience insights** — Infer target audience from engagement signals
217
+
218
+ When used through an AI agent, these workflows chain together automatically. Each CLI command also works standalone.
219
+
182
220
  ## Quick Start
183
221
 
184
222
  ```bash
@@ -223,7 +261,7 @@ redbook post --title "测试" --body "..." --images img.png --private
223
261
  | `user <userId>` | Get user profile info |
224
262
  | `user-posts <userId>` | List a user's posted notes |
225
263
  | `feed` | Get homepage feed |
226
- | `post` | Publish an image note |
264
+ | `post` | Publish an image note (captcha-prone, see below) |
227
265
  | `topics <keyword>` | Search for topics/hashtags |
228
266
  | `analyze-viral <url>` | Analyze why a viral note works (hooks, engagement, structure) |
229
267
 
@@ -243,8 +281,16 @@ redbook post --title "测试" --body "..." --images img.png --private
243
281
  | `--type <type>` | `all`, `video`, `image` | `all` |
244
282
  | `--page <n>` | Page number | `1` |
245
283
 
284
+ ### Analyze-Viral Options
285
+
286
+ | Option | Description | Default |
287
+ |--------|-------------|---------|
288
+ | `--comment-pages <n>` | Number of comment pages to fetch | `3` |
289
+
246
290
  ### Post Options
247
291
 
292
+ Publishing **frequently triggers captcha** (type=124). Image upload works, but the publish step is unreliable. For posting, consider using browser automation instead.
293
+
248
294
  | Option | Description |
249
295
  |--------|-------------|
250
296
  | `--title <title>` | Note title (required) |
@@ -275,13 +321,19 @@ redbook post --title "测试" --body "..." --images img.png --private
275
321
  Installs automatically as a Claude Code skill. Use `/redbook` in Claude Code:
276
322
 
277
323
  ```
278
- /redbook search "AI编程" # Search notes
279
- /redbook read <url> # Read a note
280
- /redbook user <userId> # Creator profile
281
- /redbook analyze <userId> # Full creator analysis
324
+ /redbook search "AI编程" # Search notes
325
+ /redbook read <url> # Read a note
326
+ /redbook user <userId> # Creator profile
327
+ /redbook analyze-viral <url> # Analyze a viral note
282
328
  ```
283
329
 
284
- Claude will call CLI commands, parse results, and handle complex workflows like competitive analysis and topic research.
330
+ The skill includes XHS-native analysis modules — keyword engagement matrix, cross-topic heatmaps, engagement signal classification, creator profiling, opportunity scoring, and more. You can give natural language instructions for complex tasks:
331
+
332
+ - *"Analyze the competitive landscape for 'AI编程' on Xiaohongshu and find blue ocean keywords"*
333
+ - *"Compare the content strategies of these three creators"*
334
+ - *"Break down this viral note and tell me why it worked"*
335
+
336
+ Claude will automatically combine multiple commands, parse JSON data, and produce structured analysis reports.
285
337
 
286
338
  ## Programmatic Usage
287
339
 
package/SKILL.md CHANGED
@@ -1,11 +1,32 @@
1
1
  ---
2
- description: Search, read, and analyze Xiaohongshu (小红书) content via CLI
2
+ description: Search, read, analyze, and automate Xiaohongshu (小红书) content via CLI
3
3
  allowed-tools: Bash, Read, Write, Glob, Grep
4
+ # OpenClaw / ClawHub metadata (clawhub install redbook)
5
+ name: redbook
6
+ version: 0.2.0
7
+ metadata:
8
+ openclaw:
9
+ requires:
10
+ bins:
11
+ - redbook
12
+ install:
13
+ - kind: node
14
+ package: "@lucasygu/redbook"
15
+ bins: [redbook]
16
+ os: [macos]
17
+ homepage: https://github.com/lucasygu/redbook
18
+ tags:
19
+ - xiaohongshu
20
+ - social-media
21
+ - analytics
22
+ - content-ops
4
23
  ---
5
24
 
6
25
  # Redbook — Xiaohongshu CLI
7
26
 
8
- Use the `redbook` CLI to search notes, read content, analyze creators, and research topics on Xiaohongshu (小红书/RED).
27
+ Use the `redbook` CLI to search notes, read content, analyze creators, automate engagement, and research topics on Xiaohongshu (小红书/RED).
28
+
29
+ **OpenClaw users:** Install via `clawhub install redbook` or `npm install -g @lucasygu/redbook`.
9
30
 
10
31
  ## Usage
11
32
 
@@ -28,6 +49,10 @@ Use the `redbook` CLI to search notes, read content, analyze creators, and resea
28
49
  | Browse feed | `redbook feed --json` |
29
50
  | Search hashtags | `redbook topics "keyword" --json` |
30
51
  | Analyze viral note | `redbook analyze-viral <url> --json` |
52
+ | Extract content template | `redbook viral-template <url1> <url2> --json` |
53
+ | Post a comment | `redbook comment <url> --content "text"` |
54
+ | Reply to comment | `redbook reply <url> --comment-id <id> --content "text"` |
55
+ | Batch reply (preview) | `redbook batch-reply <url> --strategy questions --dry-run` |
31
56
  | Check connection | `redbook whoami` |
32
57
 
33
58
  **Always add `--json`** when parsing output programmatically. Without it, output is human-formatted text.
@@ -303,6 +328,112 @@ redbook search "keyword" --type video --sort popular --json
303
328
 
304
329
  ---
305
330
 
331
+ ### Module I: Comment Operations
332
+
333
+ **Answers:** Which comments deserve a reply? What is the comment quality distribution?
334
+
335
+ **Commands:**
336
+ ```bash
337
+ # 1. Fetch all comments
338
+ redbook comments "<noteUrl>" --all --json
339
+
340
+ # 2. Preview reply candidates (dry run)
341
+ redbook batch-reply "<noteUrl>" --strategy questions --dry-run --json
342
+
343
+ # 3. Execute replies with template
344
+ redbook batch-reply "<noteUrl>" --strategy questions \
345
+ --template "感谢提问!关于{content},..." \
346
+ --max 10 --delay 3000
347
+ ```
348
+
349
+ **Fields to extract from `--dry-run` JSON:**
350
+ - `candidates[].commentId` — target comments
351
+ - `candidates[].isQuestion` — boolean, detected question
352
+ - `candidates[].likes` — engagement signal
353
+ - `candidates[].hasSubReplies` — whether already answered
354
+ - `skipped` — how many comments were filtered out
355
+ - `totalComments` — total fetched
356
+
357
+ **Strategies:**
358
+ - `questions` — replies to comments ending with `?` or `?` (learning-oriented audience)
359
+ - `top-engaged` — replies to highest-liked comments (maximum visibility)
360
+ - `all-unanswered` — replies to comments with no existing sub-replies (fill gaps)
361
+
362
+ **How to interpret:**
363
+ - High question rate (>15%) = audience is learning-oriented → reply to build authority
364
+ - High top-engaged comments (>100 likes) = reply to visible comments for maximum reach
365
+ - Many unanswered comments = engagement gap, opportunity to increase reply rate
366
+
367
+ **Safety:** Hard cap 50 replies per batch, minimum 2s delay, `--dry-run` by default (no template = preview only), immediate stop on captcha.
368
+
369
+ **Output:** Reply plan table with candidate comments, strategy match reason, and status.
370
+
371
+ ---
372
+
373
+ ### Module J: Viral Replication
374
+
375
+ **Answers:** What structural template can I extract from successful notes to guide new content creation?
376
+
377
+ **Commands:**
378
+ ```bash
379
+ # 1. Find top notes for a keyword
380
+ redbook search "keyword" --sort popular --json
381
+
382
+ # 2. Extract structural template from 2-3 top performers
383
+ redbook viral-template "<url1>" "<url2>" "<url3>" --json
384
+ ```
385
+
386
+ **Fields to extract from `viral-template` JSON:**
387
+ - `dominantHookPatterns[]` — hook types appearing in majority of notes
388
+ - `titleStructure.commonPatterns[]` — specific title formula
389
+ - `titleStructure.avgLength` — target title length
390
+ - `bodyStructure.lengthRange` — target word count [min, max]
391
+ - `bodyStructure.paragraphRange` — target paragraph count
392
+ - `engagementProfile.type` — reference/insight/entertainment
393
+ - `audienceSignals.commonThemes[]` — what the audience talks about
394
+
395
+ **How to interpret:**
396
+ - Consistent hook patterns across notes = proven formula for this niche
397
+ - Narrow body length range = audience has clear content length preference
398
+ - High collect/like in profile = audience saves content → create reference material
399
+ - Common comment themes = topics to address in new content
400
+
401
+ **Composition with other modules:**
402
+ - Uses Module A results to identify top URLs for template extraction
403
+ - Feeds into Module H (Content Brainstorm) as structural constraint
404
+ - Uses Module C classification to validate engagement profile
405
+
406
+ **Output:** Content template spec — the structural skeleton for content creation. An LLM (via the composed workflow) uses this template to generate actual title, body, hashtags, and cover image prompt.
407
+
408
+ ---
409
+
410
+ ### Module K: Engagement Automation
411
+
412
+ **Answers:** How should I manage ongoing engagement with my audience?
413
+
414
+ This module is a workflow that composes Modules I and J with human oversight.
415
+
416
+ **Workflow:**
417
+ 1. **Monitor** — `redbook comments "<myNoteUrl>" --all --json` to fetch recent comments
418
+ 2. **Filter** — `redbook batch-reply --strategy questions --dry-run` to identify reply candidates
419
+ 3. **Review** — Human reviews dry-run output (or LLM reviews with persona guidelines)
420
+ 4. **Execute** — `redbook batch-reply --strategy questions --template "..." --max 10`
421
+ 5. **Report** — Summary of replies sent, errors encountered, rate limit status
422
+
423
+ **Safety rules:**
424
+ - Always `--dry-run` first, human approval before execution
425
+ - Maximum 50 replies per session
426
+ - Minimum 2-second delay between replies
427
+ - Never reply to the same comment twice (check `hasSubReplies`)
428
+ - Stop immediately on captcha — do not retry
429
+
430
+ **Anti-spam guidelines:**
431
+ - Vary reply templates across batches
432
+ - Limit to 1-2 batch runs per note per day
433
+ - Prioritize quality (targeted strategy) over quantity
434
+
435
+ ---
436
+
306
437
  ## Composed Workflows
307
438
 
308
439
  Combine modules for different analysis depths.
@@ -332,22 +463,51 @@ The comprehensive playbook — keyword landscape, cross-topic heatmap, engagemen
332
463
 
333
464
  No module composition needed — `analyze-viral` returns hook analysis, engagement ratios, comment themes, author baseline comparison, and a 0-100 viral score in one call.
334
465
 
335
- ### Viral Pattern Research
466
+ ### Viral Pattern Research → Content Template
336
467
  ```bash
337
468
  # 1. Find top notes
338
469
  redbook search "keyword" --sort popular --json
339
470
 
340
- # 2. Analyze 3-5 top notes
341
- redbook analyze-viral "<url1>" --json
342
- redbook analyze-viral "<url2>" --json
343
- redbook analyze-viral "<url3>" --json
344
-
345
- # 3. Synthesize across notes:
346
- # - Which hookPatterns[] appear most often?
347
- # - What collectToLikeRatio is typical?
348
- # - What content structure drives saves vs. shares?
471
+ # 2. Extract template from top 3 notes (replaces manual synthesis)
472
+ redbook viral-template "<url1>" "<url2>" "<url3>" --json
349
473
  ```
350
474
 
475
+ `viral-template` automates what previously required manual synthesis across `analyze-viral` results. It outputs a `ContentTemplate` JSON that captures dominant hooks, body structure ranges, engagement profile, and audience signals.
476
+
477
+ ### Reply Management
478
+ **Modules:** I
479
+
480
+ Single-module workflow for managing comment engagement on your notes. Use `batch-reply --dry-run` to audit, then execute with a template.
481
+
482
+ ### Content Replication
483
+ **Modules:** A → J → H
484
+
485
+ Keyword research → viral template extraction → data-backed content brainstorm. The template provides structural constraints that guide Module H's content ideas.
486
+
487
+ ### Full Operations
488
+ **Modules:** A → C → I → J → K
489
+
490
+ Comprehensive automation playbook — keyword analysis, engagement classification, comment operations, viral replication templates, and engagement automation workflow.
491
+
492
+ ---
493
+
494
+ ## API vs Browser Limitations
495
+
496
+ The following operations work reliably via API:
497
+ - **Reading**: search, notes, comments, user profiles, feed
498
+ - **Writing**: top-level comments, comment replies
499
+ - **Analysis**: viral scoring, template extraction, batch reply planning
500
+
501
+ The following operations are unreliable via API (frequently trigger captcha):
502
+ - Publishing notes (use `--private` for higher success rate)
503
+ - Bulk operations at very high frequency
504
+
505
+ The following operations require browser automation (not supported by this CLI):
506
+ - Captcha solving, real-time notifications
507
+ - Like/collect/follow (heavy anti-automation enforcement)
508
+ - DM/private messaging
509
+ - Cover image generation (use external tools like Gemini/DALL-E)
510
+
351
511
  ---
352
512
 
353
513
  ## Command Details
@@ -443,6 +603,72 @@ Returns `{ note, score, hook, content, visual, engagement, comments, relative, f
443
603
  - `relative.isOutlier` — true if viralMultiplier > 3
444
604
  - `comments.themes[]` — top recurring keyword phrases from comments
445
605
 
606
+ ### `redbook viral-template <url> [url2] [url3]`
607
+
608
+ Extract a reusable content template from 1-3 viral notes. Analyzes each note (same pipeline as `analyze-viral`) and synthesizes common structural patterns.
609
+
610
+ ```bash
611
+ redbook viral-template "<url1>" "<url2>" "<url3>" --json
612
+ redbook viral-template "<url1>" --comment-pages 5 --json
613
+ ```
614
+
615
+ **Options:**
616
+ - `--comment-pages <n>`: Comment pages to fetch per note (default: 3, max: 10)
617
+
618
+ **JSON output structure:**
619
+ Returns `{ dominantHookPatterns, titleStructure, bodyStructure, engagementProfile, audienceSignals, sourceNotes, generatedAt }`.
620
+
621
+ - `dominantHookPatterns[]` — hook types appearing in majority of input notes
622
+ - `titleStructure.avgLength` — average title length across notes
623
+ - `bodyStructure.lengthRange` — [min, max] body length
624
+ - `engagementProfile.type` — "reference" / "insight" / "entertainment"
625
+ - `audienceSignals.commonThemes[]` — merged comment themes across notes
626
+
627
+ ### `redbook comment <url>`
628
+
629
+ Post a top-level comment on a note.
630
+
631
+ ```bash
632
+ redbook comment "<noteUrl>" --content "Great post!" --json
633
+ ```
634
+
635
+ **Options:**
636
+ - `--content <text>` (required): Comment text
637
+
638
+ ### `redbook reply <url>`
639
+
640
+ Reply to a specific comment on a note.
641
+
642
+ ```bash
643
+ redbook reply "<noteUrl>" --comment-id "<commentId>" --content "Thanks for asking!" --json
644
+ ```
645
+
646
+ **Options:**
647
+ - `--comment-id <id>` (required): Comment ID to reply to (from `comments --json` output)
648
+ - `--content <text>` (required): Reply text
649
+
650
+ ### `redbook batch-reply <url>`
651
+
652
+ Reply to multiple comments using a filtering strategy. Always preview with `--dry-run` first.
653
+
654
+ ```bash
655
+ # Preview which comments match the strategy
656
+ redbook batch-reply "<noteUrl>" --strategy questions --dry-run --json
657
+
658
+ # Execute replies with a template
659
+ redbook batch-reply "<noteUrl>" --strategy questions \
660
+ --template "感谢提问!{content}" --max 10 --delay 3000
661
+ ```
662
+
663
+ **Options:**
664
+ - `--strategy <name>`: `questions` (default), `top-engaged`, `all-unanswered`
665
+ - `--template <text>`: Reply template with `{author}`, `{content}` placeholders
666
+ - `--max <n>`: Max replies (default: 10, hard cap: 50)
667
+ - `--delay <ms>`: Delay between replies in ms (default: 3000, min: 2000)
668
+ - `--dry-run`: Preview candidates without posting (default when no template)
669
+
670
+ **Safety:** Stops immediately on captcha. No template = dry-run only.
671
+
446
672
  ### `redbook whoami`
447
673
 
448
674
  Check connection status. Verifies cookies are valid and shows the logged-in user.