diff --git a/plugins/claude-code/scripts/run-sleep.sh b/plugins/claude-code/scripts/run-sleep.sh index e46e212..310d8de 100755 --- a/plugins/claude-code/scripts/run-sleep.sh +++ b/plugins/claude-code/scripts/run-sleep.sh @@ -30,12 +30,17 @@ if [ -z "${REPO_ROOT:-}" ]; then fi PY="" -for cand in python3.12 python3.11 python3.10 python3; do - if command -v "$cand" >/dev/null 2>&1; then - ver="$("$cand" -c 'import sys; print("%d%d" % sys.version_info[:2])' 2>/dev/null || echo 0)" - if [ "${ver:-0}" -ge 310 ]; then PY="$cand"; break; fi - fi -done +# Allow explicit Python override (useful on macOS with old system Python). +if [ -n "${SKILLOPT_SLEEP_PYTHON:-}" ]; then + PY="$SKILLOPT_SLEEP_PYTHON" +else + for cand in python3.12 python3.11 python3.10 python3; do + if command -v "$cand" >/dev/null 2>&1; then + ver="$("$cand" -c 'import sys; print("%d%d" % sys.version_info[:2])' 2>/dev/null || echo 0)" + if [ "${ver:-0}" -ge 310 ]; then PY="$cand"; break; fi + fi + done +fi if [ -z "$PY" ]; then echo "[sleep] ERROR: need Python >= 3.10 (found none)." >&2 exit 1 diff --git a/plugins/run-sleep.sh b/plugins/run-sleep.sh index e46e212..310d8de 100755 --- a/plugins/run-sleep.sh +++ b/plugins/run-sleep.sh @@ -30,12 +30,17 @@ if [ -z "${REPO_ROOT:-}" ]; then fi PY="" -for cand in python3.12 python3.11 python3.10 python3; do - if command -v "$cand" >/dev/null 2>&1; then - ver="$("$cand" -c 'import sys; print("%d%d" % sys.version_info[:2])' 2>/dev/null || echo 0)" - if [ "${ver:-0}" -ge 310 ]; then PY="$cand"; break; fi - fi -done +# Allow explicit Python override (useful on macOS with old system Python). +if [ -n "${SKILLOPT_SLEEP_PYTHON:-}" ]; then + PY="$SKILLOPT_SLEEP_PYTHON" +else + for cand in python3.12 python3.11 python3.10 python3; do + if command -v "$cand" >/dev/null 2>&1; then + ver="$("$cand" -c 'import sys; print("%d%d" % sys.version_info[:2])' 2>/dev/null || echo 0)" + if [ "${ver:-0}" -ge 310 ]; then PY="$cand"; break; fi + fi + done +fi if [ -z "$PY" ]; then echo "[sleep] ERROR: need Python >= 3.10 (found none)." >&2 exit 1 diff --git a/skillopt_sleep/cycle.py b/skillopt_sleep/cycle.py index 4678cff..e66f436 100644 --- a/skillopt_sleep/cycle.py +++ b/skillopt_sleep/cycle.py @@ -144,6 +144,14 @@ def run_sleep_cycle( _progress(cfg, f"using {len(tasks)} seeded tasks") else: since = state.last_harvest_for(project) + # On first run (no prior harvest), apply lookback_hours so we don't + # scan the entire transcript history and trigger massive LLM mining. + if since is None: + lookback_hours = cfg.get("lookback_hours", 72) + if lookback_hours and lookback_hours > 0: + import time + cutoff = time.time() - lookback_hours * 3600 + since = _now_iso(cutoff) max_tasks = cfg.get("max_tasks_per_night", 40) max_sessions = cfg.get("max_sessions_per_night", 0) or max_tasks * 3 candidate_limit = max_tasks