Skip to content

Commit 889238b

Browse files
carpedkmclaude
andcommitted
fix: add SKILLOPT_SLEEP_PYTHON override + lookback_hours first-run fallback
Two fixes from issue #57 feedback: 1. run-sleep.sh: support SKILLOPT_SLEEP_PYTHON env var to explicitly set the Python interpreter. Useful on macOS where system Python is 3.9 but a newer Python is available elsewhere (e.g. Codex Desktop's bundled Python 3.12). Applied to both the shared runner and the bundled Claude Code plugin copy. 2. cycle.py: on first run (no prior harvest recorded), apply the lookback_hours config (default 72h) as a time cutoff. Previously, first run scanned the entire transcript history, which could trigger massive LLM mining on users with months of session data. Co-Authored-By: Claude Fable 5 <[email protected]>
1 parent b5a1c2b commit 889238b

3 files changed

Lines changed: 30 additions & 12 deletions

File tree

‎plugins/claude-code/scripts/run-sleep.sh‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,17 @@ if [ -z "${REPO_ROOT:-}" ]; then
3030
fi
3131

3232
PY=""
33-
for cand in python3.12 python3.11 python3.10 python3; do
34-
if command -v "$cand" >/dev/null 2>&1; then
35-
ver="$("$cand" -c 'import sys; print("%d%d" % sys.version_info[:2])' 2>/dev/null || echo 0)"
36-
if [ "${ver:-0}" -ge 310 ]; then PY="$cand"; break; fi
37-
fi
38-
done
33+
# Allow explicit Python override (useful on macOS with old system Python).
34+
if [ -n "${SKILLOPT_SLEEP_PYTHON:-}" ]; then
35+
PY="$SKILLOPT_SLEEP_PYTHON"
36+
else
37+
for cand in python3.12 python3.11 python3.10 python3; do
38+
if command -v "$cand" >/dev/null 2>&1; then
39+
ver="$("$cand" -c 'import sys; print("%d%d" % sys.version_info[:2])' 2>/dev/null || echo 0)"
40+
if [ "${ver:-0}" -ge 310 ]; then PY="$cand"; break; fi
41+
fi
42+
done
43+
fi
3944
if [ -z "$PY" ]; then
4045
echo "[sleep] ERROR: need Python >= 3.10 (found none)." >&2
4146
exit 1

‎plugins/run-sleep.sh‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,17 @@ if [ -z "${REPO_ROOT:-}" ]; then
3030
fi
3131

3232
PY=""
33-
for cand in python3.12 python3.11 python3.10 python3; do
34-
if command -v "$cand" >/dev/null 2>&1; then
35-
ver="$("$cand" -c 'import sys; print("%d%d" % sys.version_info[:2])' 2>/dev/null || echo 0)"
36-
if [ "${ver:-0}" -ge 310 ]; then PY="$cand"; break; fi
37-
fi
38-
done
33+
# Allow explicit Python override (useful on macOS with old system Python).
34+
if [ -n "${SKILLOPT_SLEEP_PYTHON:-}" ]; then
35+
PY="$SKILLOPT_SLEEP_PYTHON"
36+
else
37+
for cand in python3.12 python3.11 python3.10 python3; do
38+
if command -v "$cand" >/dev/null 2>&1; then
39+
ver="$("$cand" -c 'import sys; print("%d%d" % sys.version_info[:2])' 2>/dev/null || echo 0)"
40+
if [ "${ver:-0}" -ge 310 ]; then PY="$cand"; break; fi
41+
fi
42+
done
43+
fi
3944
if [ -z "$PY" ]; then
4045
echo "[sleep] ERROR: need Python >= 3.10 (found none)." >&2
4146
exit 1

‎skillopt_sleep/cycle.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,14 @@ def run_sleep_cycle(
144144
_progress(cfg, f"using {len(tasks)} seeded tasks")
145145
else:
146146
since = state.last_harvest_for(project)
147+
# On first run (no prior harvest), apply lookback_hours so we don't
148+
# scan the entire transcript history and trigger massive LLM mining.
149+
if since is None:
150+
lookback_hours = cfg.get("lookback_hours", 72)
151+
if lookback_hours and lookback_hours > 0:
152+
import time
153+
cutoff = time.time() - lookback_hours * 3600
154+
since = _now_iso(cutoff)
147155
max_tasks = cfg.get("max_tasks_per_night", 40)
148156
max_sessions = cfg.get("max_sessions_per_night", 0) or max_tasks * 3
149157
candidate_limit = max_tasks

0 commit comments

Comments
 (0)