diff --git a/gh-monitor/buildspec.md b/gh-monitor/buildspec.md index 57bf4c8..5a6d309 100644 --- a/gh-monitor/buildspec.md +++ b/gh-monitor/buildspec.md @@ -140,24 +140,49 @@ Function: Entry point: `if __name__ == "__main__": main()` -### STEP 10 — OpenClaw cron job +### STEP 10 — macOS LaunchAgent -Register via OpenClaw cron API: -```json -{ - "name": "gh-monitor", - "schedule": { "kind": "every", "everyMs": 300000 }, - "payload": { - "kind": "systemEvent", - "text": "Run GitHub PR monitor: cd ~/Projects/hans-tools/gh-monitor && python3 poll.py" - }, - "sessionTarget": "main" -} +Create `~/Library/LaunchAgents/com.hans.gh-monitor.plist`: + +```xml + + + + + Label + com.hans.gh-monitor + ProgramArguments + + /usr/bin/python3 + /Users/hansheinemann/Projects/hans-tools/gh-monitor/poll.py + + StartInterval + 300 + StandardOutPath + /Users/hansheinemann/Projects/hans-tools/gh-monitor/state/stdout.log + StandardErrorPath + /Users/hansheinemann/Projects/hans-tools/gh-monitor/state/stderr.log + RunAtLoad + + + ``` -Note: this is a systemEvent (not agentTurn) so it injects into the main session -and Hans handles it inline. If this proves noisy, switch to agentTurn in isolated -session. +Load with: +```bash +launchctl load ~/Library/LaunchAgents/com.hans.gh-monitor.plist +``` + +Pause/resume: +```bash +launchctl unload ~/Library/LaunchAgents/com.hans.gh-monitor.plist +launchctl load ~/Library/LaunchAgents/com.hans.gh-monitor.plist +``` + +**Token cost:** Zero during polling. The main session is only woken when +`poll.py` calls `openclaw system event` — i.e. only when real PR activity +is detected. --- diff --git a/gh-monitor/design.md b/gh-monitor/design.md index 0807273..fbf87d2 100644 --- a/gh-monitor/design.md +++ b/gh-monitor/design.md @@ -115,16 +115,16 @@ intervals across a handful of repos, this is nowhere near the limit. --- -## Cron Schedule +## Schedule -Every 5 minutes via OpenClaw cron: -``` -{ "kind": "every", "everyMs": 300000 } -``` +Every 5 minutes via macOS `launchd` (LaunchAgent plist). `poll.py` runs as a +plain shell process — no agent session, no tokens consumed during polling. -Payload: systemEvent → injects wake text into main session. +The main session is only woken when `poll.py` finds new activity and calls +`openclaw system event`. On a quiet repo this costs zero tokens most of the day. -Can be paused/resumed via OpenClaw cron management without touching the code. +The LaunchAgent can be unloaded/loaded via `launchctl` to pause/resume polling +without touching the code. ---