Files
my-pi/pi-notify
云服务部-叶林立 879fc5d37f docs(upstream): 将 UPSTREAM.md 来源记录统一改为中文维护
把 12 份 UPSTREAM.md 来源记录全部翻译为中文,并把中文定为这份仓库自有
维护文档的强制语言。

- 翻译 hippo-memory-pi、pi-ask-user、pi-chrome、pi-compaction、
  pi-extension-codex-fast-mode、pi-minimal-footer、pi-notify、
  pi-permission-system/docs/auto-review、pi-ssh、pi-subagents 与
  pi-tool-search 的来源记录。
- 在 AGENTS.md 增加纪律:每个自维护扩展目录必须保留中文 UPSTREAM.md,
  内容涵盖官方仓库、tag/commit、导入版本、导入日期、许可证归属、本地
  改动清单与同步上游时的约束。
- 明确边界:UPSTREAM.md 属于仓库自有的维护文档,因此使用中文;上游自带
  的源码、测试、文档、README、CHANGELOG 与 LICENSE 一律保持原文,不翻
  译、不改写,避免同步上游时产生无意义 diff 并破坏许可证原文完整性。
- 所有 40 位 commit、tag/版本号、仓库 URL 与许可证路径原样保留,仅翻译
  叙述性文字。

验证:12 份文件均无残留英文正文;逐份复核了 commit、版本、URL 与
LICENSES/ 路径未发生改变。
2026-10-13 23:19:01 -07:00
..

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:

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. Use environment variables for persistent defaults.

Configuration

  • PI_NOTIFY_ENABLED: 1/true or 0/false; default enabled.
  • PI_NOTIFY_TITLE: title template shared by completion and permission notifications; default π - {project}.
  • PI_NOTIFY_BODY: completion-notification body template; default {message}. Permission prompts use a bounded Permission required · <agent> · <surface> summary.
  • PI_NOTIFY_MESSAGE_SOURCE: assistant, user, or privacy mode none; default assistant. Privacy mode also hides permission values and requester details.
  • PI_NOTIFY_MESSAGE_MAX: maximum completion-message or permission-value characters before ellipsis; default 80, maximum 500.
  • PI_NOTIFY_MIN_SECONDS: minimum complete run duration; default 3, range 0–3600. This does not delay permission prompts.
  • PI_NOTIFY_VISIBILITY: Kitty policy unfocused, invisible, or always; default always.
  • PI_NOTIFY_ACTION: Kitty click action focus or none; default focus.
  • PI_NOTIFY_SOUND_CMD: 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:

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:

export PI_NOTIFY_TITLE='π {status_icon} · {project}'
export PI_NOTIFY_MESSAGE_SOURCE=none
export PI_NOTIFY_VISIBILITY=unfocused

Kitty must be allowed under System Settings → Notifications. Self-built or unsigned Kitty binaries may not be able to publish macOS notifications.