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(last-run): guard python3 absence + hoist datetime + use context manager

Trevin Chowb296a6551531
diff --git a/hooks/scripts/check-config.sh b/hooks/scripts/check-config.sh
index a9c7f698..41890276 100755
--- a/hooks/scripts/check-config.sh
+++ b/hooks/scripts/check-config.sh
@@ -74,15 +74,16 @@ else
LAST_RUN_FILE="$HOME/.config/last30days/last-run.json"
fi
LAST_RUN_LINE=""
-if [[ -n "$LAST_RUN_FILE" && -f "$LAST_RUN_FILE" ]]; then
- LAST_RUN_LINE=$(LAST_RUN_FILE="$LAST_RUN_FILE" python3 - <<'PY' 2>/dev/null
+if [[ -n "$LAST_RUN_FILE" && -f "$LAST_RUN_FILE" ]] && command -v python3 &>/dev/null; then
+ LAST_RUN_LINE=$(LAST_RUN_FILE="$LAST_RUN_FILE" python3 - <<'PY' 2>/dev/null || true
import datetime
import json
import os
path = os.environ["LAST_RUN_FILE"]
try:
- d = json.load(open(path))
+ with open(path) as fh:
+ d = json.load(fh)
topic = (d.get("topic") or "?")[:60]
ts = d.get("timestamp", "")
dt = datetime.datetime.fromisoformat(ts.replace("Z", "+00:00"))
diff --git a/skills/last30days/scripts/last30days.py b/skills/last30days/scripts/last30days.py
index d2df7fa1..0a870cc0 100644
--- a/skills/last30days/scripts/last30days.py
+++ b/skills/last30days/scripts/last30days.py
@@ -6,6 +6,7 @@ from __future__ import annotations
import argparse
import atexit
+import datetime
import json
import os
import re
@@ -533,7 +534,6 @@ def _show_runtime_ui(
def _write_last_run(topic: str, report: "schema.Report") -> None:
try:
- import datetime
if env.CONFIG_DIR is None:
return
target = env.CONFIG_DIR