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
refactor(query): extract SOCIAL_NOISE and VIRAL_NOISE shared sets (#437)
Ilia Alshanetsky9fff90b62bce
diff --git a/skills/last30days/scripts/lib/bluesky.py b/skills/last30days/scripts/lib/bluesky.pyindex f75d399e..603872f4 100644--- a/skills/last30days/scripts/lib/bluesky.py+++ b/skills/last30days/scripts/lib/bluesky.py@@ -158,14 +158,8 @@ def _reset_session_cache() -> None:def _extract_core_subject(topic: str) -> str:"""Extract core subject from verbose query for Bluesky search."""- from .query import extract_core_subject- _BSKY_NOISE = frozenset({- 'best', 'top', 'good', 'great', 'awesome',- 'latest', 'new', 'news', 'update', 'updates',- 'trending', 'hottest', 'popular', 'viral',- 'practices', 'features', 'recommendations', 'advice',- })- return extract_core_subject(topic, noise=_BSKY_NOISE)+ from .query import SOCIAL_NOISE, extract_core_subject+ return extract_core_subject(topic, noise=SOCIAL_NOISE)def _parse_date(item: Dict[str, Any]) -> Optional[str]:diff --git a/skills/last30days/scripts/lib/instagram.py b/skills/last30days/scripts/lib/instagram.pyindex b3372446..39eca7df 100644--- a/skills/last30days/scripts/lib/instagram.py+++ b/skills/last30days/scripts/lib/instagram.py@@ -69,17 +69,8 @@ def _resolve_transcript_timeout(def _extract_core_subject(topic: str) -> str:"""Extract core subject from verbose query for Instagram search."""- from .query import extract_core_subject- _INSTAGRAM_NOISE = frozenset({- 'best', 'top', 'good', 'great', 'awesome', 'killer',- 'latest', 'new', 'news', 'update', 'updates',- 'trending', 'hottest', 'popular', 'viral',- 'practices', 'features',- 'recommendations', 'advice',- 'prompt', 'prompts', 'prompting',- 'methods', 'strategies', 'approaches',- })- return extract_core_subject(topic, noise=_INSTAGRAM_NOISE)+ from .query import VIRAL_NOISE, extract_core_subject+ return extract_core_subject(topic, noise=VIRAL_NOISE)def _to_hashtag_form(query: str) -> str:diff --git a/skills/last30days/scripts/lib/pinterest.py b/skills/last30days/scripts/lib/pinterest.pyindex 1c589832..08002a65 100644--- a/skills/last30days/scripts/lib/pinterest.py+++ b/skills/last30days/scripts/lib/pinterest.py@@ -27,17 +27,8 @@ from .relevance import token_overlap_relevance as _compute_relevancedef _extract_core_subject(topic: str) -> str:"""Extract core subject from verbose query for Pinterest search."""- from .query import extract_core_subject- _PINTEREST_NOISE = frozenset({- 'best', 'top', 'good', 'great', 'awesome', 'killer',- 'latest', 'new', 'news', 'update', 'updates',- 'trending', 'hottest', 'popular', 'viral',- 'practices', 'features',- 'recommendations', 'advice',- 'prompt', 'prompts', 'prompting',- 'methods', 'strategies', 'approaches',- })- return extract_core_subject(topic, noise=_PINTEREST_NOISE)+ from .query import VIRAL_NOISE, extract_core_subject+ return extract_core_subject(topic, noise=VIRAL_NOISE)def _log(msg: str):diff --git a/skills/last30days/scripts/lib/query.py b/skills/last30days/scripts/lib/query.pyindex 38c76a10..e735e623 100644--- a/skills/last30days/scripts/lib/query.py+++ b/skills/last30days/scripts/lib/query.py@@ -54,6 +54,28 @@ NOISE_WORDS = frozenset({})+# Shared noise sets for adapter `_extract_core_subject` wrappers.+#+# SOCIAL_NOISE: short-form micro-social platforms (Bluesky, Threads, Truth Social)+# where research/meta words rarely appear in the body of a post.+SOCIAL_NOISE = frozenset({+ 'best', 'top', 'good', 'great', 'awesome',+ 'latest', 'new', 'news', 'update', 'updates',+ 'trending', 'hottest', 'popular', 'viral',+ 'practices', 'features', 'recommendations', 'advice',+ 'or', 'and',+})++# VIRAL_NOISE: viral / discovery platforms (TikTok, Instagram, Pinterest) and+# the base for YouTube. Adds 'killer', the prompt-meta cluster, and the+# methodology cluster on top of SOCIAL_NOISE.+VIRAL_NOISE = SOCIAL_NOISE | frozenset({+ 'killer',+ 'prompt', 'prompts', 'prompting',+ 'methods', 'strategies', 'approaches',+})++def extract_core_subject(topic: str,*,diff --git a/skills/last30days/scripts/lib/threads.py b/skills/last30days/scripts/lib/threads.pyindex c7d2a0bc..628b171f 100644--- a/skills/last30days/scripts/lib/threads.py+++ b/skills/last30days/scripts/lib/threads.py@@ -36,18 +36,12 @@ def _extract_core_subject(topic: str) -> str:emits "A OR B") return zero. Strip boolean operators and cap to the twomost salient words."""- from .query import extract_core_subject- _THREADS_NOISE = frozenset({- 'best', 'top', 'good', 'great', 'awesome',- 'latest', 'new', 'news', 'update', 'updates',- 'trending', 'hottest', 'popular', 'viral',- 'practices', 'features', 'recommendations', 'advice',- 'or', 'and',- })- core = extract_core_subject(topic, noise=_THREADS_NOISE, max_words=2)+ from .query import SOCIAL_NOISE, extract_core_subject+ core = extract_core_subject(topic, noise=SOCIAL_NOISE, max_words=2)return " ".join(core.rstrip("?!.").split()[:2])+def _parse_date(item: Dict[str, Any]) -> Optional[str]:"""Parse date from Threads item to YYYY-MM-DD.diff --git a/skills/last30days/scripts/lib/tiktok.py b/skills/last30days/scripts/lib/tiktok.pyindex 81e7a39b..c35771eb 100644--- a/skills/last30days/scripts/lib/tiktok.py+++ b/skills/last30days/scripts/lib/tiktok.py@@ -31,17 +31,8 @@ from .relevance import token_overlap_relevance as _compute_relevancedef _extract_core_subject(topic: str) -> str:"""Extract core subject from verbose query for TikTok search."""- from .query import extract_core_subject- _TIKTOK_NOISE = frozenset({- 'best', 'top', 'good', 'great', 'awesome', 'killer',- 'latest', 'new', 'news', 'update', 'updates',- 'trending', 'hottest', 'popular', 'viral',- 'practices', 'features',- 'recommendations', 'advice',- 'prompt', 'prompts', 'prompting',- 'methods', 'strategies', 'approaches',- })- return extract_core_subject(topic, noise=_TIKTOK_NOISE)+ from .query import VIRAL_NOISE, extract_core_subject+ return extract_core_subject(topic, noise=VIRAL_NOISE)def expand_tiktok_queries(topic: str, depth: str) -> List[str]:diff --git a/skills/last30days/scripts/lib/truthsocial.py b/skills/last30days/scripts/lib/truthsocial.pyindex 83043e65..c0a338dd 100644--- a/skills/last30days/scripts/lib/truthsocial.py+++ b/skills/last30days/scripts/lib/truthsocial.py@@ -33,14 +33,8 @@ def _strip_html(html: str) -> str:def _extract_core_subject(topic: str) -> str:"""Extract core subject from verbose query for Truth Social search."""- from .query import extract_core_subject- _TS_NOISE = frozenset({- 'best', 'top', 'good', 'great', 'awesome',- 'latest', 'new', 'news', 'update', 'updates',- 'trending', 'hottest', 'popular', 'viral',- 'practices', 'features', 'recommendations', 'advice',- })- return extract_core_subject(topic, noise=_TS_NOISE)+ from .query import SOCIAL_NOISE, extract_core_subject+ return extract_core_subject(topic, noise=SOCIAL_NOISE)def _parse_date(status: Dict[str, Any]) -> Optional[str]:diff --git a/skills/last30days/scripts/lib/youtube_yt.py b/skills/last30days/scripts/lib/youtube_yt.pyindex cc0b358d..33742d6f 100644--- a/skills/last30days/scripts/lib/youtube_yt.py+++ b/skills/last30days/scripts/lib/youtube_yt.py@@ -217,25 +217,17 @@ def _extract_core_subject(topic: str) -> str:NOTE: 'tips', 'tricks', 'tutorial', 'guide', 'review', 'reviews'are intentionally KEPT — they're YouTube content types that improve search."""- from .query import extract_core_subject- # YouTube-specific noise set: smaller than default, keeps content-type words- _YT_NOISE = frozenset({- 'best', 'top', 'good', 'great', 'awesome', 'killer',- 'latest', 'new', 'news', 'update', 'updates',- 'trending', 'hottest', 'popular', 'viral',- 'practices', 'features',- 'recommendations', 'advice',- 'prompt', 'prompts', 'prompting',- 'methods', 'strategies', 'approaches',- # Temporal/meta words — planner generates these but they don't- # appear in YouTube titles, so strip them for better search.+ from .query import VIRAL_NOISE, extract_core_subject+ # YouTube extends VIRAL_NOISE with temporal/meta words the planner emits+ # that don't appear in YouTube titles (months, recent year tokens, etc.).+ _YT_EXTRA = frozenset({'last', 'days', 'recent', 'recently', 'month', 'week','january', 'february', 'march', 'april', 'may', 'june','july', 'august', 'september', 'october', 'november', 'december','2025', '2026', '2027','music', 'public', 'appearances', 'developments', 'discussions', 'coverage',})- return extract_core_subject(topic, noise=_YT_NOISE)+ return extract_core_subject(topic, noise=VIRAL_NOISE | _YT_EXTRA)def expand_youtube_queries(topic: str, depth: str) -> List[str]:diff --git a/tests/test_query.py b/tests/test_query.pyindex a737fcbd..b8048550 100644--- a/tests/test_query.py+++ b/tests/test_query.py@@ -4,6 +4,8 @@ import unittestfrom lib.query import (NOISE_WORDS,+ SOCIAL_NOISE,+ VIRAL_NOISE,extract_compound_terms,extract_core_subject,infer_query_intent,@@ -128,6 +130,59 @@ class TestNoiseWordsCompleteness(unittest.TestCase):+class TestSharedAdapterNoiseSets(unittest.TestCase):+ """Pin SOCIAL_NOISE / VIRAL_NOISE so adapters can rely on stable membership.++ Bluesky, Threads, Truth Social use SOCIAL_NOISE.+ TikTok, Instagram, Pinterest use VIRAL_NOISE.+ YouTube extends VIRAL_NOISE with temporal/meta tokens (asserted in its+ own adapter test).+ """++ def test_social_noise_membership(self):+ # Words shared with the historical _BSKY_NOISE / _TS_NOISE / _THREADS_NOISE.+ expected = {+ 'best', 'top', 'good', 'great', 'awesome',+ 'latest', 'new', 'news', 'update', 'updates',+ 'trending', 'hottest', 'popular', 'viral',+ 'practices', 'features', 'recommendations', 'advice',+ 'or', 'and',+ }+ self.assertEqual(set(SOCIAL_NOISE), expected)++ def test_viral_noise_is_social_superset(self):+ self.assertTrue(SOCIAL_NOISE.issubset(VIRAL_NOISE))+ # The extra words VIRAL adds on top of SOCIAL: the historical+ # tiktok / instagram / pinterest delta.+ delta = VIRAL_NOISE - SOCIAL_NOISE+ self.assertEqual(+ delta,+ {'killer', 'prompt', 'prompts', 'prompting',+ 'methods', 'strategies', 'approaches'},+ )++ def test_extract_core_subject_with_social_noise(self):+ # Sanity: a Bluesky-style query strips through SOCIAL_NOISE.+ result = extract_core_subject(+ "best new Claude Code update",+ noise=SOCIAL_NOISE,+ )+ self.assertEqual(result, "claude code")++ def test_extract_core_subject_with_viral_noise(self):+ # Viral set strips 'killer' and the prompt cluster.+ result = extract_core_subject(+ "killer prompting strategies for React",+ noise=VIRAL_NOISE,+ )+ # 'for' is in the default NOISE_WORDS path but VIRAL_NOISE alone+ # doesn't include articles/prepositions; extract_core_subject+ # falls back to original when nothing survives, so allow 'for'.+ self.assertIn("react", result)+ self.assertNotIn("killer", result)+ self.assertNotIn("prompting", result)++class TestInferQueryIntent(unittest.TestCase):"""Tests for infer_query_intent() — the shared canonical classifier.