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
Merge remote-tracking branch 'origin/main' into fix/xurl-app-only-search-auth
Trevin Chow5c6e671596f0
diff --cc skills/last30days/scripts/lib/xurl_x.pyindex e3e65600,df30ee32..556b5db5--- a/skills/last30days/scripts/lib/xurl_x.py+++ b/skills/last30days/scripts/lib/xurl_x.py@@@ -13,21 -12,17 +13,22 @@@ Priority: xAI API > Bird/GraphQL > xurimport jsonimport re+ import shutilimport subprocess- import sys- from typing import Any, Dict, List, Optional+ from pathlib import Path+ from typing import Any, Dict, List, Optional, Tuple+ from . import logfrom .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")- sys.stderr.flush()+ log.source_log("xurl", msg, tty_only=False)# Depth configurations: number of results to request@@@ -38,16 -33,38 +39,39 @@@ DEPTH_CONFIG =}+ # Memoized availability, mirroring health.py's per-process dependency-probe-# cache: each uncached is_available() check spawns an `xurl whoami`-# subprocess (a live, authenticated X API call). The doctor/safe-diagnose++# cache: each uncached is_available() check spawns an `xurl auth status`++# subprocess (local credential status; no network). The doctor/safe-diagnose+ # path never uses it — see stored_auth_status()/has_stored_auth() below —+ # but research-time callers may consult it more than once per process.+ # None means "not yet probed".+ _availability_cache: Optional[bool] = None+++ def clear_availability_cache() -> None:+ """Reset the memoized is_available() result (tests, or a re-check after auth)."""+ global _availability_cache+ _availability_cache = None++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``.+ Memoized per process; ``clear_availability_cache()`` resets."""+ global _availability_cache+ if _availability_cache is None:+ _availability_cache = _is_available_uncached()+ return _availability_cache+++ def _is_available_uncached() -> bool:try:result = subprocess.run(- ["xurl", "whoami"],+ ["xurl", "auth", "status"],capture_output=True,text=True,timeout=10,diff --cc tests/test_xurl_x.pyindex e4db593e,46258615..be6751c0--- a/tests/test_xurl_x.py+++ b/tests/test_xurl_x.py@@@ -26,24 -28,15 +28,29 @@@ def _make_api_response(tweets=None, useclass TestIsAvailable(unittest.TestCase):+ def setUp(self):+ # is_available() memoizes per process; isolate every test.+ xurl_x.clear_availability_cache()+ self.addCleanup(xurl_x.clear_availability_cache)+- 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="")