From cd94706d3b6a060ffbd2adaa941faa26822809d8 Mon Sep 17 00:00:00 2001 From: Pnant <73925474+Panniantong@users.noreply.github.com> Date: Thu, 5 Mar 2026 18:29:33 +0800 Subject: [PATCH] feat: auto-install WeChat article tools during install (#80) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --- README.md | 2 +- agent_reach/cli.py | 113 +++++++++++++++++++++++++++++++++++++ agent_reach/skill/SKILL.md | 14 ++++- docs/README_en.md | 2 +- 4 files changed, 126 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 4127b2f..a1707de 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ AI Agent 已经能帮你写代码、改文档、管项目——但你让它去 | 🎵 **抖音** | — | 视频解析、无水印下载链接获取 | 告诉 Agent「帮我配抖音」 | | 💼 **LinkedIn** | Jina Reader 读公开页面 | Profile 详情、公司页面、职位搜索 | 告诉 Agent「帮我配 LinkedIn」 | | 🏢 **Boss直聘** | Jina Reader 读职位页 | 搜索职位、向 HR 打招呼 | 告诉 Agent「帮我配 Boss直聘」 | -| 💬 **微信公众号** | — | 搜索 + 阅读公众号文章(全文 Markdown) | 告诉 Agent「帮我配微信公众号」 | +| 💬 **微信公众号** | 搜索 + 阅读公众号文章(全文 Markdown) | — | 无需配置 | > **不知道怎么配?不用查文档。** 直接告诉 Agent「帮我配 XXX」,它知道需要什么、会一步一步引导你。 > diff --git a/agent_reach/cli.py b/agent_reach/cli.py index 8bb3a41..1eb2f8c 100644 --- a/agent_reach/cli.py +++ b/agent_reach/cli.py @@ -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.""" diff --git a/agent_reach/skill/SKILL.md b/agent_reach/skill/SKILL.md index 6432af5..e8e631d 100644 --- a/agent_reach/skill/SKILL.md +++ b/agent_reach/skill/SKILL.md @@ -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. diff --git a/docs/README_en.md b/docs/README_en.md index 21c2120..6661b6a 100644 --- a/docs/README_en.md +++ b/docs/README_en.md @@ -67,7 +67,7 @@ Update Agent Reach: https://raw.githubusercontent.com/Panniantong/agent-reach/ma | 🎵 **Douyin** | Video parsing · Watermark-free download | mcporter | Via [douyin-mcp-server](https://github.com/yzfly/douyin-mcp-server), no login needed | | 💼 **LinkedIn** | Jina Reader (public pages) | Full profiles, companies, job search | Tell your Agent "help me set up LinkedIn" | | 🏢 **Boss直聘** | Jina Reader (job pages) | Job search, greet recruiters | Tell your Agent "help me set up Boss直聘" | -| 💬 **WeChat Articles** | — | Search + read WeChat Official Account articles (full Markdown) | Tell your Agent "help me set up WeChat" | +| 💬 **WeChat Articles** | Search + Read | Zero config | Search + read WeChat Official Account articles (full Markdown) ([wechat-article-for-ai](https://github.com/bzd6661/wechat-article-for-ai) + [miku_ai](https://github.com/GobinFan/Miku_Spider)) | | 🔍 **Web Search** | Search | Auto-configured | Auto-configured during install, free, no API key ([Exa](https://exa.ai) via [mcporter](https://github.com/nicepkg/mcporter)) | | 📦 **GitHub** | Read · Search | Zero config | [gh CLI](https://cli.github.com) powered. Public repos work immediately. `gh auth login` unlocks Fork, Issue, PR | | 📺 **YouTube** | Read · **Search** | Zero config | Subtitles + search across 1800+ video sites ([yt-dlp](https://github.com/yt-dlp/yt-dlp) ⭐148K) |