feat(xiaohongshu): multi-backend — OpenCLI / xiaohongshu-mcp / xhs-cli
- backends becomes the ordered candidate list [OpenCLI, xiaohongshu-mcp, xhs-cli]; probing order makes the desktop/server split automatic: OpenCLI never probes alive headless, so servers fall through to xiaohongshu-mcp; first fully-usable candidate wins, fixable (warn) candidates only win when nothing is fully usable - xiaohongshu-mcp probing: HTTP reachability of localhost:18060 (proxy-bypassed) + mcporter config presence; guides through `mcporter config add` when half-wired - opencli backend: treat a sleeping extension service worker as ready — verified live that `daemon status` reports disconnected while any real command wakes it; disambiguate "sleeping" vs "never installed" via the Chrome Extensions directory on disk (fixes active_backend flapping between OpenCLI and xhs-cli across doctor runs) - install: desktop installs OpenCLI; server prints the xiaohongshu-mcp guide (binary to ~/.agent-reach/tools/, QR login, mcporter add); xhs-cli is no longer installed by default (upstream unmaintained since 2026-03) but existing installs keep working as the last candidate - skill/references/social.md: xiaohongshu section rewritten as three backend command groups keyed off `doctor --json` active_backend, including the 120s-timeout and login-first caveats for the mcp path Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
+21
-18
@@ -699,26 +699,29 @@ def _install_twitter_deps():
|
||||
|
||||
|
||||
def _install_xhs_deps():
|
||||
"""Install xhs-cli (xiaohongshu-cli) for XiaoHongShu."""
|
||||
import shutil
|
||||
import subprocess
|
||||
"""Set up XiaoHongShu — backend depends on environment.
|
||||
|
||||
print("Setting up XiaoHongShu (xhs-cli)...")
|
||||
if shutil.which("xhs"):
|
||||
print(" ✅ xhs-cli already installed")
|
||||
Desktop: OpenCLI (reuses the browser session, zero config).
|
||||
Server: xiaohongshu-mcp guide (self-contained headless browser + QR
|
||||
login; we don't manage long-running services, so guide only).
|
||||
xhs-cli is no longer installed by default — upstream unmaintained
|
||||
since 2026-03; existing installs keep working as a fallback backend.
|
||||
"""
|
||||
import shutil
|
||||
|
||||
print("Setting up XiaoHongShu...")
|
||||
if _detect_environment() == "server":
|
||||
print(" 服务器环境推荐 xiaohongshu-mcp(自带无头浏览器,扫码登录):")
|
||||
print(" 1. 下载 binary:https://github.com/xpzouying/xiaohongshu-mcp/releases")
|
||||
print(" (建议放到 ~/.agent-reach/tools/ 下)")
|
||||
print(" 2. 启动服务(首次运行会下载约 150MB 浏览器,请等待完成)")
|
||||
print(" 3. 扫码登录后接入:mcporter config add xiaohongshu http://localhost:18060/mcp")
|
||||
print(" 4. 验证:agent-reach doctor")
|
||||
return
|
||||
for tool, cmd in [("pipx", ["pipx", "install", "xiaohongshu-cli"]),
|
||||
("uv", ["uv", "tool", "install", "xiaohongshu-cli"])]:
|
||||
if shutil.which(tool):
|
||||
try:
|
||||
subprocess.run(cmd, capture_output=True, encoding="utf-8",
|
||||
errors="replace", timeout=120)
|
||||
if shutil.which("xhs"):
|
||||
print(" ✅ xhs-cli installed (run `xhs login` to authenticate)")
|
||||
return
|
||||
except Exception:
|
||||
pass
|
||||
print(" [!] xhs-cli install failed. Run: pipx install xiaohongshu-cli")
|
||||
|
||||
_install_opencli_deps()
|
||||
if shutil.which("xhs"):
|
||||
print(" ✅ 检测到存量 xhs-cli,将作为备选后端继续可用")
|
||||
|
||||
|
||||
def _install_opencli_deps():
|
||||
|
||||
Reference in New Issue
Block a user