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:
+38
-53
@@ -502,24 +502,36 @@ def _install_system_deps():
|
||||
except Exception:
|
||||
print(" [!] Node.js install failed. Try: apt install nodejs npm, or nvm install 22, or download from https://nodejs.org")
|
||||
|
||||
# ── bird CLI (for Twitter search) ──
|
||||
if shutil.which("bird") or shutil.which("birdx"):
|
||||
print(" ✅ bird CLI already installed")
|
||||
# ── twitter-cli (for Twitter search) ──
|
||||
if shutil.which("twitter"):
|
||||
print(" ✅ twitter-cli already installed")
|
||||
else:
|
||||
if shutil.which("npm"):
|
||||
if shutil.which("pipx"):
|
||||
try:
|
||||
subprocess.run(
|
||||
["npm", "install", "-g", "@steipete/bird"],
|
||||
["pipx", "install", "twitter-cli"],
|
||||
capture_output=True, encoding="utf-8", errors="replace", timeout=120,
|
||||
)
|
||||
if shutil.which("bird") or shutil.which("birdx"):
|
||||
print(" ✅ bird CLI installed (Twitter search + timeline)")
|
||||
if shutil.which("twitter"):
|
||||
print(" ✅ twitter-cli installed (Twitter search + timeline + article)")
|
||||
else:
|
||||
print(" -- bird CLI install failed (optional — Twitter reading still works via Jina)")
|
||||
print(" -- twitter-cli install failed (optional — Twitter reading still works via Jina)")
|
||||
except Exception:
|
||||
print(" -- bird CLI install failed (optional — Twitter reading still works via Jina)")
|
||||
print(" -- twitter-cli install failed (optional — Twitter reading still works via Jina)")
|
||||
elif shutil.which("uv"):
|
||||
try:
|
||||
subprocess.run(
|
||||
["uv", "tool", "install", "twitter-cli"],
|
||||
capture_output=True, encoding="utf-8", errors="replace", timeout=120,
|
||||
)
|
||||
if shutil.which("twitter"):
|
||||
print(" ✅ twitter-cli installed (Twitter search + timeline + article)")
|
||||
else:
|
||||
print(" -- twitter-cli install failed (optional)")
|
||||
except Exception:
|
||||
print(" -- twitter-cli install failed (optional)")
|
||||
else:
|
||||
print(" -- bird CLI requires Node.js (optional — Twitter reading still works via Jina)")
|
||||
print(" -- twitter-cli requires pipx or uv (optional — Twitter reading still works via Jina)")
|
||||
|
||||
# ── undici (proxy support for Node.js fetch) ──
|
||||
npm_cmd = shutil.which("npm")
|
||||
@@ -533,7 +545,7 @@ def _install_system_deps():
|
||||
subprocess.run([npm_cmd, "install", "-g", "undici"], capture_output=True, encoding="utf-8", errors="replace", timeout=60)
|
||||
print(" ✅ undici installed (Node.js proxy support)")
|
||||
except Exception:
|
||||
print(" -- undici install failed (optional — bird may not work behind proxies)")
|
||||
print(" -- undici install failed (optional — may not work behind proxies)")
|
||||
|
||||
# ── yt-dlp JS runtime config (YouTube requires external JS runtime) ──
|
||||
if shutil.which("node"):
|
||||
@@ -733,7 +745,7 @@ def _install_system_deps_safe():
|
||||
deps = [
|
||||
("gh", ["gh"], "GitHub CLI", "https://cli.github.com — or: apt install gh / brew install gh"),
|
||||
("node", ["node", "npm"], "Node.js", "https://nodejs.org — or: apt install nodejs npm"),
|
||||
("bird", ["bird", "birdx"], "bird CLI (Twitter)", "npm install -g @steipete/bird"),
|
||||
("twitter", ["twitter"], "twitter-cli (Twitter)", "pipx install twitter-cli"),
|
||||
]
|
||||
|
||||
missing = []
|
||||
@@ -786,7 +798,7 @@ def _install_system_deps_dryrun():
|
||||
checks = [
|
||||
("gh CLI", ["gh"], "apt install gh / brew install gh"),
|
||||
("Node.js", ["node"], "curl NodeSource setup | bash + apt install nodejs"),
|
||||
("bird CLI", ["bird", "birdx"], "npm install -g @steipete/bird"),
|
||||
("twitter-cli", ["twitter"], "pipx install twitter-cli"),
|
||||
]
|
||||
|
||||
for label, binaries, method in checks:
|
||||
@@ -1000,57 +1012,30 @@ def _cmd_configure(args):
|
||||
config.set("twitter_auth_token", auth_token)
|
||||
config.set("twitter_ct0", ct0)
|
||||
|
||||
# Sync credentials to bird CLI env
|
||||
try:
|
||||
import json
|
||||
# Legacy: sync to xfetch session.json for backward compat
|
||||
xfetch_dir = os.path.join(os.path.expanduser("~"), ".config", "xfetch")
|
||||
os.makedirs(xfetch_dir, exist_ok=True)
|
||||
session_path = os.path.join(xfetch_dir, "session.json")
|
||||
session_data = {}
|
||||
if os.path.exists(session_path):
|
||||
with open(session_path, "r", encoding="utf-8") as sf:
|
||||
session_data = json.load(sf)
|
||||
session_data["authToken"] = auth_token
|
||||
session_data["ct0"] = ct0
|
||||
with open(session_path, "w", encoding="utf-8") as sf:
|
||||
json.dump(session_data, sf, indent=2)
|
||||
os.chmod(session_path, 0o600)
|
||||
|
||||
# bird CLI: write shell-sourceable credentials.env
|
||||
bird_dir = os.path.join(os.path.expanduser("~"), ".config", "bird")
|
||||
os.makedirs(bird_dir, exist_ok=True)
|
||||
env_path = os.path.join(bird_dir, "credentials.env")
|
||||
with open(env_path, "w", encoding="utf-8") as f:
|
||||
f.write(f'AUTH_TOKEN="{auth_token}"\n')
|
||||
f.write(f'CT0="{ct0}"\n')
|
||||
os.chmod(env_path, 0o600)
|
||||
|
||||
print("✅ Twitter cookies configured (synced to bird)!")
|
||||
except Exception as e:
|
||||
print("✅ Twitter cookies configured!")
|
||||
print(f"[!] Could not sync to bird credentials: {e}")
|
||||
# Sync credentials to twitter-cli env
|
||||
print("✅ Twitter cookies configured!")
|
||||
|
||||
print("Testing Twitter access...", end=" ")
|
||||
try:
|
||||
import subprocess
|
||||
bird = shutil.which("bird") or shutil.which("birdx")
|
||||
if not bird:
|
||||
print("[!] bird CLI not installed. Run: npm install -g @steipete/bird")
|
||||
twitter_bin = shutil.which("twitter")
|
||||
if not twitter_bin:
|
||||
print("[!] twitter-cli not installed. Run: pipx install twitter-cli")
|
||||
else:
|
||||
import os
|
||||
env = os.environ.copy()
|
||||
env["AUTH_TOKEN"] = auth_token
|
||||
env["CT0"] = ct0
|
||||
env["TWITTER_AUTH_TOKEN"] = auth_token
|
||||
env["TWITTER_CT0"] = ct0
|
||||
result = subprocess.run(
|
||||
[bird, "search", "test", "-n", "1"],
|
||||
[twitter_bin, "status"],
|
||||
capture_output=True, encoding="utf-8", errors="replace", timeout=15,
|
||||
env=env,
|
||||
)
|
||||
if result.returncode == 0 and result.stdout.strip():
|
||||
print("✅ Twitter Advanced works!")
|
||||
output = (result.stdout or "") + (result.stderr or "")
|
||||
if "ok: true" in output:
|
||||
print("✅ Twitter access works!")
|
||||
else:
|
||||
print(f"[!] Test returned no results (cookies might be wrong)")
|
||||
print("[!] Auth check failed (cookies might be wrong)")
|
||||
except Exception as e:
|
||||
print(f"[X] Failed: {e}")
|
||||
else:
|
||||
@@ -1367,7 +1352,7 @@ def _cmd_uninstall(args):
|
||||
print()
|
||||
print("Optional: remove tools installed by Agent Reach:")
|
||||
print(" npm uninstall -g mcporter")
|
||||
print(" npm uninstall -g @steipete/bird")
|
||||
print(" pipx uninstall twitter-cli")
|
||||
print(" npm uninstall -g undici")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user