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(hooks): add LAST30DAYS_QUIET to quiet the SessionStart status hook (#958)
dnorth12330d47be7020b
diff --git a/CONFIGURATION.md b/CONFIGURATION.mdindex 222ef7e8..36733d75 100644--- a/CONFIGURATION.md+++ b/CONFIGURATION.md@@ -108,6 +108,8 @@ Override the global location with `LAST30DAYS_CONFIG_DIR=/path` (or `LAST30DAYS_The project-scoped file is useful for **intentional per-client setups**: drop a `.claude/last30days.env` into each client folder (`SCRAPECREATORS_API_KEY`, `INCLUDE_SOURCES`, `LAST30DAYS_MEMORY_DIR`, `BSKY_HANDLE`, etc), then opt in with `LAST30DAYS_TRUST_PROJECT_CONFIG=1` from your shell or `~/.config/last30days/.env`. Folder-mode hosts such as Codex desktop do not trust hidden project config by default, and discovery stops at the git root so unrelated parent folders cannot silently influence runs. The SessionStart status hook (`hooks/scripts/check-config.sh`) uses the same trust gate — an untrusted repo's `.claude/last30days.env` is not read at session start.+**`LAST30DAYS_QUIET`** - quiet the SessionStart status hook. When truthy (`1`, `true`, `yes`, `on`), `hooks/scripts/check-config.sh` drops the first-run welcome and the ScrapeCreators tip while keeping the one-line status and the last-run summary. Useful once you have deliberately settled on a set of sources: without it, an install that never adds a key is advised to run the setup wizard at every session start indefinitely. Resolves like the other settings here, process environment first, then `~/.config/last30days/.env`, then a trusted project file. Unset or falsy leaves the output byte-for-byte as before.+**`LAST30DAYS_API_KEY`** + **`LAST30DAYS_API_BASE`** - optional remote-API backend. Set BOTH to route research through a remote API endpoint instead of running the local sources: `LAST30DAYS_API_BASE` is the endpoint (there is no built-in default), and `LAST30DAYS_API_KEY` is the bearer key for it. When both are set (and `--mock` is not passed), the engine submits the topic to that endpoint, polls with progress on stderr, and prints the server's report; none of the per-source keys below are used for that run. A configured local corpus is the privacy exception: the engine bypasses the hosted backend and runs locally rather than forwarding file-derived input. Non-default `--register` selections are forwarded with the request so server-side synthesis uses the same audience preset. Leave either unset to run local sources exactly as normal. Unlike the other keys here, these two are read only from the **process environment** (export them in your shell or host config) - they are deliberately not loaded from the `.env` files above, so a project-scoped `.env` can never silently redirect research to a remote endpoint. The remote endpoint does not return the local `Report` needed for the versioned agent JSON profile; use `--emit=json --json-profile=raw` for its existing server-response JSON contract.**`BRIGHTDATA_API_KEY`** - optional, for the `amazon` source. The Bright Data CLI normally owns its own auth via `brightdata login`, so this is only needed if you would rather keep an explicit key in `.env` or the keychain. It is resolved through the standard config layering and passed to the CLI through the child process environment, never on the command line (where it would be readable from `/proc/<pid>/cmdline` by other local users on a shared host).diff --git a/changelog.d/+quiet-session-start-hook.added.md b/changelog.d/+quiet-session-start-hook.added.mdnew file mode 100644index 00000000..c95e5a8d--- /dev/null+++ b/changelog.d/+quiet-session-start-hook.added.md@@ -0,0 +1 @@+`LAST30DAYS_QUIET` quiets the SessionStart status hook. Setting it to a truthy value (`1`, `true`, `yes`, `on`) drops the first-run welcome and the ScrapeCreators tip while keeping the one-line status and the last-run summary. Previously there was no way to turn either off: an install that deliberately stays on the free sources was advised to run the setup wizard at every session start, in every project, indefinitely. The variable resolves through the existing precedence chain (process environment, then the global `.env`, then a trusted project file), and is a no-op when unset or falsy.diff --git a/hooks/scripts/check-config.sh b/hooks/scripts/check-config.shindex b967223e..36572cb8 100755--- a/hooks/scripts/check-config.sh+++ b/hooks/scripts/check-config.sh@@ -100,6 +100,19 @@ is_truthy() {esac}+# Quiet mode: suppress the onboarding welcome and the upsell tips, keeping the+# one-line status. Same precedence as every other setting: the process+# environment wins when set, otherwise the global config file is consulted.+# A project-scoped file reaches this only through the existing trust gate,+# because ENV_* vars are populated by load_env_vars after that check.+is_quiet() {+ if [[ "${LAST30DAYS_QUIET+x}" == "x" ]]; then+ is_truthy "$LAST30DAYS_QUIET"+ return $?+ fi+ is_truthy "${ENV_LAST30DAYS_QUIET:-}"+}+# Project config cannot self-grant trust. Process env (including empty/0 deny)# wins when set; otherwise the global config file's trust flag is consulted.project_config_trusted() {@@ -243,6 +256,14 @@ fi# If setup has never been run, show welcome message for new usersif [[ -z "$SETUP_COMPLETE" && -z "$CONFIG_FILE" && -z "${ENV_OPENAI_API_KEY:-${OPENAI_API_KEY:-}}" && -z "${ENV_SCRAPECREATORS_API_KEY:-${SCRAPECREATORS_API_KEY:-}}" && -z "${ENV_AUTH_TOKEN:-${AUTH_TOKEN:-}}" && -z "${ENV_XAI_API_KEY:-${XAI_API_KEY:-}}" ]]; then+ # Nothing is configured, so every line below is onboarding copy. In quiet+ # mode emit only the last-run status, when there is one, and stop.+ if is_quiet; then+ if [[ -n "$LAST_RUN_LINE" ]]; then+ echo "$LAST_RUN_LINE"+ fi+ exit 0+ fi# printf, NOT cat-with-heredoc: see the bash 5.3 heredoc deadlock note above.if [[ -n "$HAS_YTDLP" ]]; then# YouTube is already working via the on-system yt-dlp binary — don't list@@ -329,6 +350,10 @@ elseif [[ -n "$LAST_RUN_LINE" ]]; thenecho "$LAST_RUN_LINE"fi+ # Status already printed above; the rest of this branch is an upsell.+ if is_quiet; then+ exit 0+ 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_check_config_quiet.py b/tests/test_check_config_quiet.pynew file mode 100644index 00000000..17c721af--- /dev/null+++ b/tests/test_check_config_quiet.py@@ -0,0 +1,164 @@+"""Tests for LAST30DAYS_QUIET in hooks/scripts/check-config.sh.++The SessionStart status hook prints an onboarding welcome when nothing is+configured, and a ScrapeCreators tip when setup is done without that key.+Neither can be turned off, so a user who has deliberately settled on the+free sources sees setup advice at every session start forever.++LAST30DAYS_QUIET suppresses the onboarding and upsell lines while keeping+the one-line status. Every case below is asserted in both directions: the+quiet run drops the copy, and the otherwise-identical non-quiet run still+emits it, so a test cannot pass because the hook printed nothing at all.++Cases:+ - unconfigured + quiet -> silent; without quiet -> welcome+ - setup done, no ScrapeCreators -> status kept, tip dropped+ - quiet read from the config file, not only the process environment+ - falsy values do not enable quiet+ - last-run status survives quiet on the unconfigured path+"""++from __future__ import annotations++import json+import os+import shutil+import subprocess+from pathlib import Path++import pytest++HOOK = Path(__file__).resolve().parents[1] / "hooks" / "scripts" / "check-config.sh"++_CLEARED = (+ "LAST30DAYS_MEMORY_DIR",+ "LAST30DAYS_QUIET",+ "SETUP_COMPLETE",+ "LAST30DAYS_CONFIG_DIR",+ "OPENAI_API_KEY",+ "SCRAPECREATORS_API_KEY",+ "AUTH_TOKEN",+ "XAI_API_KEY",+ "CT0",+ "BSKY_HANDLE",+ "BSKY_APP_PASSWORD",+ "EXA_API_KEY",+)++WELCOME = "Ready to use. Run /last30days"+TIP = "Tip: Add ScrapeCreators"+STATUS = "sources active"+++def _run_hook(env_overrides: dict[str, str]) -> subprocess.CompletedProcess:+ env = os.environ.copy()+ for key in _CLEARED:+ env.pop(key, None)+ env.update(env_overrides)+ bash_path = shutil.which("bash")+ if bash_path is None:+ pytest.skip("bash not on PATH")+ return subprocess.run(+ [bash_path, str(HOOK)],+ capture_output=True,+ text=True,+ env=env,+ timeout=30,+ )+++def _cfg_dir(tmp_path: Path, name: str = "cfg", env_body: str | None = None) -> str:+ """Config dir holding a well-formed last-run.json, optionally an .env.++ The hook reads last-run.json through a python3 subshell; supplying a valid+ one keeps these tests independent of the empty-last-run exit bug (#440).+ """+ cfg = tmp_path / name+ cfg.mkdir()+ (cfg / "last-run.json").write_text(+ json.dumps({"topic": "quiet mode", "timestamp": "2026-06-01T00:00:00Z", "total": 0})+ )+ if env_body is not None:+ env_file = cfg / ".env"+ env_file.write_text(env_body)+ env_file.chmod(0o600)+ return str(cfg)++[email protected](shutil.which("bash") is None, reason="bash not on PATH")+def test_quiet_suppresses_new_user_welcome(tmp_path: Path):+ """Unconfigured + quiet is silent; the same run without quiet is not."""+ quiet = _run_hook({"LAST30DAYS_CONFIG_DIR": _cfg_dir(tmp_path, "a"), "LAST30DAYS_QUIET": "1"})+ loud = _run_hook({"LAST30DAYS_CONFIG_DIR": _cfg_dir(tmp_path, "b")})++ assert quiet.returncode == 0, f"hook failed: stderr={quiet.stderr!r}"+ assert loud.returncode == 0, f"hook failed: stderr={loud.stderr!r}"++ # Positive control: without quiet the welcome is present, so the assertion+ # below is testing suppression rather than an unrelated early exit.+ assert WELCOME in loud.stdout, f"control run lost the welcome: {loud.stdout!r}"+ assert WELCOME not in quiet.stdout, f"quiet run kept the welcome: {quiet.stdout!r}"++[email protected](shutil.which("bash") is None, reason="bash not on PATH")+def test_quiet_keeps_status_and_drops_scrapecreators_tip(tmp_path: Path):+ """Setup done without ScrapeCreators: status survives, the upsell does not."""+ base = {"SETUP_COMPLETE": "true"}+ quiet = _run_hook({**base, "LAST30DAYS_CONFIG_DIR": _cfg_dir(tmp_path, "a"), "LAST30DAYS_QUIET": "1"})+ loud = _run_hook({**base, "LAST30DAYS_CONFIG_DIR": _cfg_dir(tmp_path, "b")})++ assert quiet.returncode == 0, f"hook failed: stderr={quiet.stderr!r}"+ assert loud.returncode == 0, f"hook failed: stderr={loud.stderr!r}"++ assert TIP in loud.stdout, f"control run lost the tip: {loud.stdout!r}"+ assert TIP not in quiet.stdout, f"quiet run kept the tip: {quiet.stdout!r}"+ # Quiet trims the copy, it does not silence a configured install.+ assert STATUS in quiet.stdout, f"quiet run lost the status line: {quiet.stdout!r}"++[email protected](shutil.which("bash") is None, reason="bash not on PATH")+def test_quiet_honored_from_config_file(tmp_path: Path):+ """The global .env can set quiet, matching how every other setting resolves."""+ cfg = _cfg_dir(tmp_path, "a", env_body="SETUP_COMPLETE=true\nLAST30DAYS_QUIET=true\n")+ control = _cfg_dir(tmp_path, "b", env_body="SETUP_COMPLETE=true\n")++ quiet = _run_hook({"LAST30DAYS_CONFIG_DIR": cfg})+ loud = _run_hook({"LAST30DAYS_CONFIG_DIR": control})++ assert quiet.returncode == 0, f"hook failed: stderr={quiet.stderr!r}"+ assert loud.returncode == 0, f"hook failed: stderr={loud.stderr!r}"++ assert TIP in loud.stdout, f"control run lost the tip: {loud.stdout!r}"+ assert TIP not in quiet.stdout, f"config-file quiet was ignored: {quiet.stdout!r}"++[email protected](shutil.which("bash") is None, reason="bash not on PATH")[email protected]("value", ["0", "false", "no", "off", ""])+def test_falsy_values_do_not_enable_quiet(tmp_path: Path, value: str):+ """Only the documented truthy set turns quiet on; everything else is a no-op."""+ result = _run_hook(+ {+ "SETUP_COMPLETE": "true",+ "LAST30DAYS_CONFIG_DIR": _cfg_dir(tmp_path),+ "LAST30DAYS_QUIET": value,+ }+ )++ assert result.returncode == 0, f"hook failed: stderr={result.stderr!r}"+ assert TIP in result.stdout, (+ f"LAST30DAYS_QUIET={value!r} should not enable quiet mode: {result.stdout!r}"+ )++[email protected](shutil.which("bash") is None, reason="bash not on PATH")+def test_quiet_preserves_last_run_line_when_unconfigured(tmp_path: Path):+ """Quiet drops onboarding copy, not the last-run status a returning user wants."""+ result = _run_hook(+ {"LAST30DAYS_CONFIG_DIR": _cfg_dir(tmp_path), "LAST30DAYS_QUIET": "1"}+ )++ assert result.returncode == 0, f"hook failed: stderr={result.stderr!r}"+ assert WELCOME not in result.stdout+ assert "quiet mode" in result.stdout, (+ f"expected the last-run topic to survive quiet mode: {result.stdout!r}"+ )