fix: Twitter bird CLI fetch failed — 自动代理注入 + 连通性检测 + Exa fallback

问题:bird CLI 用 Node.js 原生 fetch(),不走 HTTP_PROXY,
导致需要代理的用户(如 Windows + 本地代理)完全无法使用。

修复:
1. 自动代理注入:检测到 HTTP_PROXY/HTTPS_PROXY 时,通过 undici 的
   EnvHttpProxyAgent 让 Node.js fetch 自动走代理,用户无需任何额外配置
2. doctor 检测:实际跑 bird whoami 测连通性,失败时给出具体原因
3. search fallback:bird 搜索失败时自动 fallback 到 Exa
4. install:自动安装 undici(npm install -g undici)
5. 新增 troubleshooting.md:常见问题解决方案

Fixes #9
This commit is contained in:
Panniantong
2026-02-25 21:27:13 +01:00
parent b6d135c977
commit 12bd727e30
3 changed files with 179 additions and 6 deletions
+13
View File
@@ -423,6 +423,19 @@ def _install_system_deps():
else:
print(" ⬜ bird CLI requires Node.js (optional — Twitter reading still works via Jina)")
# ── undici (proxy support for Node.js fetch) ──
if shutil.which("npm"):
npm_root = subprocess.run(["npm", "root", "-g"], capture_output=True, text=True, timeout=5).stdout.strip()
undici_path = os.path.join(npm_root, "undici", "index.js") if npm_root else ""
if os.path.exists(undici_path):
print(" ✅ undici already installed (Node.js proxy support)")
else:
try:
subprocess.run(["npm", "install", "-g", "undici"], capture_output=True, text=True, timeout=60)
print(" ✅ undici installed (Node.js proxy support)")
except Exception:
print(" ⬜ undici install failed (optional — bird may not work behind proxies)")
# ── instaloader (for Instagram) ──
if shutil.which("instaloader"):
print(" ✅ instaloader already installed")