Metadata-Version: 2.4
Name: apeawake
Version: 0.5.1
Summary: Keep your laptop awake while an AI agent finishes its task
License: MIT
Project-URL: Homepage, https://github.com/RobinDFeder/apeawake
Project-URL: Source, https://github.com/RobinDFeder/apeawake
Project-URL: Bug Tracker, https://github.com/RobinDFeder/apeawake/issues
Keywords: claude,ai,sleep,caffeinate,tui
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Utilities
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: textual>=0.60
Dynamic: license-file

# 🦍 ApeAwake

Intelligent wrapper for Claude Code. ApeAwake launches Claude, keeps your laptop awake for the full session, auto-approves permission prompts based on your preference, and presents a PR-style diff review when Claude finishes.

Works on **macOS** and **Linux**. Windows supports legacy watch mode only.

---

## Prerequisites

- **Python 3.9+**
- **[Claude Code](https://claude.ai/download)** installed and available on your PATH (`claude --version` should succeed)

---

## Install

```bash
pipx install apeawake
```

Or install directly from source:

```bash
pipx install git+https://github.com/RobinDFeder/apeawake
```

For local development:

```bash
git clone https://github.com/RobinDFeder/apeawake
cd apeawake
pip install -e .
```

---

## Usage

### Default — TUI session mode

```bash
apeawake
```

Launches a three-phase session:

1. **Config screen** — pick an approval mode (see below)
2. **Claude session** — Claude Code runs in a PTY relay; sleep lock is held; prompts are auto-approved per your chosen mode
3. **Diff review** — when Claude goes idle, a side-by-side diff lets you keep or revert changes file by file

### Skip the config screen

```bash
apeawake --mode all      # auto-approve every Claude prompt
apeawake --mode edits    # auto-approve file edits; pause on shell commands
apeawake --mode ask      # never auto-approve; you handle every prompt
```

### Legacy watch mode (headless)

Attach to an already-running process by PID and hold the sleep lock until it exits. No TUI, no diff review. Works on Windows.

```bash
apeawake --watch <PID>
```

---

## Approval modes

| Mode | Behavior |
|---|---|
| `all` | Auto-answers every Claude permission prompt with yes |
| `edits` | Auto-approves file edits; pauses on bash/shell commands |
| `ask` | Never auto-approves; every prompt requires your input |

---

## Options

| Flag | Description | Default |
|---|---|---|
| `--mode` / `-m` | Skip config TUI; use `all`, `edits`, or `ask` | — |
| `--idle SECONDS` | CPU-idle seconds before declaring Claude done | `60` |
| `--watch PID` / `-w` | (Legacy) watch an existing process by PID | — |
| `--interval SECONDS` / `-i` | Poll interval in seconds | `2.0` |

---

## Diff review keys

After Claude finishes, the diff screen shows each changed file:

| Key | Action |
|---|---|
| `K` | Keep current file |
| `R` | Revert current file |
| `A` | Keep all files |
| `D` | Discard all files |
| `Q` | Quit |

If you don't interact with the diff screen for 10 minutes, the sleep lock is released so your laptop can sleep normally. The screen stays open — interacting with it re-acquires the lock.

---

## How it works

### Sleep backends

| OS | Mechanism |
|---|---|
| macOS | `caffeinate -dims -s` + `pmset` power settings (requires sudo) |
| Linux | `systemd-inhibit --what=sleep:idle:handle-lid-switch` |
| Linux (fallback) | `xdg-screensaver reset` loop (screensaver only, no lid-close) |
| Windows | Legacy watch mode only — use `apeawake --watch <PID>` |

### macOS power management

On macOS, ApeAwake uses `sudo pmset` to disable standby, hibernate, and battery sleep for the duration of the session — so closing the lid on battery won't interrupt Claude mid-task. Your original settings are restored automatically when the session ends. You'll be prompted for your password once at startup; ApeAwake keeps the sudo token alive in the background for the full session.

---

## Contributing

Bug reports and pull requests are welcome. Please open an issue first for any significant change.

---

## License

MIT — see [LICENSE](LICENSE).
