Add to your opencode.json or opencode.jsonc
{
"plugin": ["opencode-caffeinate"]
}
Prevent macOS from sleeping while OpenCode sessions are active.
This plugin automatically runs caffeinate -dim when an OpenCode session starts, keeping your Mac awake during long AI coding sessions. When all sessions end, caffeinate is stopped to restore normal power management.
Flags used:
-d: Prevent display sleep-i: Prevent idle sleep-m: Prevent disk sleepAdd to your opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-caffeinate"]
}
Clone this repo to your plugins directory:
# Global plugins
git clone https://github.com/nguyenphutrong/opencode-caffeinate.git ~/.config/opencode/plugins/opencode-caffeinate
# Or project-level
git clone https://github.com/nguyenphutrong/opencode-caffeinate.git .opencode/plugins/opencode-caffeinate
caffeinate command is macOS-specificsession.created event), the plugin registers the session in /tmp/opencode-caffeinate/sessions/caffeinate process is spawned if not already running (tracked via PID file at /tmp/opencode-caffeinate/caffeinate.pid)session.idle or session.deleted events), the session is unregisteredCross-process synchronization: The plugin uses file-based session tracking to correctly handle multiple OpenCode instances running in parallel. Each session creates a PID file, and stale sessions (crashed processes) are automatically detected and ignored.
# Install dependencies
bun install
# Run tests
bun run test
# Type check
bun run --bun tsc --noEmit
MIT
Sign in to leave a comment.