# pi-smart-notify

Context-aware completion notifications for [Pi](https://pi.dev) coding agent sessions.

Instead of repeating the latest user message, the extension generates a short English summary of the work that was completed:

```text
Pi · feat/improve-checkout
Simplify the Base deposit flow — completed
```

## Features

- Generates a dynamic work summary of at most eight words.
- Uses the Pi session name, Git branch, or short session ID to identify the instance.
- Keeps the previous meaningful summary for test, greeting, acknowledgement, and thank-you turns.
- Sends OSC 777 terminal notifications, including Ghostty attention notifications.
- Sends native macOS Notification Center alerts through `osascript`.
- Does not request a bell or notification sound.
- Avoids displaying summaries that appear to contain credentials or secrets.
- Adds `/notify-test` for manual verification.

## Install

From npm:

```bash
pi install npm:pi-smart-notify
```

From GitHub:

```bash
pi install git:github.com/rafa-canseco/pi-smart-notify
```

Try it without installing:

```bash
pi -e git:github.com/rafa-canseco/pi-smart-notify
```

Reload an already-running Pi session after installation:

```text
/reload
```

## Usage

For the clearest instance identifier, give the session a descriptive name:

```text
/name B1N-437 DepositModal
```

Notifications are sent automatically whenever the agent settles. Test delivery with:

```text
/notify-test
```

No task name needs to be entered manually.

## How summaries work

At the end of a turn, the extension asks the currently selected and authenticated Pi model for a one-line English summary. This creates one small additional model request per completed turn. If summarization fails, the notification falls back to the session identifier.

Only the current request, the final assistant result, and the previous short summary are included in the summarization request. The summary is filtered before being shown on the lock screen, but users should still avoid placing secrets in prompts.

## Platform support

| Platform | Notification channel |
|---|---|
| Ghostty and OSC 777 terminals | Terminal notification |
| macOS | Native Notification Center alert |
| Other systems | Terminal notification when OSC 777 is supported |

Native Windows and Linux desktop notification backends are not currently included.

## Development

```bash
npm install
npm run check
npm run pack:check
```

Install the local checkout in Pi:

```bash
pi install /absolute/path/to/pi-smart-notify
```

## Security

Pi extensions execute with full system access. Review extension source code before installation.

## License

MIT
