AI agent skill that researches any topic across Reddit, X, YouTube, HN, Polymarket, and the web - then synthesizes a grounded summary
Python ai-promptsai-skillblueskyclaudeclaude-codeclawhubdeep-researchhackernewsinstagramopenclawpolymarketrecencyredditresearchsocial-mediatiktoktrendstwitterweb-searchyoutube
fix(xurl): align availability probe with app-only search auth (#855)
Trevin Chow6f1ae7ce6326
diff --git a/skills/last30days/scripts/lib/xurl_x.py b/skills/last30days/scripts/lib/xurl_x.pyindex de4b2cd5..e3e65600 100644--- a/skills/last30days/scripts/lib/xurl_x.py+++ b/skills/last30days/scripts/lib/xurl_x.py@@ -5,8 +5,8 @@ xurl is X's official CLI for the X APIX Developer App. No xAI subscription or browser cookies needed.Install: npm install -g @xdevplatform/xurl-Auth: xurl auth app-only <bearer-token> (search)- xurl auth oauth1 ... (whoami / availability check)+Auth: xurl auth app-only <bearer-token> (search / availability)+ xurl auth oauth1 ... (optional; not used for search)Priority: xAI API > Bird/GraphQL > xurl > web-only fallback"""@@ -19,6 +19,11 @@ from typing import Any, Dict, List, Optionalfrom .relevance import token_overlap_relevance as _compute_relevance+# xurl auth status marks a configured app-only bearer as "bearer: ✓".+# Search uses --auth app, so availability must require this — oauth1 alone+# is not enough.+_BEARER_CONFIGURED_RE = re.compile(r"bearer:\s*✓")+def _log(msg: str) -> None:sys.stderr.write(f"[xurl] {msg}\n")@@ -34,19 +39,23 @@ DEPTH_CONFIG = {def is_available() -> bool:- """Check if xurl is installed and has valid authentication.+ """Check if xurl is installed and has app-only bearer auth.- Returns True only if xurl binary is found AND the user is authenticated- (i.e. ``xurl whoami`` exits 0 and returns a username field).+ Returns True only if xurl binary is found AND ``xurl auth status``+ exits 0 with a configured app-only bearer (``bearer: ✓``). OAuth1+ alone is insufficient — ``search_x`` pins ``--auth app``."""try:result = subprocess.run(- ["xurl", "whoami"],+ ["xurl", "auth", "status"],capture_output=True,text=True,timeout=10,)- return result.returncode == 0 and '"username"' in result.stdout+ return (+ result.returncode == 0+ and _BEARER_CONFIGURED_RE.search(result.stdout) is not None+ )except (OSError, subprocess.TimeoutExpired):# OSError covers FileNotFoundError (no xurl on PATH) and# PermissionError (a non-executable match on PATH, e.g. WSL'sdiff --git a/tests/test_xurl_x.py b/tests/test_xurl_x.pyindex 723dd955..e4db593e 100644--- a/tests/test_xurl_x.py+++ b/tests/test_xurl_x.py@@ -26,10 +26,24 @@ def _make_api_response(tweets=None, users=None):class TestIsAvailable(unittest.TestCase):- def test_returns_true_when_xurl_authenticated(self):- completed = mock.Mock(returncode=0, stdout='{"username": "testuser"}')- with mock.patch("subprocess.run", return_value=completed):+ def test_returns_true_when_bearer_configured(self):+ completed = mock.Mock(+ returncode=0,+ stdout="oauth1: ✗\nbearer: ✓\n",+ )+ with mock.patch("subprocess.run", return_value=completed) as run_mock:self.assertTrue(xurl_x.is_available())+ call_args = run_mock.call_args[0][0]+ self.assertEqual(call_args[:3], ["xurl", "auth", "status"])++ def test_returns_false_when_oauth1_only(self):+ # OAuth1 alone cannot satisfy search_x's --auth app requirement.+ completed = mock.Mock(+ returncode=0,+ stdout="oauth1: ✓\nbearer: ✗\n",+ )+ with mock.patch("subprocess.run", return_value=completed):+ self.assertFalse(xurl_x.is_available())def test_returns_false_when_not_authenticated(self):completed = mock.Mock(returncode=1, stdout="")@@ -52,9 +66,9 @@ class TestIsAvailable(unittest.TestCase):with mock.patch("subprocess.run", side_effect=subprocess.TimeoutExpired("xurl", 10)):self.assertFalse(xurl_x.is_available())- def test_returns_false_when_no_username_in_output(self):- # returncode=0 but output does not contain '"username"'- completed = mock.Mock(returncode=0, stdout='{"id": "123"}')+ def test_returns_false_when_no_bearer_marker(self):+ # returncode=0 but status output has no bearer: ✓+ completed = mock.Mock(returncode=0, stdout="oauth1: ✗\nbearer: ✗\n")with mock.patch("subprocess.run", return_value=completed):self.assertFalse(xurl_x.is_available())