npm package: @hjanuschka/pi-nanny
Description: Parental control extension for Pi - helps you go to bed instead of having 47 creative ideas at 3 AM
Author: Harald Januschka
Latest version: 1.1.0

# 🛏️ Pi-Nanny Extension

> "My ADHD ass having 47 creative new ideas at 3 am instead of sleeping"

**Pi-Nanny** is a parental control extension for [Pi](https://github.com/badlogic/pi) that helps you maintain a healthy sleep schedule by nagging you to go to bed when you're coding at ungodly hours.

Born from [this Twitter thread](https://x.com/badlogicgames/status/2021521786341556509) where [@badlogicgames](https://twitter.com/badlogicgames) said "do it" after [@hjanuschka](https://twitter.com/hjanuschka) suggested we need "some 'its over go to bed' extension!"

## Features

✨ **Progressive Enforcement**
- 🌙 Gentle warnings (midnight - 1 AM)
- 🚨 Strict mode after 5 ignored warnings
- 🔴 **Hard exit at 1:00 AM** - automatic shutdown with funny messages

😴 **Snooze System**
- Temporary override with `/nanny snooze <minutes>`
- Quick snooze with `Ctrl+Shift+S`
- Can't snooze past hard exit time

📊 **Status Tracking**
- Persistent footer showing bedtime status
- Warning counter for repeat offenders
- Countdown to hard exit

🎲 **Random Exit Messages**
- "Good night sucker! 😴"
- "Git commit yourself to bed. NOW. 🛏️"
- "404: Wakefulness not found. Redirecting to sleep. 🌙"
- ...and 17 more!

## Installation

### Quick Install (Recommended)

```bash
# Install from npm (easiest)
pi install npm:@hjanuschka/pi-nanny

# Or install from git
pi install git:github.com/hjanuschka/pi-nanny@v1.0.0

# Try without installing
pi -e npm:@hjanuschka/pi-nanny
```

### Manual Installation

#### Global (All Projects)

```bash
# Copy to extensions directory
mkdir -p ~/.pi/agent/extensions
cp pi-nanny.ts ~/.pi/agent/extensions/

# Or symlink for development
ln -s $(pwd)/pi-nanny.ts ~/.pi/agent/extensions/
```

The extension will auto-load in all Pi sessions. Use `/reload` to reload after edits.

#### Project-Local

```bash
# Copy to project extensions
mkdir -p .pi/extensions
cp pi-nanny.ts .pi/extensions/
```

## Usage

### Commands

#### `/nanny test [bedtime|hardexit|normal]` - Test Mode
Simulate different times for testing without waiting until midnight:
- `bedtime` - Simulate midnight (gentle warnings)
- `hardexit` - Simulate 1 AM (forced shutdown)
- `normal` - Switch back to real time

```bash
/nanny test bedtime   # See bedtime warnings
/nanny test hardexit  # Trigger shutdown (careful!)
/nanny test normal    # Back to real time
```

Can also use CLI flag:
```bash
pi -e ./pi-nanny.ts --nanny-test-time=0   # Midnight
pi -e ./pi-nanny.ts --nanny-test-time=1   # 1 AM
```

#### `/nanny` - Check Status
Shows current configuration and bedtime status:
- Enabled/disabled state
- Bedtime hours
- Hard exit time
- Current violations
- Snooze status

#### `/nanny snooze [minutes]` - Snooze Warnings
Temporarily disable bedtime enforcement (default: 15 minutes).
- Cannot snooze past hard exit hour
- Resets some of your warning counter
- Use wisely!

```bash
/nanny snooze 30  # Snooze for 30 minutes
/nanny snooze     # Snooze for 15 minutes (default)
```

#### `/nanny config` - Configure Hours
Update bedtime schedule:
- Bedtime start (default: 0 = midnight)
- Bedtime end (default: 6 = 6 AM)
- Hard exit hour (default: 1 = 1 AM)

#### `/nanny disable` - Turn Off
Disable Pi-Nanny for the current session.

#### `/nanny enable` - Turn On
Re-enable Pi-Nanny after disabling.

#### `/nanny reset` - Reset Warnings
Reset the warning counter and strict mode.

### Keyboard Shortcuts

- **`Ctrl+Shift+S`** - Quick 15-minute snooze (only during bedtime, before hard exit)

### Status Line

Pi-Nanny adds a status indicator to the footer:
- `🌙 Bedtime! (ends in 5 hours)` - Warning mode
- `🚨 Bedtime! Hard exit in 45m` - Approaching hard exit
- `😴 Snooze: 12m remaining` - Currently snoozed
- `🚨 HARD EXIT - Shutting down soon!` - Past 1 AM

## Configuration

Default configuration:
```typescript
{
  bedtimeStart: 0,    // Midnight
  bedtimeEnd: 6,      // 6 AM
  hardExitHour: 1,    // 1 AM - force quit
  strictMode: false,  // Starts gentle
  enabled: true
}
```

### How It Works

1. **Midnight - 1 AM (Warning Mode)**
   - Gentle reminders on each prompt
   - Escalates to "firm" after 3 warnings
   - Activates strict mode after 5 warnings

2. **Strict Mode**
   - Blocks each prompt with confirmation dialog
   - Auto-timeout after 10 seconds
   - Adds guilt to every bypass

3. **1 AM - Hard Exit**
   - 30-second countdown dialog
   - No snooze allowed
   - Automatic `ctx.shutdown()`
   - Random funny exit message

### Exit Messages

Sample messages shown during hard exit:
- "Good night sucker! 😴"
- "That's it. I'm pulling the plug. Sweet dreams! 🔌"
- "Your 3 AM ideas can wait. Trust me. 🌙"
- "Git commit yourself to bed. NOW. 🛏️"
- "Stackoverflow will still be there in the morning. Bye! 👋"
- "404: Wakefulness not found. Redirecting to sleep. 🌙"
- "Ctrl+Alt+Delete your bad sleep habits. Good night! ⌨️"

## Examples

### Starting Pi at 2 AM
```bash
$ pi
🚨 MANDATORY BEDTIME
It's past 1:00 AM. Pi is shutting down in 30 seconds.

Ctrl+Alt+Delete your bad sleep habits. Good night! ⌨️

No snooze available. Get some sleep!
[Yes] [No (default)]
```

### Warning During Bedtime
```
😴 Even GPUs need to sleep sometimes.
```

### Snoozing Past Hard Exit
```bash
/nanny snooze 60
⚠️ Can't snooze past 1:00 AM (hard exit). Max snooze: 45 minutes
```

## Development

Built with Pi's extension API. Key features used:
- **Event interception** - `input`, `agent_start`, `session_start`
- **UI components** - `ctx.ui.confirm()`, `ctx.ui.notify()`, `ctx.ui.setStatus()`
- **Custom commands** - `/nanny` with subcommands
- **Keyboard shortcuts** - `Ctrl+Shift+S`
- **Graceful shutdown** - `ctx.shutdown()`

## Credits

- **Idea**: [@kshvbgde](https://twitter.com/kshvbgde)'s late-night ADHD tweet
- **Suggestion**: [@hjanuschka](https://twitter.com/hjanuschka) (that's me!)
- **Blessing**: [@badlogicgames](https://twitter.com/badlogicgames) said "do it"
- **Framework**: [Pi](https://github.com/badlogic/pi) by [@badlogicgames](https://twitter.com/badlogicgames)

## License

MIT - Use at your own risk of actually getting good sleep.

## Contributing

Got better exit messages? More creative nag lines? PRs welcome!

---

*Remember: The bugs will still be there tomorrow. Your sleep schedule won't.*