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
fix: check-config.sh exits 0 when no prior run (empty LAST_RUN_LINE) (#539)
SAI MOHANEESH5f499d4eeca1
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 12ab1f4d..7478c45f 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0- YouTube transcript budget prioritises recent videos (by a combination of views and recency) instead of views alone, preventing transcript slots from being consumed by old high-view-count videos that would be discarded by strict_recent freshness pruning ([#531](https://github.com/mvanhorn/last30days-skill/issues/531))- YouTube items with successfully extracted transcripts are no longer pruned by title-only relevance scoring; the transcript content proves substantive topical coverage even when the video title has low lexical overlap with the query ([#468](https://github.com/mvanhorn/last30days-skill/issues/468))- First-run setup wizard in SKILL.md now references the existing Python setup wizard (`last30days.py setup`) instead of the missing `nux-wizard.md` file, so first-run setup actually runs on new installs. ([#574](https://github.com/mvanhorn/last30days-skill/issues/574))+- `check-config.sh` no longer exits 1 on the ScrapeCreators-configured path when no prior run exists (empty `LAST_RUN_LINE`) — swapped `&&` guard for an `if` block that always exits cleanly ([#463](https://github.com/mvanhorn/last30days-skill/issues/463))- `check-config.sh` no longer exits 1 when a `.env` value contains an unbalanced quote — replaced `xargs` (which interprets quotes) with `sed` for whitespace trimming in `load_env_vars` ([#506](https://github.com/mvanhorn/last30days-skill/issues/506))- `subproc.py` `run_with_timeout()` now guards `os.killpg` / `os.getpgid` with `hasattr`, preventing an uncaught `AttributeError` crash when a subprocess times out on Windows where these functions don't exist ([#527](https://github.com/mvanhorn/last30days-skill/issues/527))- Entity-grounding rerank demotion now keys on the head token of the primary entity instead of requiring the full multi-word phrase as a contiguous substring. A high-engagement on-entity item (e.g. a 323-pt HN thread titled "Stripe is friendly to 'friendly fraud'") is no longer demoted to score 0 on a `Stripe payments` query just because it lacks the trailing search-hint word. The intended demotion still fires for items that never name the brand at all. The keyless Reddit comment-enrichment slot selection (`_slot_priority`), which mirrors this signal, was updated to the same head-token grounding so the two paths stay consistent.diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.mdindex 36ac3a49..d7cd4137 100644--- a/CONTRIBUTORS.md+++ b/CONTRIBUTORS.md@@ -59,5 +59,6 @@ v3 has durable watchlist with multi-source storage and extended time windows.- [@levineam](https://github.com/levineam) - Model fallback for unverified orgs ([#16](https://github.com/mvanhorn/last30days-skill/pull/16))- [@jonthebeef](https://github.com/jonthebeef) - Early testing and feedback- [@23241a6749](https://github.com/23241a6749) - Windows cp1252 fixes: utf-8 plan-file reads, skill_meta version-detection encoding, MSYS noacl permission check skip ([#549](https://github.com/mvanhorn/last30days-skill/pull/549)); first-run setup wizard fix: SKILL.md references existing Python setup wizard instead of missing nux-wizard.md ([#574](https://github.com/mvanhorn/last30days-skill/pull/574))+- [@23241a6749](https://github.com/23241a6749) - check-config.sh clean-exit on missing last-run.json ([#463](https://github.com/mvanhorn/last30days-skill/issues/463))- [@23241a6749](https://github.com/23241a6749) - check-config.sh xargs unterminated quote fix ([#506](https://github.com/mvanhorn/last30days-skill/issues/506))- [@23241a6749](https://github.com/23241a6749) - Windows subprocess timeout fix: guard os.killpg/os.getpgid with hasattr in subproc.py ([#527](https://github.com/mvanhorn/last30days-skill/issues/527))diff --git a/hooks/scripts/check-config.sh b/hooks/scripts/check-config.shindex ec205972..21a85772 100755--- a/hooks/scripts/check-config.sh+++ b/hooks/scripts/check-config.sh@@ -114,7 +114,9 @@ if [[ -z "$SETUP_COMPLETE" && -z "$CONFIG_FILE" && -z "${OPENAI_API_KEY:-}" && -Reddit, Hacker News, and Polymarket work out of the box.The setup wizard can unlock X/Twitter, YouTube, and more.EOF- [[ -n "$LAST_RUN_LINE" ]] && echo "$LAST_RUN_LINE"+ if [[ -n "$LAST_RUN_LINE" ]]; then+ echo "$LAST_RUN_LINE"+ fiexit 0fi@@ -166,12 +168,16 @@ if [[ -n "$HAS_SCRAPECREATORS" ]]; then# Fully configured — compact ready messageecho "/last30days: Ready — ${SOURCE_COUNT} sources active."echo " Research any topic across social + market + web sources (last 30 days)."- [[ -n "$LAST_RUN_LINE" ]] && echo "$LAST_RUN_LINE"+ if [[ -n "$LAST_RUN_LINE" ]]; then+ echo "$LAST_RUN_LINE"+ fielse# Setup done but missing ScrapeCreators — recommend itecho "/last30days: Ready — ${SOURCE_COUNT} sources active."echo " Research any topic across social + market + web sources (last 30 days)."- [[ -n "$LAST_RUN_LINE" ]] && echo "$LAST_RUN_LINE"+ if [[ -n "$LAST_RUN_LINE" ]]; then+ echo "$LAST_RUN_LINE"+ fiecho " Tip: Add ScrapeCreators for Reddit comments + TikTok + Instagram."echo " 100 free credits, no credit card — scrapecreators.com"echo " last30days has no affiliation with any API provider."diff --git a/tests/test_last_run_state.py b/tests/test_last_run_state.pyindex 15ddd4d1..e8c8885b 100644--- a/tests/test_last_run_state.py+++ b/tests/test_last_run_state.py@@ -1,11 +1,15 @@+import ioimport jsonimport osimport subprocessimport sysimport tempfileimport unittest+from contextlib import redirect_stderrfrom pathlib import Path+from unittest import mock+import last30days as cliREPO_ROOT = Path(__file__).resolve().parents[1]LAST30DAYS_SCRIPT = REPO_ROOT / "skills" / "last30days" / "scripts" / "last30days.py"@@ -80,6 +84,27 @@ class LastRunStateTests(unittest.TestCase):self.assertEqual(result.returncode, 0, result.stderr)self.assertIn('Last run: "custom hook query"', result.stdout)+ def test_hook_exits_0_when_no_last_run(self):+ """Script exits 0 when ScrapeCreators configured but no prior run (last-run.json absent)."""+ with tempfile.TemporaryDirectory() as tmp:+ env = os.environ.copy()+ env["HOME"] = str(Path(tmp) / "home")+ env["SETUP_COMPLETE"] = "true"+ env["ENV_SCRAPECREATORS_API_KEY"] = "sk-test"++ result = subprocess.run(+ ["bash", "hooks/scripts/check-config.sh"],+ cwd=REPO_ROOT,+ env=env,+ capture_output=True,+ text=True,+ check=False,+ )++ self.assertEqual(result.returncode, 0, result.stderr)+ self.assertIn("Ready —", result.stdout)+ self.assertNotIn("Last run:", result.stdout)+def test_hook_parses_dotenv_with_unbalanced_quote(self):"""Script exits 0 when .env contains an unbalanced quote in a value."""with tempfile.TemporaryDirectory() as tmp:@@ -108,6 +133,40 @@ class LastRunStateTests(unittest.TestCase):self.assertEqual(result.returncode, 0, result.stderr)self.assertIn("Ready —", result.stdout)+ def test_hook_shows_last_run_when_json_exists(self):+ """Script exits 0 and shows last-run summary when last-run.json exists."""+ with tempfile.TemporaryDirectory() as tmp:+ config_dir = Path(tmp) / "custom-config"+ config_dir.mkdir()+ (config_dir / "last-run.json").write_text(+ json.dumps(+ {+ "topic": "prior research",+ "timestamp": "2026-06-01T12:00:00+00:00",+ "sources": {"reddit": 5},+ "total": 5,+ }+ )+ )+ env = os.environ.copy()+ env["HOME"] = str(Path(tmp) / "home")+ env["SETUP_COMPLETE"] = "true"+ env["ENV_SCRAPECREATORS_API_KEY"] = "sk-test"+ env["LAST30DAYS_CONFIG_DIR"] = str(config_dir)++ result = subprocess.run(+ ["bash", "hooks/scripts/check-config.sh"],+ cwd=REPO_ROOT,+ env=env,+ capture_output=True,+ text=True,+ check=False,+ )++ self.assertEqual(result.returncode, 0, result.stderr)+ self.assertIn('Last run: "prior research"', result.stdout)++class TestSkillMdFirstRunReference(unittest.TestCase):"""Verifies SKILL.md references that exist in the CLI."""@@ -118,20 +177,27 @@ class TestSkillMdFirstRunReference(unittest.TestCase):"SKILL.md should not reference the missing nux-wizard.md file",)- def test_setup_subcommand_exists(self):- """The setup subcommand referenced in SKILL.md must exist."""- result = subprocess.run(- [sys.executable, str(LAST30DAYS_SCRIPT), "setup", "--help"],- cwd=REPO_ROOT,- capture_output=True,- text=True,- )- self.assertEqual(result.returncode, 0, result.stderr)+ def test_skill_md_references_setup_command(self):+ content = SKILL_MD.read_text(encoding="utf-8")self.assertIn(- "usage:", result.stdout.lower(),- "--help should print usage for setup subcommand",+ "last30days.py setup", content,+ "SKILL.md should reference the Python setup subcommand",)+ def test_setup_subcommand_dispatches(self):+ """topic 'setup' must reach setup_wizard, not be swallowed by argparse."""+ with mock.patch.object(cli.env, "get_config", return_value={}), \+ mock.patch("lib.setup_wizard.run_auto_setup", return_value={"cookies_found": {}}) as mock_setup, \+ mock.patch("lib.setup_wizard.write_setup_config") as mock_write, \+ mock.patch("lib.setup_wizard.get_setup_status_text", return_value="ok"), \+ mock.patch.object(sys, "argv", ["last30days.py", "setup"]):+ stderr = io.StringIO()+ with redirect_stderr(stderr):+ rc = cli.main()+ self.assertEqual(0, rc)+ mock_setup.assert_called_once()+ mock_write.assert_called_once()+if __name__ == "__main__":unittest.main()