Summary
Add scheduling capabilities to nightshift so runs can be triggered easily without manual tmux setup.
Three Tiers
Tier 1: Quick Launch (enhance existing zsh alias)
Add --at and --in flags to the nightshift start alias:
nightshift start # Start immediately (existing)
nightshift start --at 2:00 # Start at 2:00 AM tonight
nightshift start --in 1h # Start in 1 hour
nightshift start --at 2:00 --dry-run # Preview what would run at 2 AM
Implementation: Shell arithmetic → sleep N in a named tmux session. Same as what we do manually today, just wrapped in the alias.
Pros: Zero dependencies, works now
Cons: Dies if laptop sleeps or terminal closes
Tier 2: Manual Schedule (survives terminal close)
nightshift schedule 2:00 # One-shot: run at 2 AM tonight
nightshift schedule --cancel # Cancel scheduled run
nightshift schedule --status # Show next scheduled run
Implementation: Write a launchd one-shot plist to ~/Library/LaunchAgents/com.autodev.nightshift-oneshot.plist with StartCalendarInterval. Load with launchctl.
Pros: Survives terminal close, proper macOS integration
Cons: Slightly more complex, plist XML
Tier 3: Recurring Schedule
nightshift cron 2:00 # Run every night at 2 AM
nightshift cron --weekdays 2:00 # Mon-Fri only
nightshift cron --disable # Pause recurring runs
nightshift cron --enable # Resume
nightshift cron --status # Show schedule + last run
Implementation: Persistent launchd plist at ~/Library/LaunchAgents/com.autodev.nightshift.plist. Runs a wrapper script that:
- Checks if nightshift is already running (lock file)
- Checks if there are
nightshift-labeled issues to process
- If yes, runs
npx tsx nightshift/src/index.ts run
- Logs to
~/.auto-dev/runs/
Pros: Fully autonomous, survives reboots
Cons: Need to handle edge cases (laptop sleep, network down, no issues)
Design Decisions
- launchd over cron: macOS-native, handles sleep/wake properly, can set env vars
- All three tiers coexist: Quick launch for "run this now", schedule for "run tonight", cron for "run every night"
- Single tmux session name: All tiers use
nightshift session — prevents parallel runs
- Lock file:
~/.auto-dev/nightshift.lock prevents overlapping runs across tiers
Files
| File |
Purpose |
nightshift/nightshift.zsh |
Add --at, --in to start; add schedule and cron subcommands |
nightshift/scripts/nightshift-launcher.sh |
Wrapper for launchd (env setup, lock check, logging) |
nightshift/templates/com.autodev.nightshift.plist |
Template for launchd recurring plist |
Verification
nightshift start --at 2:00 → tmux session created with correct sleep
nightshift schedule 2:00 → plist loaded, launchctl list | grep autodev
nightshift cron 2:00 → plist loaded, persists after reboot
- Parallel run prevention: start nightshift, try starting again → blocked by lock
Summary
Add scheduling capabilities to nightshift so runs can be triggered easily without manual tmux setup.
Three Tiers
Tier 1: Quick Launch (enhance existing zsh alias)
Add
--atand--inflags to thenightshift startalias:Implementation: Shell arithmetic →
sleep Nin a named tmux session. Same as what we do manually today, just wrapped in the alias.Pros: Zero dependencies, works now
Cons: Dies if laptop sleeps or terminal closes
Tier 2: Manual Schedule (survives terminal close)
Implementation: Write a
launchdone-shot plist to~/Library/LaunchAgents/com.autodev.nightshift-oneshot.plistwithStartCalendarInterval. Load withlaunchctl.Pros: Survives terminal close, proper macOS integration
Cons: Slightly more complex, plist XML
Tier 3: Recurring Schedule
Implementation: Persistent
launchdplist at~/Library/LaunchAgents/com.autodev.nightshift.plist. Runs a wrapper script that:nightshift-labeled issues to processnpx tsx nightshift/src/index.ts run~/.auto-dev/runs/Pros: Fully autonomous, survives reboots
Cons: Need to handle edge cases (laptop sleep, network down, no issues)
Design Decisions
nightshiftsession — prevents parallel runs~/.auto-dev/nightshift.lockprevents overlapping runs across tiersFiles
nightshift/nightshift.zsh--at,--into start; addscheduleandcronsubcommandsnightshift/scripts/nightshift-launcher.shnightshift/templates/com.autodev.nightshift.plistVerification
nightshift start --at 2:00→ tmux session created with correct sleepnightshift schedule 2:00→ plist loaded,launchctl list | grep autodevnightshift cron 2:00→ plist loaded, persists after reboot