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
feat(cli): LAST30DAYS_DEFAULT_SEARCH env var as default source set for --search (#536)
Hammad Khand434947e0365
diff --git a/CONFIGURATION.md b/CONFIGURATION.mdindex 34b97e5d..d8ba7f38 100644--- a/CONFIGURATION.md+++ b/CONFIGURATION.md@@ -149,6 +149,16 @@ The skill defaults to `api.bsky.app` for `searchPosts`, which is the canonical aBSKY_SEARCH_HOST=api.bsky.app # default — change only if Bluesky moves```+### Default source set (`LAST30DAYS_DEFAULT_SEARCH`)++By default the engine decides the source set per query (everything available, minus `EXCLUDE_SOURCES`). To pin a **fixed** source set for every run without passing `--search` each time — and without patching `SKILL.md`, which a release would overwrite — set:++```bash+LAST30DAYS_DEFAULT_SEARCH=reddit,x,youtube,hn+```++Accepts the same comma-separated names and aliases as `--search` (`web` → grounding, `hn` → hackernews, `bsky` → bluesky). Precedence: an explicit `--search` on the command line always wins; `LAST30DAYS_DEFAULT_SEARCH` applies only when the flag is omitted; when neither is set, per-query behavior is unchanged. `INCLUDE_SOURCES` / `EXCLUDE_SOURCES` keep their existing additive/subtractive roles on whichever set is selected.+---## Reasoning provider prioritydiff --git a/skills/last30days/scripts/last30days.py b/skills/last30days/scripts/last30days.pyindex f07019e4..e0732d3d 100644--- a/skills/last30days/scripts/last30days.py+++ b/skills/last30days/scripts/last30days.py@@ -74,7 +74,7 @@ def _cleanup_children() -> None:atexit.register(_cleanup_children)-def parse_search_flag(raw: str) -> list[str]:+def parse_search_flag(raw: str, flag_name: str = "--search") -> list[str]:sources = []for source in raw.split(","):source = source.strip().lower()@@ -82,14 +82,28 @@ def parse_search_flag(raw: str) -> list[str]:continuenormalized = pipeline.SEARCH_ALIAS.get(source, source)if normalized not in pipeline.MOCK_AVAILABLE_SOURCES:- raise SystemExit(f"Unknown search source: {source}")+ raise SystemExit(f"Unknown search source in {flag_name}: {source}")if normalized not in sources:sources.append(normalized)if not sources:- raise SystemExit("--search requires at least one source.")+ raise SystemExit(f"{flag_name} requires at least one source.")return sources+def resolve_requested_sources(args_search: str | None, config: dict) -> list[str] | None:+ """Resolve the requested source set: explicit --search wins, then the+ LAST30DAYS_DEFAULT_SEARCH config key (env var or .env file), then None+ (per-query default behavior). The config fallback lets users pin a fixed+ source set that survives upgrades without patching SKILL.md (#442).+ """+ if args_search:+ return parse_search_flag(args_search)+ default_search = (config.get("LAST30DAYS_DEFAULT_SEARCH") or "").strip()+ if default_search:+ return parse_search_flag(default_search, flag_name="LAST30DAYS_DEFAULT_SEARCH")+ return None++def slugify(value: str) -> str:slug = re.sub(r"[^a-z0-9]+", "-", value.lower()).strip("-")return slug or "last30days"@@ -647,7 +661,7 @@ def main() -> int:sys.stderr.write(setup_wizard.get_setup_status_text(results) + "\n")return 0- requested_sources = parse_search_flag(args.search) if args.search else None+ requested_sources = resolve_requested_sources(args.search, config)diag = pipeline.diagnose(config, requested_sources)if args.diagnose:diff --git a/skills/last30days/scripts/lib/env.py b/skills/last30days/scripts/lib/env.pyindex a5c54f89..04ba348e 100644--- a/skills/last30days/scripts/lib/env.py+++ b/skills/last30days/scripts/lib/env.py@@ -413,6 +413,7 @@ def get_config() -> dict[str, Any]:('SETUP_COMPLETE', None),('INCLUDE_SOURCES', ''),('EXCLUDE_SOURCES', ''),+ ('LAST30DAYS_DEFAULT_SEARCH', ''),('LAST30DAYS_YOUTUBE_SSH_HOST', None),('LAST30DAYS_TRANSCRIPT_TIMEOUT', None),('LAST30DAYS_YT_SUB_LANGS', 'en,es,pt'),diff --git a/tests/test_cli_v3.py b/tests/test_cli_v3.pyindex bb6c6609..480a77a1 100644--- a/tests/test_cli_v3.py+++ b/tests/test_cli_v3.py@@ -96,6 +96,34 @@ class CliV3Tests(unittest.TestCase):with self.assertRaises(SystemExit):cli.parse_search_flag(" , ")+ def test_resolve_requested_sources_flag_wins_over_config_default(self):+ sources = cli.resolve_requested_sources(+ "reddit", {"LAST30DAYS_DEFAULT_SEARCH": "x,youtube"},+ )+ self.assertEqual(["reddit"], sources)++ def test_resolve_requested_sources_falls_back_to_config_default(self):+ sources = cli.resolve_requested_sources(+ None, {"LAST30DAYS_DEFAULT_SEARCH": "web, reddit, hn"},+ )+ self.assertEqual(["grounding", "reddit", "hackernews"], sources)++ def test_resolve_requested_sources_none_when_neither_set(self):+ self.assertIsNone(cli.resolve_requested_sources(None, {}))+ self.assertIsNone(+ cli.resolve_requested_sources(None, {"LAST30DAYS_DEFAULT_SEARCH": ""})+ )+ self.assertIsNone(+ cli.resolve_requested_sources(None, {"LAST30DAYS_DEFAULT_SEARCH": " "})+ )++ def test_resolve_requested_sources_invalid_config_default_names_env_var(self):+ with self.assertRaises(SystemExit) as exc:+ cli.resolve_requested_sources(+ None, {"LAST30DAYS_DEFAULT_SEARCH": "notasource"},+ )+ self.assertIn("LAST30DAYS_DEFAULT_SEARCH", str(exc.exception))+def test_build_parser_accepts_days_alias_and_preserves_topic_tokens(self):parser = cli.build_parser()args, extra = parser.parse_known_args(["--days", "7", "biosecurity", "ai", "agents"])diff --git a/tests/test_env_default_search.py b/tests/test_env_default_search.pynew file mode 100644index 00000000..657ea181--- /dev/null+++ b/tests/test_env_default_search.py@@ -0,0 +1,34 @@+from lib import env+++def test_default_search_defaults_to_empty_string(monkeypatch, tmp_path):+ # Ensure the env var is not set+ monkeypatch.delenv("LAST30DAYS_DEFAULT_SEARCH", raising=False)++ # Avoid reading any real user config file by patching the resolved module path directly+ monkeypatch.setattr(env, "CONFIG_FILE", tmp_path / "does-not-exist.env")++ cfg = env.get_config()++ assert "LAST30DAYS_DEFAULT_SEARCH" in cfg+ assert cfg["LAST30DAYS_DEFAULT_SEARCH"] == ""+++def test_default_search_read_from_environment(monkeypatch, tmp_path):+ monkeypatch.setenv("LAST30DAYS_DEFAULT_SEARCH", "reddit,x,youtube")+ monkeypatch.setattr(env, "CONFIG_FILE", tmp_path / "does-not-exist.env")++ cfg = env.get_config()++ assert cfg["LAST30DAYS_DEFAULT_SEARCH"] == "reddit,x,youtube"+++def test_default_search_read_from_env_file(monkeypatch, tmp_path):+ monkeypatch.delenv("LAST30DAYS_DEFAULT_SEARCH", raising=False)+ env_file = tmp_path / "config.env"+ env_file.write_text("LAST30DAYS_DEFAULT_SEARCH=reddit,hn\n")+ monkeypatch.setattr(env, "CONFIG_FILE", env_file)++ cfg = env.get_config()++ assert cfg["LAST30DAYS_DEFAULT_SEARCH"] == "reddit,hn"