@lucasygu/redbook 0.1.15 → 0.3.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 +184 -6
- package/SKILL.md +365 -12
- package/dist/cli.js +276 -0
- package/dist/cli.js.map +1 -1
- package/dist/lib/analyze.d.ts +1 -0
- package/dist/lib/analyze.d.ts.map +1 -1
- package/dist/lib/analyze.js +4 -2
- package/dist/lib/analyze.js.map +1 -1
- package/dist/lib/client.d.ts +1 -0
- package/dist/lib/client.d.ts.map +1 -1
- package/dist/lib/client.js +8 -0
- package/dist/lib/client.js.map +1 -1
- package/dist/lib/render.d.ts +33 -0
- package/dist/lib/render.d.ts.map +1 -0
- package/dist/lib/render.js +531 -0
- package/dist/lib/render.js.map +1 -0
- package/dist/lib/reply-strategy.d.ts +42 -0
- package/dist/lib/reply-strategy.d.ts.map +1 -0
- package/dist/lib/reply-strategy.js +119 -0
- package/dist/lib/reply-strategy.js.map +1 -0
- package/dist/lib/template.d.ts +50 -0
- package/dist/lib/template.d.ts.map +1 -0
- package/dist/lib/template.js +154 -0
- package/dist/lib/template.js.map +1 -0
- package/package.json +17 -2
package/README.md
CHANGED
|
@@ -29,6 +29,9 @@ npm install -g @lucasygu/redbook
|
|
|
29
29
|
- **话题研究** —— 搜索关键词,分析哪些话题有流量、哪些是蓝海
|
|
30
30
|
- **竞品分析** —— 找到头部博主,对比粉丝量、互动数据、内容风格
|
|
31
31
|
- **爆款拆解** —— 分析爆款笔记的标题钩子、互动比例、评论主题
|
|
32
|
+
- **爆款模板** —— 从多篇爆款笔记提取内容模板(标题结构、正文结构、钩子模式)
|
|
33
|
+
- **评论管理** —— 发评论、回复评论、按策略批量回复(问题优先 / 高赞优先 / 未回复优先)
|
|
34
|
+
- **图文卡片** —— Markdown 渲染为小红书风格的 PNG 图文卡片(7 种配色主题)
|
|
32
35
|
- **内容策划** —— 基于数据发现内容机会,生成有数据支撑的选题建议
|
|
33
36
|
- **受众洞察** —— 从互动信号推断目标用户画像
|
|
34
37
|
|
|
@@ -62,6 +65,23 @@ redbook topics "Claude Code"
|
|
|
62
65
|
# 分析爆款笔记
|
|
63
66
|
redbook analyze-viral https://www.xiaohongshu.com/explore/abc123
|
|
64
67
|
|
|
68
|
+
# 从多篇爆款提取内容模板
|
|
69
|
+
redbook viral-template "<url1>" "<url2>" "<url3>" --json
|
|
70
|
+
|
|
71
|
+
# 发评论
|
|
72
|
+
redbook comment "<noteUrl>" --content "写得好!"
|
|
73
|
+
|
|
74
|
+
# 回复评论
|
|
75
|
+
redbook reply "<noteUrl>" --comment-id "<id>" --content "感谢提问!"
|
|
76
|
+
|
|
77
|
+
# 按策略批量回复(先预览再执行)
|
|
78
|
+
redbook batch-reply "<noteUrl>" --strategy questions --dry-run
|
|
79
|
+
redbook batch-reply "<noteUrl>" --strategy questions --template "感谢!{content}" --max 10
|
|
80
|
+
|
|
81
|
+
# 将 Markdown 渲染为图文卡片(需要可选依赖)
|
|
82
|
+
redbook render content.md --style xiaohongshu
|
|
83
|
+
redbook render content.md --style dark --output-dir ./cards
|
|
84
|
+
|
|
65
85
|
# 发布图文笔记
|
|
66
86
|
redbook post --title "标题" --body "正文内容" --images cover.png
|
|
67
87
|
redbook post --title "测试" --body "..." --images img.png --private
|
|
@@ -81,6 +101,11 @@ redbook post --title "测试" --body "..." --images img.png --private
|
|
|
81
101
|
| `post` | 发布图文笔记(易触发验证码,详见下方说明) |
|
|
82
102
|
| `topics <关键词>` | 搜索话题/标签 |
|
|
83
103
|
| `analyze-viral <url>` | 分析爆款笔记(钩子、互动、结构) |
|
|
104
|
+
| `viral-template <url...>` | 从 1-3 篇爆款笔记提取内容模板 |
|
|
105
|
+
| `comment <url>` | 发表评论 |
|
|
106
|
+
| `reply <url>` | 回复指定评论 |
|
|
107
|
+
| `batch-reply <url>` | 按策略批量回复评论(支持预览模式) |
|
|
108
|
+
| `render <文件>` | Markdown 渲染为小红书图文卡片 PNG(需可选依赖) |
|
|
84
109
|
|
|
85
110
|
### 通用选项
|
|
86
111
|
|
|
@@ -98,12 +123,42 @@ redbook post --title "测试" --body "..." --images img.png --private
|
|
|
98
123
|
| `--type <类型>` | `all`(全部)、`video`(视频)、`image`(图文) | `all` |
|
|
99
124
|
| `--page <页码>` | 页码 | `1` |
|
|
100
125
|
|
|
101
|
-
### 分析选项(analyze-viral)
|
|
126
|
+
### 分析选项(analyze-viral / viral-template)
|
|
102
127
|
|
|
103
128
|
| 选项 | 说明 | 默认值 |
|
|
104
129
|
|------|------|--------|
|
|
105
130
|
| `--comment-pages <n>` | 获取评论页数 | `3` |
|
|
106
131
|
|
|
132
|
+
### 批量回复选项(batch-reply)
|
|
133
|
+
|
|
134
|
+
| 选项 | 说明 | 默认值 |
|
|
135
|
+
|------|------|--------|
|
|
136
|
+
| `--strategy <策略>` | `questions`(提问)、`top-engaged`(高赞)、`all-unanswered`(未回复) | `questions` |
|
|
137
|
+
| `--template <模板>` | 回复模板,支持 `{author}`, `{content}` 占位符 | 无(预览模式) |
|
|
138
|
+
| `--max <数量>` | 最大回复数(上限 30) | `10` |
|
|
139
|
+
| `--delay <毫秒>` | 回复间隔(最小 180000ms/3分钟),自动添加 ±30% 随机抖动 | `300000`(5分钟) |
|
|
140
|
+
| `--dry-run` | 只预览不发送 | 无模板时自动开启 |
|
|
141
|
+
|
|
142
|
+
> ⚠️ **风控安全:** 小红书检测均匀时间间隔的自动化行为。回复间隔已自动添加 ±30% 随机抖动,避免触发机器人检测。建议每天每篇笔记最多批量回复 1-2 次。
|
|
143
|
+
|
|
144
|
+
### 渲染选项(render)
|
|
145
|
+
|
|
146
|
+
将 Markdown 文件渲染为小红书风格的 PNG 图文卡片。使用本机 Chrome 渲染,无需额外下载浏览器。
|
|
147
|
+
|
|
148
|
+
| 选项 | 说明 | 默认值 |
|
|
149
|
+
|------|------|--------|
|
|
150
|
+
| `--style <名称>` | 配色:purple, xiaohongshu, mint, sunset, ocean, elegant, dark | `xiaohongshu` |
|
|
151
|
+
| `--pagination <模式>` | 分页:auto(自动拆分)、separator(按 `---` 拆分) | `auto` |
|
|
152
|
+
| `--output-dir <目录>` | 输出目录 | 与输入文件同目录 |
|
|
153
|
+
| `--width <像素>` | 卡片宽度 | `1080` |
|
|
154
|
+
| `--height <像素>` | 卡片高度 | `1440` |
|
|
155
|
+
| `--dpr <倍率>` | 设备像素比 | `2` |
|
|
156
|
+
|
|
157
|
+
**可选依赖:** 需要安装 `puppeteer-core` 和 `marked`:
|
|
158
|
+
```bash
|
|
159
|
+
npm install -g puppeteer-core marked
|
|
160
|
+
```
|
|
161
|
+
|
|
107
162
|
### 发布选项(post)
|
|
108
163
|
|
|
109
164
|
发布功能目前**容易触发验证码**(type=124)。图片上传正常,但发布步骤经常被拦截。如需发布笔记,建议使用浏览器自动化。
|
|
@@ -133,7 +188,30 @@ redbook post --title "测试" --body "..." --images img.png --private
|
|
|
133
188
|
- **主 API**(`edith.xiaohongshu.com`)—— 读取:搜索、推荐页、笔记、评论、用户资料。使用 144 字节 x-s 签名(v4.3.1)
|
|
134
189
|
- **创作者 API**(`creator.xiaohongshu.com`)—— 写入:上传图片、发布笔记。使用 AES-128-CBC 签名
|
|
135
190
|
|
|
136
|
-
##
|
|
191
|
+
## 分析模块(A-L)
|
|
192
|
+
|
|
193
|
+
内置 12 个可组合的分析模块,覆盖从关键词研究到内容发布的完整工作流:
|
|
194
|
+
|
|
195
|
+
| 模块 | 功能 |
|
|
196
|
+
|------|------|
|
|
197
|
+
| A. 关键词矩阵 | 分析各关键词的互动天花板和竞争密度 |
|
|
198
|
+
| B. 跨话题热力图 | 发现话题 × 场景的内容空白 |
|
|
199
|
+
| C. 互动信号分析 | 分类内容类型(工具型 / 认知型 / 娱乐型) |
|
|
200
|
+
| D. 博主画像 | 对比头部博主的粉丝、互动、风格 |
|
|
201
|
+
| E. 内容形式分析 | 图文 vs. 视频的表现对比 |
|
|
202
|
+
| F. 机会评分 | 按性价比排序关键词 |
|
|
203
|
+
| G. 受众推断 | 从互动信号推断用户画像 |
|
|
204
|
+
| H. 选题策划 | 数据驱动的内容创意 |
|
|
205
|
+
| I. 评论运营 | 按策略筛选和批量回复评论 |
|
|
206
|
+
| J. 爆款复刻 | 从爆款笔记提取内容模板 |
|
|
207
|
+
| K. 互动自动化 | 组合 I + J 的自动化运营工作流 |
|
|
208
|
+
| L. 图文卡片 | Markdown → 小红书风格 PNG 图文卡片(7 种配色) |
|
|
209
|
+
|
|
210
|
+
详见 [SKILL.md](SKILL.md) 的模块文档和组合工作流。
|
|
211
|
+
|
|
212
|
+
## AI 助手集成
|
|
213
|
+
|
|
214
|
+
### Claude Code
|
|
137
215
|
|
|
138
216
|
安装后自动注册为 Claude Code 技能。在 Claude Code 中使用 `/redbook` 命令:
|
|
139
217
|
|
|
@@ -144,14 +222,25 @@ redbook post --title "测试" --body "..." --images img.png --private
|
|
|
144
222
|
/redbook analyze-viral <url> # 分析爆款笔记
|
|
145
223
|
```
|
|
146
224
|
|
|
147
|
-
|
|
225
|
+
你可以直接用自然语言下达复杂任务:
|
|
148
226
|
|
|
149
227
|
- *"分析'AI编程'在小红书的竞争格局,找出蓝海关键词"*
|
|
150
228
|
- *"对比这三个博主的内容策略和互动数据"*
|
|
151
229
|
- *"拆解这篇爆款笔记,告诉我为什么火了"*
|
|
230
|
+
- *"帮我回复这篇笔记下面的提问评论"*
|
|
152
231
|
|
|
153
232
|
Claude 会自动组合多个命令,解析 JSON 数据,输出结构化分析报告。
|
|
154
233
|
|
|
234
|
+
### OpenClaw / ClawHub
|
|
235
|
+
|
|
236
|
+
官方支持 [OpenClaw](https://openclaw.ai) 和 [ClawHub](https://docs.openclaw.ai/tools/clawhub) 生态。通过 ClawHub 安装:
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
clawhub install redbook
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
安装后在 OpenClaw 中可直接使用所有 `redbook` 命令。SKILL.md 同时兼容 Claude Code 和 OpenClaw 两个生态。
|
|
243
|
+
|
|
155
244
|
## 编程接口
|
|
156
245
|
|
|
157
246
|
```typescript
|
|
@@ -212,6 +301,9 @@ After installing, run `redbook whoami` to verify the connection. If macOS shows
|
|
|
212
301
|
- **Topic research** — Search keywords, analyze which topics have demand vs. gaps
|
|
213
302
|
- **Competitive analysis** — Find top creators, compare followers, engagement, content style
|
|
214
303
|
- **Viral note breakdown** — Analyze title hooks, engagement ratios, comment themes
|
|
304
|
+
- **Viral templates** — Extract content templates from multiple viral notes (hook patterns, body structure, engagement profile)
|
|
305
|
+
- **Comment management** — Post comments, reply to comments, batch-reply with strategies (questions / top-engaged / unanswered)
|
|
306
|
+
- **Image cards** — Render markdown to styled PNG cards for XHS posts (7 color themes)
|
|
215
307
|
- **Content planning** — Discover content opportunities with data-backed topic suggestions
|
|
216
308
|
- **Audience insights** — Infer target audience from engagement signals
|
|
217
309
|
|
|
@@ -245,6 +337,23 @@ redbook topics "Claude Code"
|
|
|
245
337
|
# Analyze a viral note
|
|
246
338
|
redbook analyze-viral https://www.xiaohongshu.com/explore/abc123
|
|
247
339
|
|
|
340
|
+
# Extract content template from viral notes
|
|
341
|
+
redbook viral-template "<url1>" "<url2>" "<url3>" --json
|
|
342
|
+
|
|
343
|
+
# Post a comment
|
|
344
|
+
redbook comment "<noteUrl>" --content "Great post!"
|
|
345
|
+
|
|
346
|
+
# Reply to a comment
|
|
347
|
+
redbook reply "<noteUrl>" --comment-id "<id>" --content "Thanks for asking!"
|
|
348
|
+
|
|
349
|
+
# Batch reply with strategy (preview first, then execute)
|
|
350
|
+
redbook batch-reply "<noteUrl>" --strategy questions --dry-run
|
|
351
|
+
redbook batch-reply "<noteUrl>" --strategy questions --template "Thanks! {content}" --max 10
|
|
352
|
+
|
|
353
|
+
# Render markdown to image cards (requires optional deps)
|
|
354
|
+
redbook render content.md --style xiaohongshu
|
|
355
|
+
redbook render content.md --style dark --output-dir ./cards
|
|
356
|
+
|
|
248
357
|
# Publish (requires image)
|
|
249
358
|
redbook post --title "标题" --body "正文" --images cover.png
|
|
250
359
|
redbook post --title "测试" --body "..." --images img.png --private
|
|
@@ -264,6 +373,11 @@ redbook post --title "测试" --body "..." --images img.png --private
|
|
|
264
373
|
| `post` | Publish an image note (captcha-prone, see below) |
|
|
265
374
|
| `topics <keyword>` | Search for topics/hashtags |
|
|
266
375
|
| `analyze-viral <url>` | Analyze why a viral note works (hooks, engagement, structure) |
|
|
376
|
+
| `viral-template <url...>` | Extract a content template from 1-3 viral notes |
|
|
377
|
+
| `comment <url>` | Post a top-level comment |
|
|
378
|
+
| `reply <url>` | Reply to a specific comment |
|
|
379
|
+
| `batch-reply <url>` | Batch reply to comments with filtering strategy (supports dry-run) |
|
|
380
|
+
| `render <file>` | Render markdown to styled PNG image cards for XHS posts (optional deps) |
|
|
267
381
|
|
|
268
382
|
### Global Options
|
|
269
383
|
|
|
@@ -281,12 +395,42 @@ redbook post --title "测试" --body "..." --images img.png --private
|
|
|
281
395
|
| `--type <type>` | `all`, `video`, `image` | `all` |
|
|
282
396
|
| `--page <n>` | Page number | `1` |
|
|
283
397
|
|
|
284
|
-
### Analyze-Viral Options
|
|
398
|
+
### Analyze-Viral / Viral-Template Options
|
|
285
399
|
|
|
286
400
|
| Option | Description | Default |
|
|
287
401
|
|--------|-------------|---------|
|
|
288
402
|
| `--comment-pages <n>` | Number of comment pages to fetch | `3` |
|
|
289
403
|
|
|
404
|
+
### Batch-Reply Options
|
|
405
|
+
|
|
406
|
+
| Option | Description | Default |
|
|
407
|
+
|--------|-------------|---------|
|
|
408
|
+
| `--strategy <name>` | `questions`, `top-engaged`, `all-unanswered` | `questions` |
|
|
409
|
+
| `--template <text>` | Reply template with `{author}`, `{content}` placeholders | none (dry-run) |
|
|
410
|
+
| `--max <n>` | Max replies to send (hard cap: 30) | `10` |
|
|
411
|
+
| `--delay <ms>` | Delay between replies in ms (min: 180000 / 3 min), ±30% random jitter applied automatically | `300000` (5 min) |
|
|
412
|
+
| `--dry-run` | Preview candidates without posting | auto when no template |
|
|
413
|
+
|
|
414
|
+
> ⚠️ **Rate limit safety:** XHS detects uniform timing patterns as bot behavior. Reply delays include ±30% random jitter automatically. Limit to 1-2 batch runs per note per day. See SKILL.md for full rate limit guidance.
|
|
415
|
+
|
|
416
|
+
### Render Options
|
|
417
|
+
|
|
418
|
+
Render a markdown file to styled PNG image cards. Uses your existing Chrome for rendering — no browser download needed.
|
|
419
|
+
|
|
420
|
+
| Option | Description | Default |
|
|
421
|
+
|--------|-------------|---------|
|
|
422
|
+
| `--style <name>` | Color style: purple, xiaohongshu, mint, sunset, ocean, elegant, dark | `xiaohongshu` |
|
|
423
|
+
| `--pagination <mode>` | Pagination: auto, separator | `auto` |
|
|
424
|
+
| `--output-dir <dir>` | Output directory | same as input |
|
|
425
|
+
| `--width <n>` | Card width in pixels | `1080` |
|
|
426
|
+
| `--height <n>` | Card height in pixels | `1440` |
|
|
427
|
+
| `--dpr <n>` | Device pixel ratio | `2` |
|
|
428
|
+
|
|
429
|
+
**Optional dependencies:** Requires `puppeteer-core` and `marked`:
|
|
430
|
+
```bash
|
|
431
|
+
npm install -g puppeteer-core marked
|
|
432
|
+
```
|
|
433
|
+
|
|
290
434
|
### Post Options
|
|
291
435
|
|
|
292
436
|
Publishing **frequently triggers captcha** (type=124). Image upload works, but the publish step is unreliable. For posting, consider using browser automation instead.
|
|
@@ -316,7 +460,30 @@ Publishing **frequently triggers captcha** (type=124). Image upload works, but t
|
|
|
316
460
|
- **Main API** (`edith.xiaohongshu.com`) — for reading: search, feed, notes, comments, user profiles. Uses x-s signature with 144-byte payload (v4.3.1).
|
|
317
461
|
- **Creator API** (`creator.xiaohongshu.com`) — for writing: upload images, publish notes. Uses simpler AES-128-CBC signing.
|
|
318
462
|
|
|
319
|
-
##
|
|
463
|
+
## Analysis Modules (A-L)
|
|
464
|
+
|
|
465
|
+
12 composable analysis modules covering the full workflow from keyword research to content publishing:
|
|
466
|
+
|
|
467
|
+
| Module | Purpose |
|
|
468
|
+
|--------|---------|
|
|
469
|
+
| A. Keyword Matrix | Analyze engagement ceiling and competition density per keyword |
|
|
470
|
+
| B. Cross-Topic Heatmap | Find topic × scene content gaps |
|
|
471
|
+
| C. Engagement Signals | Classify content type (reference / insight / entertainment) |
|
|
472
|
+
| D. Creator Profiling | Compare top creators' followers, engagement, style |
|
|
473
|
+
| E. Content Form | Image-text vs. video performance comparison |
|
|
474
|
+
| F. Opportunity Scoring | Rank keywords by effort-to-reward ratio |
|
|
475
|
+
| G. Audience Inference | Infer user persona from engagement signals |
|
|
476
|
+
| H. Content Brainstorm | Data-backed content ideas |
|
|
477
|
+
| I. Comment Operations | Filter and batch-reply to comments by strategy |
|
|
478
|
+
| J. Viral Replication | Extract content templates from viral notes |
|
|
479
|
+
| K. Engagement Automation | Combined I + J workflow for operations |
|
|
480
|
+
| L. Card Rendering | Markdown → styled PNG image cards for XHS posts (7 color themes) |
|
|
481
|
+
|
|
482
|
+
See [SKILL.md](SKILL.md) for full module documentation and composed workflows.
|
|
483
|
+
|
|
484
|
+
## AI Agent Integration
|
|
485
|
+
|
|
486
|
+
### Claude Code
|
|
320
487
|
|
|
321
488
|
Installs automatically as a Claude Code skill. Use `/redbook` in Claude Code:
|
|
322
489
|
|
|
@@ -327,14 +494,25 @@ Installs automatically as a Claude Code skill. Use `/redbook` in Claude Code:
|
|
|
327
494
|
/redbook analyze-viral <url> # Analyze a viral note
|
|
328
495
|
```
|
|
329
496
|
|
|
330
|
-
|
|
497
|
+
You can give natural language instructions for complex tasks:
|
|
331
498
|
|
|
332
499
|
- *"Analyze the competitive landscape for 'AI编程' on Xiaohongshu and find blue ocean keywords"*
|
|
333
500
|
- *"Compare the content strategies of these three creators"*
|
|
334
501
|
- *"Break down this viral note and tell me why it worked"*
|
|
502
|
+
- *"Reply to the question comments on my latest post"*
|
|
335
503
|
|
|
336
504
|
Claude will automatically combine multiple commands, parse JSON data, and produce structured analysis reports.
|
|
337
505
|
|
|
506
|
+
### OpenClaw / ClawHub
|
|
507
|
+
|
|
508
|
+
Officially supports [OpenClaw](https://openclaw.ai) and [ClawHub](https://docs.openclaw.ai/tools/clawhub). Install via ClawHub:
|
|
509
|
+
|
|
510
|
+
```bash
|
|
511
|
+
clawhub install redbook
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
All `redbook` commands are available in OpenClaw after installation. The SKILL.md is compatible with both Claude Code and OpenClaw ecosystems.
|
|
515
|
+
|
|
338
516
|
## Programmatic Usage
|
|
339
517
|
|
|
340
518
|
```typescript
|