feat: auto-install WeChat article tools during install (#80)
* feat: auto-install WeChat article tools during agent-reach install
WeChat (微信公众号) deps are now auto-installed during 'agent-reach install':
- Python packages: camoufox[geoip], markdownify, beautifulsoup4, httpx, miku_ai
- Tool repo: wechat-article-for-ai cloned to ~/.agent-reach/tools/
No login or configuration needed — works out of the box like YouTube/RSS.
Updated README tables to reflect zero-config status.
Also covers safe mode and dry-run.
* feat: auto-install WeChat + add channel-setup reference to SKILL.md
1. WeChat auto-install during 'agent-reach install':
- pip install camoufox[geoip], markdownify, bs4, httpx, miku_ai
- clone wechat-article-for-ai to ~/.agent-reach/tools/
- covers safe mode and dry-run
- README tables: WeChat → zero-config
2. SKILL.md improvements:
- Added 'configure' triggers to description
- Added references/channel-setup.md with install steps for all
login-required platforms (Twitter, XHS, Douyin, LinkedIn, Boss)
- Principle: user only provides cookies, agent does everything else
* simplify: point to install.md URL instead of bundled reference
No need to maintain a separate channel-setup.md. Just tell agents
to fetch install.md when they need setup instructions.
---------
Co-authored-by: Panniantong <panniantong@users.noreply.github.com>
This commit is contained in:
@@ -442,6 +442,79 @@ def _install_system_deps():
|
||||
except Exception:
|
||||
print(" ⬜ Could not configure yt-dlp JS runtime (YouTube may not work)")
|
||||
|
||||
# ── WeChat Articles (miku_ai + camoufox + wechat-article-for-ai) ──
|
||||
_install_wechat_deps()
|
||||
|
||||
|
||||
def _install_wechat_deps():
|
||||
"""Install WeChat article reading and search dependencies."""
|
||||
import subprocess
|
||||
|
||||
print("📦 Setting up WeChat article tools...")
|
||||
|
||||
# Check if already installed
|
||||
has_camoufox = False
|
||||
has_miku = False
|
||||
try:
|
||||
import camoufox # noqa: F401
|
||||
has_camoufox = True
|
||||
except ImportError:
|
||||
pass
|
||||
try:
|
||||
import miku_ai # noqa: F401
|
||||
has_miku = True
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
# Install Python packages
|
||||
if has_camoufox and has_miku:
|
||||
print(" ✅ WeChat Python packages already installed")
|
||||
else:
|
||||
pkgs = []
|
||||
if not has_camoufox:
|
||||
pkgs.extend(["camoufox[geoip]", "markdownify", "beautifulsoup4", "httpx"])
|
||||
if not has_miku:
|
||||
pkgs.append("miku_ai")
|
||||
try:
|
||||
cmd = [sys.executable, "-m", "pip", "install", "--break-system-packages", "-q"] + pkgs
|
||||
subprocess.run(cmd, capture_output=True, encoding="utf-8", errors="replace", timeout=120)
|
||||
# Verify
|
||||
ok = True
|
||||
try:
|
||||
import importlib
|
||||
if not has_camoufox:
|
||||
importlib.import_module("camoufox")
|
||||
if not has_miku:
|
||||
importlib.import_module("miku_ai")
|
||||
except ImportError:
|
||||
ok = False
|
||||
if ok:
|
||||
print(f" ✅ WeChat Python packages installed ({', '.join(pkgs)})")
|
||||
else:
|
||||
print(f" ⚠️ Some WeChat packages failed to install. Try: pip install {' '.join(pkgs)}")
|
||||
except Exception:
|
||||
print(f" ⚠️ WeChat packages install failed. Try: pip install {' '.join(pkgs)}")
|
||||
|
||||
# Clone wechat-article-for-ai tool
|
||||
tools_dir = os.path.expanduser("~/.agent-reach/tools")
|
||||
wechat_dir = os.path.join(tools_dir, "wechat-article-for-ai")
|
||||
if os.path.isfile(os.path.join(wechat_dir, "main.py")):
|
||||
print(" ✅ wechat-article-for-ai tool already installed")
|
||||
else:
|
||||
try:
|
||||
os.makedirs(tools_dir, exist_ok=True)
|
||||
subprocess.run(
|
||||
["git", "clone", "--depth", "1",
|
||||
"https://github.com/bzd6661/wechat-article-for-ai.git", wechat_dir],
|
||||
capture_output=True, encoding="utf-8", errors="replace", timeout=60,
|
||||
)
|
||||
if os.path.isfile(os.path.join(wechat_dir, "main.py")):
|
||||
print(" ✅ wechat-article-for-ai tool installed")
|
||||
else:
|
||||
print(" ⚠️ wechat-article-for-ai clone failed. Try: git clone https://github.com/bzd6661/wechat-article-for-ai.git " + wechat_dir)
|
||||
except Exception:
|
||||
print(" ⚠️ wechat-article-for-ai clone failed. Try: git clone https://github.com/bzd6661/wechat-article-for-ai.git " + wechat_dir)
|
||||
|
||||
|
||||
def _install_system_deps_safe():
|
||||
"""Safe mode: check what's installed, print instructions for what's missing."""
|
||||
@@ -472,6 +545,29 @@ def _install_system_deps_safe():
|
||||
else:
|
||||
print(" All system dependencies are installed!")
|
||||
|
||||
# WeChat check (Python packages, not binaries)
|
||||
has_camoufox = has_miku = False
|
||||
try:
|
||||
import camoufox # noqa: F401
|
||||
has_camoufox = True
|
||||
except ImportError:
|
||||
pass
|
||||
try:
|
||||
import miku_ai # noqa: F401
|
||||
has_miku = True
|
||||
except ImportError:
|
||||
pass
|
||||
if has_camoufox and has_miku:
|
||||
print(" ✅ WeChat article tools already installed")
|
||||
else:
|
||||
pkgs = []
|
||||
if not has_camoufox:
|
||||
pkgs.extend(["camoufox[geoip]", "markdownify", "beautifulsoup4", "httpx"])
|
||||
if not has_miku:
|
||||
pkgs.append("miku_ai")
|
||||
print(f" ⬜ WeChat article tools not found")
|
||||
print(f" Install: pip install {' '.join(pkgs)}")
|
||||
|
||||
|
||||
def _install_system_deps_dryrun():
|
||||
"""Dry-run: just show what would be checked/installed."""
|
||||
@@ -492,6 +588,23 @@ def _install_system_deps_dryrun():
|
||||
else:
|
||||
print(f" 📥 {label}: would install via: {method}")
|
||||
|
||||
# WeChat
|
||||
has_camoufox = has_miku = False
|
||||
try:
|
||||
import camoufox # noqa: F401
|
||||
has_camoufox = True
|
||||
except ImportError:
|
||||
pass
|
||||
try:
|
||||
import miku_ai # noqa: F401
|
||||
has_miku = True
|
||||
except ImportError:
|
||||
pass
|
||||
if has_camoufox and has_miku:
|
||||
print(" ✅ WeChat article tools: already installed, skip")
|
||||
else:
|
||||
print(" 📥 WeChat article tools: would install via: pip install camoufox[geoip] markdownify beautifulsoup4 httpx miku_ai")
|
||||
|
||||
|
||||
def _install_mcporter():
|
||||
"""Install mcporter and configure Exa + XiaoHongShu MCP servers."""
|
||||
|
||||
@@ -7,12 +7,14 @@ description: >
|
||||
Use when: (1) user asks to search or read any of these platforms,
|
||||
(2) user shares a URL from any supported platform,
|
||||
(3) user asks to search the web, find information online, or research a topic,
|
||||
(4) user asks to post, comment, or interact on supported platforms.
|
||||
(4) user asks to post, comment, or interact on supported platforms,
|
||||
(5) user asks to configure or set up a platform channel.
|
||||
Triggers: "搜推特", "搜小红书", "看视频", "搜一下", "上网搜", "帮我查", "全网搜索",
|
||||
"search twitter", "read tweet", "youtube transcript", "search reddit",
|
||||
"read this link", "看这个链接", "B站", "bilibili", "抖音视频",
|
||||
"微信文章", "公众号", "LinkedIn", "GitHub issue", "RSS",
|
||||
"search online", "web search", "find information", "research".
|
||||
"search online", "web search", "find information", "research",
|
||||
"帮我配", "configure twitter", "configure proxy", "帮我安装".
|
||||
---
|
||||
|
||||
# Agent Reach — Usage Guide
|
||||
@@ -157,4 +159,10 @@ for e in feedparser.parse('FEED_URL').entries[:5]:
|
||||
|
||||
- **Channel not working?** Run `agent-reach doctor` — shows status and fix instructions.
|
||||
- **Twitter fetch failed?** Ensure `undici` is installed: `npm install -g undici`. Configure proxy: `agent-reach configure proxy URL`.
|
||||
- **Need to configure a channel?** Run `agent-reach doctor`, follow its instructions, or tell user to run the install guide.
|
||||
|
||||
## Setting Up a Channel ("帮我配 XXX")
|
||||
|
||||
If a channel needs setup (cookies, Docker, etc.), fetch the install guide:
|
||||
https://raw.githubusercontent.com/Panniantong/agent-reach/main/docs/install.md
|
||||
|
||||
User only provides cookies. Everything else is your job.
|
||||
|
||||
Reference in New Issue
Block a user