This repository is the public core of Keep Mac Awake: the root helper and watchdog that change and restore the macOS SleepDisabled setting, their session and supervision logic, the restoration journal, the XPC protocol, the installer scripts and the recovery reader. The menu bar app, the per-user coordinator and the keepmacawake command are not here. The plugin for AI agents is in plugins/keep-mac-awake (an Agent Skill and a read-only session-start hook, under the MIT License), with the marketplace manifests in .claude-plugin/ (Claude Code, Codex, Copilot CLI) and .cursor-plugin/ (Cursor), the plugin's own manifests in plugins/keep-mac-awake/ (.claude-plugin/, .codex-plugin/, .cursor-plugin/, .antigravity-plugin/) and the Gemini CLI extension manifest gemini-extension.json at the root, which loads the skill as the extension's context. The MCP server for the same command is in mcp/ (Node.js, MIT, the npm package keepmacawake-mcp, with server.json for the MCP Registry and glama.json at the root).
- Keeping a session alive that should continue comes first; restoring the sleep setting after any failure comes second; lightness third. Do not trade the first two for the third.
- Never change power settings from a build, a test or a script. Tests use fakes; hardware checks are run by a person, on purpose.
- The helper accepts only status, start, renew and stop, from a client whose code hash is in the root-owned trust file. Do not add commands, paths or arguments that the helper would run or open.
- Everything is English. Plain Markdown, relative links, no U+2014 or U+2013 dashes.
scripts/scan-public-content.shmust pass. - No network code. No logging of user activity.
- The agent plugin and the MCP server only call the public
keepmacawakecommand. The server has three tools (status, start, stop), no network code and no telemetry; test it withnpm ci && npm testinmcp/, which uses a fake command. Keepversionequal inmcp/package.jsonandmcp/server.json. - The agent plugin only calls the public
keepmacawakecommand. Its hook stays read only: no network, no start, stop or settings change, and it never reads the user's prompts or files. Check it withclaude plugin validate --strict plugins/keep-mac-awakeandclaude plugin validate --strict .. - The integrations in
integrations/(an Alfred workflow, Apple Shortcuts, a Hammerspoon Spoon, the Pi extension@keepmacawake/pi, the Python packagekeepmacawakeand a JetBrains IDE plugin, MIT) only call the publickeepmacawakecommand too, withstart,statusandstop. Their tests use a fake command and never run the real one:integrations/alfred/test.sh,integrations/shortcuts/test.sh,lua test.luainintegrations/hammerspoon,npm testinintegrations/pi,python -m pytestinintegrations/pythonand./gradlew testinintegrations/jetbrains. The Pi extension never starts a session without a time limit, ends a session only when the user runs/awake stop(the command has no session identity, so it cannot prove a session is its own), and leaves the first session on a Mac (which starts the free trial) to the user. The Python package never starts a session without a time limit, never searchesPATHfor the command, and ends a session only when the code callsstop(), uses%keepmacawake off, or setsstop_on_exit=Trueon asession()block that started it and whose session still has the same hours and end time. It never changes the battery settings; when Run on battery turned itself on (config.battery_chosenfalse) it warns that the session may run on battery, and its README tells an AI agent to ask the user first, the same rule as the MCP server. The JetBrains plugin ends only the session it started in the same IDE process, recognised by its hours and end time; any other session is left running. It never changes the battery settings, and while Run on battery turned itself on (config.battery_chosenfalse) it never starts a session without the user's yes: Start asks first, and its run hold starts nothing until that yes, the same rule as the MCP server. - Every commit here is an export from the maintainer's development tree. Do not commit, tag or push here by hand, and never force push: a change made here is lost at the next export.
- Pull requests from others are not accepted for now; see CONTRIBUTING.md.
Start with README.md, docs/ARCHITECTURE.md and docs/FAILURE-MODES.md.