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
Address review feedback: gate LinkedIn behind INCLUDE_SOURCES, add date-range filtering, update docs
Ravi Shresthaad52872ecf22
diff --git a/CONFIGURATION.md b/CONFIGURATION.mdindex 5e6a16fb..d527b16a 100644--- a/CONFIGURATION.md+++ b/CONFIGURATION.md@@ -99,6 +99,7 @@ The project-scoped file is useful for **intentional per-client setups**: drop a| Instagram | `SCRAPECREATORS_API_KEY` + `INCLUDE_SOURCES` contains `instagram` | Instagram Reels | 10K free calls; raise `LAST30DAYS_TRANSCRIPT_TIMEOUT` (default 30s) if SC is slow on your network || Threads | `SCRAPECREATORS_API_KEY` + `INCLUDE_SOURCES` contains `threads` | Threads items | 10K free calls || Pinterest | `SCRAPECREATORS_API_KEY` + `INCLUDE_SOURCES` contains `pinterest` | Pinterest items | 10K free calls |+| LinkedIn | `SCRAPECREATORS_API_KEY` + `INCLUDE_SOURCES` contains `linkedin` | LinkedIn posts | 10K free calls; power-user opt-in, not offered during first-run onboarding || Bluesky | `BSKY_HANDLE` + `BSKY_APP_PASSWORD` | Bluesky items | yes (app password at bsky.app) || TruthSocial | `TRUTHSOCIAL_TOKEN` | TruthSocial items | yes || Web search | one of: `BRAVE_API_KEY`, `EXA_API_KEY`, `SERPER_API_KEY`, `PARALLEL_API_KEY` | `--auto-resolve` and Step 2 supplements | Brave has a free tier; native WebSearch on Claude Code / Codex / Gemini works as a fallback |diff --git a/skills/last30days/SKILL.md b/skills/last30days/SKILL.mdindex 6534d424..ab869d98 100644--- a/skills/last30days/SKILL.md+++ b/skills/last30days/SKILL.md@@ -44,6 +44,7 @@ metadata:- youtube- tiktok- hackernews- polymarket- digg@@ -533,7 +534,7 @@ The magic of /last30days is Reddit comments + X posts together - and both are fr**Bonus: TikTok, Instagram, YouTube comments (ScrapeCreators):**- `SCRAPECREATORS_API_KEY=xxx` - 10,000 free calls at scrapecreators.com.-- After adding your key, set `INCLUDE_SOURCES=tiktok,instagram` to turn on the popular ones. (Threads and Pinterest are also available via `INCLUDE_SOURCES=threads,pinterest` for power users.)+- After adding your key, set `INCLUDE_SOURCES=tiktok,instagram` to turn on the popular ones. (Threads, Pinterest, and LinkedIn are also available via `INCLUDE_SOURCES=threads,pinterest,linkedin` for power users.)**Other optional sources (add anytime):**- `PERPLEXITY_API_KEY=xxx` (or `OPENROUTER_API_KEY=xxx`) - AI-synthesized research with citations; set `INCLUDE_SOURCES=perplexity`.@@ -592,7 +593,7 @@ SKILL_DIR="<absolute path of the directory containing the SKILL.md you just Read"${LAST30DAYS_PYTHON}" "${SKILL_DIR}/scripts/last30days.py" --diagnose```-`--diagnose` prints JSON. `ACTIVE_SOURCES_LIST` is its `available_sources` array — the engine's authoritative source set, computed after credential resolution. Map the tokens to display names: `reddit`→Reddit, `hackernews`→Hacker News, `polymarket`→Polymarket, `github`→GitHub, `digg`→Digg, `x`→X, `youtube`→YouTube, `tiktok`→TikTok, `instagram`→Instagram, `threads`→Threads, `pinterest`→Pinterest, `bluesky`→Bluesky, `perplexity`→Perplexity, `grounding`→Web, `jobs`→Jobs.+`--diagnose` prints JSON. `ACTIVE_SOURCES_LIST` is its `available_sources` array — the engine's authoritative source set, computed after credential resolution. Map the tokens to display names: `reddit`→Reddit, `hackernews`→Hacker News, `polymarket`→Polymarket, `github`→GitHub, `digg`→Digg, `x`→X, `youtube`→YouTube, `tiktok`→TikTok, `instagram`→Instagram, `threads`→Threads, `pinterest`→Pinterest, `linkedin`→LinkedIn, `bluesky`→Bluesky, `perplexity`→Perplexity, `grounding`→Web, `jobs`→Jobs.- If EXCLUDE_SOURCES is set (comma-separated, case-insensitive): drop any matching source from ACTIVE_SOURCES_LIST before displayingdiff --git a/skills/last30days/scripts/lib/linkedin.py b/skills/last30days/scripts/lib/linkedin.pyindex 99c08e3e..ceb88dce 100644--- a/skills/last30days/scripts/lib/linkedin.py+++ b/skills/last30days/scripts/lib/linkedin.py@@ -10,7 +10,6 @@ Requires SCRAPECREATORS_API_KEY environment variable.from __future__ import annotationsimport re-import sysfrom typing import Any, Dict, Listfrom urllib.parse import urlencode@@ -115,10 +114,19 @@ def _int_field(post: dict[str, Any], *keys: str) -> int:return 0-def parse_linkedin_response(result: Dict[str, Any]) -> List[Dict[str, Any]]:+def parse_linkedin_response(+ result: Dict[str, Any],+ from_date: str | None = None,+ to_date: str | None = None,+) -> List[Dict[str, Any]]:"""Parse ScrapeCreators LinkedIn response into engine-compatible item dicts.Each returned dict must be normalizable by normalize._normalize_linkedin.++ If from_date/to_date are given, applies the same hard date-range filter+ used by instagram.search_and_enrich: drop items outside the window, but+ fall back to keeping everything if the filter would otherwise empty the+ result (SC doesn't always return a usable date per post)."""posts = result.get("posts") or []items: List[Dict[str, Any]] = []@@ -181,4 +189,14 @@ def parse_linkedin_response(result: Dict[str, Any]) -> List[Dict[str, Any]]:"relevance": 0.5,})+ if from_date and to_date:+ in_range = [i for i in items if i["date"] and from_date <= i["date"] <= to_date]+ out_of_range = len(items) - len(in_range)+ if in_range:+ items = in_range+ if out_of_range:+ _log(f"Filtered {out_of_range} posts outside date range")+ elif items:+ _log(f"No posts within date range, keeping all {len(items)}")+return itemsdiff --git a/skills/last30days/scripts/lib/pipeline.py b/skills/last30days/scripts/lib/pipeline.pyindex f6691b44..df52fadd 100644--- a/skills/last30days/scripts/lib/pipeline.py+++ b/skills/last30days/scripts/lib/pipeline.py@@ -120,7 +120,7 @@ def available_sources(config: dict[str, Any], requested_sources: list[str] | Non# reddit_public needs no API key - always availableavailable.append("reddit")if config.get("SCRAPECREATORS_API_KEY"):- available.extend(["tiktok", "instagram", "linkedin"])+ available.extend(["tiktok", "instagram"])if env.get_x_source(config):available.append("x")if which("yt-dlp") or env.is_youtube_sc_available(config):@@ -151,6 +151,15 @@ def available_sources(config: dict[str, Any], requested_sources: list[str] | Non"perplexity" in include_sources or (requested_sources and "perplexity" in requested_sources)):available.append("perplexity")+ # LinkedIn: opt-in additive source via INCLUDE_SOURCES=linkedin (same+ # consent pattern as Perplexity). Unlike tiktok/instagram, which are+ # offered during SKILL.md Step 0 onboarding, LinkedIn is power-user-only+ # and must not silently activate for existing SCRAPECREATORS_API_KEY+ # holders.+ if config.get("SCRAPECREATORS_API_KEY") and (+ "linkedin" in include_sources or (requested_sources and "linkedin" in requested_sources)+ ):+ available.append("linkedin")if requested_sources and "xiaohongshu" in requested_sources and env.is_xiaohongshu_available(config):available.append("xiaohongshu")if env.is_threads_available(config):@@ -1409,7 +1418,7 @@ def _retrieve_stream(depth=depth,token=config.get("SCRAPECREATORS_API_KEY", ""),)- return linkedin.parse_linkedin_response(result), {}+ return linkedin.parse_linkedin_response(result, from_date=from_date, to_date=to_date), {}if source == "hackernews":result = hackernews.search_hackernews(subquery.search_query, from_date, to_date, depth=depth)return hackernews.parse_hackernews_response(result, query=subquery.search_query), {}diff --git a/tests/test_linkedin.py b/tests/test_linkedin.pyindex 10aad288..56901a63 100644--- a/tests/test_linkedin.py+++ b/tests/test_linkedin.py@@ -184,5 +184,49 @@ class TestSearchLinkedin(unittest.TestCase):self.assertIn("error", result)+class TestDateRangeFiltering(unittest.TestCase):+ def test_filters_out_posts_outside_range(self):+ posts = [+ {"text": "in range", "date": "2026-06-15"},+ {"text": "too old", "date": "2026-01-01"},+ ]+ items = parse_linkedin_response(+ {"posts": posts}, from_date="2026-05-27", to_date="2026-06-26"+ )+ self.assertEqual(1, len(items))+ self.assertEqual("in range", items[0]["text"])++ def test_keeps_all_when_none_in_range(self):+ # Graceful fallback: SC doesn't always return a parseable date, so if+ # the filter would drop everything, keep the unfiltered set instead+ # of returning zero results.+ posts = [+ {"text": "old post", "date": "2026-01-01"},+ {"text": "older post", "date": "2025-12-01"},+ ]+ items = parse_linkedin_response(+ {"posts": posts}, from_date="2026-05-27", to_date="2026-06-26"+ )+ self.assertEqual(2, len(items))++ def test_no_filtering_when_dates_not_provided(self):+ posts = [{"text": "any date", "date": "2020-01-01"}]+ items = parse_linkedin_response({"posts": posts})+ self.assertEqual(1, len(items))++ def test_posts_without_date_excluded_from_in_range_but_not_counted_as_failure(self):+ posts = [+ {"text": "has date in range", "date": "2026-06-15"},+ {"text": "no date at all"},+ ]+ items = parse_linkedin_response(+ {"posts": posts}, from_date="2026-05-27", to_date="2026-06-26"+ )+ # Only the dated, in-range post survives; the undated one isn't+ # counted toward "in range" and gets dropped since in_range is non-empty.+ self.assertEqual(1, len(items))+ self.assertEqual("has date in range", items[0]["text"])++if __name__ == "__main__":unittest.main()diff --git a/tests/test_pipeline_v3.py b/tests/test_pipeline_v3.pyindex 9f55e638..8d8c7a3e 100644--- a/tests/test_pipeline_v3.py+++ b/tests/test_pipeline_v3.py@@ -1276,6 +1276,36 @@ class TestPerplexityAvailability(unittest.TestCase):self.assertTrue(diag["local_mode"])+class TestLinkedinAvailability(unittest.TestCase):+ """LinkedIn is power-user opt-in (INCLUDE_SOURCES=linkedin), unlike+ tiktok/instagram which activate on SCRAPECREATORS_API_KEY alone. This+ keeps existing SCRAPECREATORS_API_KEY holders from silently picking up a+ new source — and spending new credits — on their next run."""++ def test_not_available_with_key_alone(self):+ sources = pipeline.available_sources({"SCRAPECREATORS_API_KEY": "test-key"})+ self.assertNotIn("linkedin", sources)+ # tiktok/instagram remain unconditional with just the key+ self.assertIn("tiktok", sources)+ self.assertIn("instagram", sources)++ def test_available_with_key_and_include_sources(self):+ sources = pipeline.available_sources(+ {"SCRAPECREATORS_API_KEY": "test-key", "INCLUDE_SOURCES": "linkedin"}+ )+ self.assertIn("linkedin", sources)++ def test_available_with_key_and_requested_sources(self):+ sources = pipeline.available_sources(+ {"SCRAPECREATORS_API_KEY": "test-key"}, requested_sources=["linkedin"]+ )+ self.assertIn("linkedin", sources)++ def test_not_available_with_include_sources_but_no_key(self):+ sources = pipeline.available_sources({"INCLUDE_SOURCES": "linkedin"})+ self.assertNotIn("linkedin", sources)++class TestKeylessGroundingAvailability(unittest.TestCase):"""Grounding (general web) availability is host-aware.