Files
my-pi/pi-notify/README.md
T
云服务部-叶林立andDevin <158243242+devin-ai-integration[bot]@users.noreply.github.com> e996f59469 refactor: notify/footer 持久配置收编到 config/,chrome bridge 地址固定
仓库规则要求 config/ 为唯一配置来源、不以环境变量作持久默认值:
- pi-notify 改读 config/pi-notify.json(逐字段校验回退,复用原 parsers 钳制)
- pi-minimal-footer 改读 config/pi-minimal-footer.json
- pi-chrome 移除 PI_CHROME_BRIDGE_HOST/PORT,固定 127.0.0.1:17318
  (浏览器端 service_worker.js 硬编码同一地址,单侧可配只会断连)

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-21 19:16:47 -07:00

86 lines
4.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# pi-notify
Kitty-first completion and permission-input notifications for Pi. This repository maintains a source import of
`@smoose/pi-notify@0.1.1` with local reliability, permission-bus integration, and multi-window improvements.
## Behavior
- Waits for Pi's `agent_settled` event for completion notifications, so retries, automatic compaction, and queued follow-ups do not notify early.
- Listens for `permissions:ui_prompt` and notifies immediately only when `pi-permission-system` is about to ask the human; policy and AutoReview decisions that need no user response stay silent.
- Uses Kitty OSC 99 with Base64 payloads, an ID unique to each Pi session, and explicit `a=focus`.
- Defaults to `o=always`: notifications remain visible while the originating Kitty window/pane has keyboard focus; clicking a notification returns to that exact source window.
- Measures the entire run across automatic retries and ignores completion runs shorter than three seconds by default; permission prompts bypass this duration threshold.
- Emits terminal sequences only in interactive TUI mode, never into JSON, print, or RPC output.
- Uses macOS AppleScript outside Kitty and a sanitized OSC 777 fallback outside macOS.
The root `my-pi` bundle loads this local source directly. For the unmodified upstream package, use:
```bash
pi install npm:@smoose/pi-notify
```
Do not separately install upstream when using the bundle, or notifications will be duplicated.
## Commands
- `/notify on`: enable notifications for the current session.
- `/notify off`: disable notifications for the current session.
- `/notify test`: send a notification immediately; click it to verify exact Kitty-window focus.
- `/notify status`: show the active backend, visibility policy, and duration threshold.
Command overrides are session-local. Persistent defaults come from the bundle's `config/pi-notify.json`.
## Configuration
Persistent defaults are read once per session from `config/pi-notify.json` inside the installed bundle; a missing or invalid file falls back to the defaults shown:
- `enabled`: `true`/`false`; default `true`.
- `title`: title template shared by completion and permission notifications; default `π - {project}`.
- `body`: completion-notification body template; default `{message}`. Permission prompts use a bounded `Permission required · <agent> · <surface>` summary.
- `messageSource`: `assistant`, `user`, or privacy mode `none`; default `assistant`. Privacy mode also hides permission values and requester details.
- `messageMax`: maximum completion-message or permission-value characters before ellipsis; default `80`, maximum `500`.
- `minSeconds`: minimum complete run duration; default `3`, range `0`–`3600`. This does not delay permission prompts.
- `visibility`: Kitty policy `unfocused`, `invisible`, or `always`; default `always`.
- `action`: Kitty click action `focus` or `none`; default `focus`.
- `soundCommand`: optional shell command run after the notification. This is trusted local configuration and executes through a shell.
Visibility policies:
- `unfocused`: notify whenever the originating Kitty window/pane does not have keyboard focus.
- `invisible`: notify only when the originating window/pane is not visible.
- `always`: notify even while typing in the originating window.
Inside tmux, enable passthrough and restart the tmux server after changing the setting:
```tmux
set -g allow-passthrough all
```
The active tmux client type is checked so a stale `KITTY_WINDOW_ID` cannot force the Kitty backend for a non-Kitty client.
## Template variables
- `{project}`: current directory name.
- `{cwd}`: current working directory.
- `{model}`: active model as `provider/id`.
- `{model_short}`: active model ID.
- `{message}`: selected message, or `Ready for input` when source is `none` or text is unavailable.
- `{user_message}`: latest user text, truncated.
- `{assistant_message}`: latest settled assistant text, truncated.
- `{duration}` / `{duration_ms}`: complete duration including retries.
- `{status}`: `ready`, or `ready · N tool errors` when tools reported errors.
- `{status_icon}`: `✓` or `⚠`. This reports observed tool errors, not a definitive task-success verdict.
- `{tool_error_count}`: observed tool error count.
Example for multiple projects without exposing assistant text on the lock screen (`config/pi-notify.json`):
```json
{
"title": "π {status_icon} · {project}",
"messageSource": "none",
"visibility": "unfocused"
}
```
Kitty must be allowed under **System Settings → Notifications**. Self-built or unsigned Kitty binaries may not be able to publish macOS notifications.