Skip to content

AI agent skill that researches any topic across Reddit, X, YouTube, HN, Polymarket, and the web - then synthesizes a grounded summary

fix(review): address greptile review comments

Diogo Andre Santos2655d8f4c81a
diff --git a/skills/last30days/scripts/lib/env.py b/skills/last30days/scripts/lib/env.py
index 9496ea47..7f3c708e 100644
--- a/skills/last30days/scripts/lib/env.py
+++ b/skills/last30days/scripts/lib/env.py
@@ -272,9 +272,13 @@ def get_config() -> dict[str, Any]:
sc_key_raw = config.get('SCRAPECREATORS_API_KEY') or ''
if ',' in sc_key_raw:
- import random
sc_keys = [k.strip() for k in sc_key_raw.split(',') if k.strip()]
- config['SCRAPECREATORS_API_KEY'] = random.choice(sc_keys) if sc_keys else ''
+ if sc_keys:
+ import hashlib
+ idx = int(hashlib.md5(','.join(sc_keys).encode()).hexdigest(), 16) % len(sc_keys)
+ config['SCRAPECREATORS_API_KEY'] = sc_keys[idx]
+ else:
+ config['SCRAPECREATORS_API_KEY'] = ''
# Track which config source was used
if project_env_path:
diff --git a/skills/last30days/scripts/lib/reddit_public.py b/skills/last30days/scripts/lib/reddit_public.py
index e8f3dc88..a49bd20b 100644
--- a/skills/last30days/scripts/lib/reddit_public.py
+++ b/skills/last30days/scripts/lib/reddit_public.py
@@ -22,11 +22,7 @@ from concurrent.futures import ThreadPoolExecutor, TimeoutError as FuturesTimeou
from typing import Any, Dict, List, Optional
-USER_AGENT = (
- "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) "
- "AppleWebKit/537.36 (KHTML, like Gecko) "
- "Chrome/124.0.0.0 Safari/537.36"
-)
+USER_AGENT = "last30days/3.0 (research tool)"
# Depth-aware limits for thread counts
DEPTH_LIMITS = {
@@ -65,9 +61,7 @@ def _fetch_json(url: str, timeout: int = 15) -> Optional[Dict[str, Any]]:
headers = {
"User-Agent": USER_AGENT,
"Accept": "application/json",
- "Accept-Language": "en-US,en;q=0.9",
"Accept-Encoding": "gzip, deflate",
- "Connection": "keep-alive",
}
req = urllib.request.Request(url, headers=headers)
diff --git a/skills/last30days/scripts/lib/render.py b/skills/last30days/scripts/lib/render.py
index bf355fd8..e25b864c 100644
--- a/skills/last30days/scripts/lib/render.py
+++ b/skills/last30days/scripts/lib/render.py
@@ -1026,7 +1026,7 @@ def render_brief(report: schema.Report, cluster_limit: int = 8) -> str:
)
lines.append("")
- tensions = [c for c in report.clusters if c.uncertainty]
+ tensions = [c for c in report.clusters[:cluster_limit] if c.uncertainty]
if tensions:
lines.append("## Topic Tensions")
lines.append("")
@@ -1069,7 +1069,7 @@ def _extract_audience_questions(candidates: list[schema.Candidate]) -> list[str]
if not title:
continue
first_word = title.split()[0].lower().rstrip("?")
- if title.endswith("?") or first_word in _QUESTION_WORDS:
+ if title.endswith("?"):
norm = title.lower()
if norm not in seen:
seen.add(norm)
@@ -1712,8 +1712,6 @@ def _stats_actor(item: schema.SourceItem) -> str | None:
return f"r/{item.container}"
if item.source in {"x", "bluesky", "truthsocial"} and item.author:
return f"@{item.author.lstrip('@')}"
- if item.source == "grounding" and item.container:
- return item.container
if item.source == "youtube" and item.author:
return item.author
if item.container and item.container != "Polymarket":
diff --git a/tests/test_reddit_public.py b/tests/test_reddit_public.py
index ef0d57ce..c0889fe1 100644
--- a/tests/test_reddit_public.py
+++ b/tests/test_reddit_public.py
@@ -313,7 +313,7 @@ class TestSearchRedditPublicHighLevel:
reddit_public.search("test")
req = mock_urlopen.call_args[0][0]
- assert "Mozilla/5.0" in req.get_header("User-agent")
+ assert "last30days/3.0" in req.get_header("User-agent")
class TestMissingSubreddit: