fix(twitter): migrate from deleted bird CLI to twitter-cli (#231)

steipete/bird repo has been deleted (404). Migrates to twitter-cli
(public-clis/twitter-cli, 2137 stars, Python, actively maintained).

Changes:
- twitter.py: check() now detects `twitter` binary, parses `twitter status` YAML
- cli.py: install via pipx/uv instead of npm, test via `twitter status`
- cli.py: remove bird/xfetch credential sync, use TWITTER_AUTH_TOKEN/CT0 env
- skill references: bird commands → twitter-cli commands
- tests: 5 new tests covering all check() paths

104 tests passing.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Pnant
2026-03-31 15:51:26 +08:00
committed by GitHub
parent 66883060bc
commit c5a304dc20
5 changed files with 106 additions and 109 deletions
+22 -19
View File
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Twitter/X — check if bird CLI (@steipete/bird) is available."""
"""Twitter/X — check if twitter-cli (public-clis/twitter-cli) is available."""
import shutil
import subprocess
@@ -9,7 +9,7 @@ from .base import Channel
class TwitterChannel(Channel):
name = "twitter"
description = "Twitter/X 推文"
backends = ["bird CLI"]
backends = ["twitter-cli"]
tier = 1
def can_handle(self, url: str) -> bool:
@@ -18,33 +18,36 @@ class TwitterChannel(Channel):
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:
twitter = shutil.which("twitter")
if not twitter:
return "warn", (
"bird CLI 未安装。搜索可通过 Exa 替代。安装\n"
" npm install -g @steipete/bird"
"twitter-cli 未安装。安装方式\n"
" pipx install twitter-cli\n"
"或:\n"
" uv tool install twitter-cli"
)
try:
r = subprocess.run(
[bird, "check"], capture_output=True,
[twitter, "status"], capture_output=True,
encoding="utf-8", errors="replace", timeout=10
)
output = (r.stdout or "") + (r.stderr or "")
if r.returncode == 0:
return "ok", "完整可用(读取、搜索推文,含长文/X Article)"
# bird check returns 1 when auth is missing
if "Missing credentials" in output or "missing" in output.lower():
if r.returncode == 0 and "ok: true" in output:
return "ok", (
"完整可用(搜索、读推文、时间线、长文/Article、"
"用户查询、Thread"
)
if "not_authenticated" in output:
return "warn", (
"bird CLI 已安装但未配置认证。设置环境变量\n"
" export AUTH_TOKEN=\"xxx\"\n"
" export CT0=\"yyy\"\n"
"运行:\n"
" agent-reach configure twitter-cookies \"auth_token=xxx; ct0=yyy\""
"twitter-cli 已安装但未认证。设置方式\n"
" export TWITTER_AUTH_TOKEN=\"xxx\"\n"
" export TWITTER_CT0=\"yyy\"\n"
"确保已在浏览器中登录 x.com"
)
return "warn", (
"bird CLI 已安装但认证检查失败。运行:\n"
" agent-reach configure twitter-cookies \"auth_token=xxx; ct0=yyy\""
"twitter-cli 已安装但认证检查失败。运行:\n"
" twitter -v status 查看详细信息"
)
except Exception:
return "warn", "bird CLI 已安装但连接失败"
return "warn", "twitter-cli 已安装但连接失败"