BREAKING CHANGE: Remove all `agent-reach read` and `agent-reach search-*` commands. Agent Reach is now an installer, configuration tool, and doctor — not a wrapper layer. After installation, agents call upstream tools directly (bird CLI, yt-dlp, mcporter, gh CLI, Jina Reader, etc.). What's kept: - agent-reach install: one-shot installer - agent-reach doctor: channel status overview - agent-reach configure: cookies, proxy, credentials - agent-reach setup: interactive wizard - SKILL.md: complete guide for agents to use upstream tools directly What's removed: - agent-reach read URL (and all channel read() methods) - agent-reach search-* commands (and all channel search() methods) - ReadResult / SearchResult data classes - URL routing system (get_channel_for_url) - All parsing/conversion logic (VTT, Reddit JSON, bird text parser, etc.) - MCP server read/search tools (kept only get_status) Net change: -1790 lines. Less code = fewer bugs.
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
# -*- coding: utf-8 -*-
|
||
"""Twitter/X — check if bird CLI is available."""
|
||
|
||
import shutil
|
||
import subprocess
|
||
from .base import Channel
|
||
|
||
|
||
class TwitterChannel(Channel):
|
||
name = "twitter"
|
||
description = "Twitter/X 推文"
|
||
backends = ["bird CLI"]
|
||
tier = 1
|
||
|
||
def can_handle(self, url: str) -> bool:
|
||
from urllib.parse import urlparse
|
||
d = urlparse(url).netloc.lower()
|
||
return "x.com" in d or "twitter.com" in d
|
||
|
||
def check(self, config=None):
|
||
bird = shutil.which("bird") or shutil.which("birdx")
|
||
if not bird:
|
||
return "warn", (
|
||
"bird CLI 未安装。搜索可通过 Exa 替代。安装:\n"
|
||
" npm install -g @steipete/bird"
|
||
)
|
||
try:
|
||
r = subprocess.run(
|
||
[bird, "whoami"], capture_output=True, text=True, timeout=10
|
||
)
|
||
if r.returncode == 0:
|
||
return "ok", "完整可用(读取、搜索推文)"
|
||
return "warn", (
|
||
"bird CLI 已安装但未配置 Cookie。运行:\n"
|
||
" agent-reach configure twitter-cookies \"auth_token=xxx; ct0=yyy\""
|
||
)
|
||
except Exception:
|
||
return "warn", "bird CLI 已安装但连接失败"
|