@lucasygu/redbook 0.3.0 → 0.3.1
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 +12 -4
- package/package.json +1 -1
- package/scripts/postinstall.js +38 -1
package/README.md
CHANGED
|
@@ -6,9 +6,11 @@
|
|
|
6
6
|
|
|
7
7
|
> ### 最快上手方式
|
|
8
8
|
>
|
|
9
|
-
> 把这段话发给你的 AI 助手(Claude Code、Cursor、Codex、Windsurf 等):
|
|
9
|
+
> 把这段话发给你的 AI 助手(Claude Code、Cursor、Codex、Windsurf、OpenClaw 等):
|
|
10
10
|
>
|
|
11
|
-
> **"
|
|
11
|
+
> **"帮我用 npm 安装 `@lucasygu/redbook` 这个小红书 CLI 工具,然后运行 `redbook whoami` 验证是否能正常连接。GitHub 地址:https://github.com/lucasygu/redbook"**
|
|
12
|
+
>
|
|
13
|
+
> OpenClaw 用户也可以直接:**`clawhub install redbook`**
|
|
12
14
|
>
|
|
13
15
|
> AI 会自动完成安装、验证连接、处理可能的 Cookie 问题。你只需要确保已在 Chrome 中登录 xiaohongshu.com。
|
|
14
16
|
>
|
|
@@ -18,6 +20,8 @@
|
|
|
18
20
|
|
|
19
21
|
```bash
|
|
20
22
|
npm install -g @lucasygu/redbook
|
|
23
|
+
# 或通过 ClawHub(OpenClaw 生态)
|
|
24
|
+
clawhub install redbook
|
|
21
25
|
```
|
|
22
26
|
|
|
23
27
|
需要 Node.js >= 22。使用 Chrome 浏览器的 Cookie —— 请先在 Chrome 中登录 xiaohongshu.com。
|
|
@@ -278,9 +282,11 @@ A fast CLI tool for [Xiaohongshu (小红书 / RED)](https://www.xiaohongshu.com)
|
|
|
278
282
|
|
|
279
283
|
> ### Easiest way to get started
|
|
280
284
|
>
|
|
281
|
-
> Paste this to your AI coding agent (Claude Code, Cursor, Codex, Windsurf, etc.):
|
|
285
|
+
> Paste this to your AI coding agent (Claude Code, Cursor, Codex, Windsurf, OpenClaw, etc.):
|
|
282
286
|
>
|
|
283
|
-
> **"Install the `@lucasygu/redbook` Xiaohongshu CLI tool and run `redbook whoami` to verify it works. Repo: https://github.com/lucasygu/redbook"**
|
|
287
|
+
> **"Install the `@lucasygu/redbook` Xiaohongshu CLI tool via npm and run `redbook whoami` to verify it works. Repo: https://github.com/lucasygu/redbook"**
|
|
288
|
+
>
|
|
289
|
+
> OpenClaw users can also run: **`clawhub install redbook`**
|
|
284
290
|
>
|
|
285
291
|
> 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.
|
|
286
292
|
>
|
|
@@ -290,6 +296,8 @@ A fast CLI tool for [Xiaohongshu (小红书 / RED)](https://www.xiaohongshu.com)
|
|
|
290
296
|
|
|
291
297
|
```bash
|
|
292
298
|
npm install -g @lucasygu/redbook
|
|
299
|
+
# Or via ClawHub (OpenClaw ecosystem)
|
|
300
|
+
clawhub install redbook
|
|
293
301
|
```
|
|
294
302
|
|
|
295
303
|
Requires Node.js >= 22. Uses cookies from your Chrome browser session — you must be logged into xiaohongshu.com in Chrome.
|
package/package.json
CHANGED
package/scripts/postinstall.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* This gives Claude Code a /redbook slash command automatically.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { existsSync, mkdirSync, unlinkSync, symlinkSync, lstatSync, readlinkSync, rmSync } from 'fs';
|
|
11
|
+
import { existsSync, mkdirSync, unlinkSync, symlinkSync, lstatSync, readlinkSync, rmSync, readFileSync, writeFileSync } from 'fs';
|
|
12
12
|
import { join, dirname } from 'path';
|
|
13
13
|
import { fileURLToPath } from 'url';
|
|
14
14
|
import { homedir } from 'os';
|
|
@@ -56,9 +56,46 @@ function setupClaudeSkill() {
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
/**
|
|
60
|
+
* Patch @steipete/sweet-cookie keychain timeout bug.
|
|
61
|
+
*
|
|
62
|
+
* Published v0.1.0 hardcodes `timeoutMs: 3_000` in chromeSqliteMac.js,
|
|
63
|
+
* ignoring the caller's value. The macOS `security` CLI often needs >3s
|
|
64
|
+
* (especially on first keychain prompt). This patch makes it respect
|
|
65
|
+
* the caller's timeout with a 30s default.
|
|
66
|
+
*/
|
|
67
|
+
function patchSweetCookieTimeout() {
|
|
68
|
+
const target = join(
|
|
69
|
+
PACKAGE_ROOT,
|
|
70
|
+
'node_modules',
|
|
71
|
+
'@steipete',
|
|
72
|
+
'sweet-cookie',
|
|
73
|
+
'dist',
|
|
74
|
+
'providers',
|
|
75
|
+
'chromeSqliteMac.js'
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
if (!existsSync(target)) return;
|
|
79
|
+
|
|
80
|
+
try {
|
|
81
|
+
const content = readFileSync(target, 'utf-8');
|
|
82
|
+
const needle = 'timeoutMs: 3_000,';
|
|
83
|
+
if (!content.includes(needle)) {
|
|
84
|
+
// Already patched or upstream fixed
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const patched = content.replace(needle, 'timeoutMs: options.timeoutMs ?? 30_000,');
|
|
88
|
+
writeFileSync(target, patched, 'utf-8');
|
|
89
|
+
console.log('[redbook] Patched sweet-cookie keychain timeout (3s -> 30s).');
|
|
90
|
+
} catch (err) {
|
|
91
|
+
console.log(`[redbook] Warning: could not patch sweet-cookie: ${err.message}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
59
95
|
function main() {
|
|
60
96
|
console.log('[redbook] Running post-install...');
|
|
61
97
|
const success = setupClaudeSkill();
|
|
98
|
+
patchSweetCookieTimeout();
|
|
62
99
|
console.log('');
|
|
63
100
|
console.log('[redbook] Installation complete!');
|
|
64
101
|
if (success) {
|