## 事象 [[プラグイン (GitHub Copilot CLI)|プラグイン]]のスクリプトで以下のような通知関数を書いた。 ```bash notify() { local title="$1" local body="$2" printf '\e]777;notify;%s;%s\a' "$title" "$body" } notify "title" "body" ``` これを実行しても[[OS]]に通知が来ない。 ### 環境 | 対象 | バージョン | | ---------------------- | ------- | | [[macOS]] | 15.7.3 | | [[Ghostty]] | 1.2.3 | | [[GitHub Copilot CLI]] | 0.104.0 | ## 原因 [[標準出力]]が端末まで伝わらず、[[GitHub Copilot]]側で受け取っているから。[[OSC 9 シーケンス]]や[[OSC 777 シーケンス]]を[[標準出力]]に出しても[[Ghostty]]や[[cmux]]に届かないので通知として扱われない。 また `preToolUse` は[[標準出力]]に[[JSON]]を返却する仕様となっているので、通知の[[OSC]]シーケンスを出力するは不適切。 ## 解決方法 `dev/tty` ([[TTY]]) に[[OSC 9 シーケンス]]や[[OSC 777 シーケンス]]を出力する。 ```bash notify() { local title="$1" local body="$2" printf '\e]777;notify;%s;%s\a' "$title" "$body" >/dev/tty } ``` これで[[Ghostty]]や[[cmux]]が直接通知を認識できる。 ## 参考 - https://docs.github.com/en/copilot/reference/hooks-configuration - https://docs.github.com/en/copilot/how-tos/copilot-cli/customize-copilot/use-hooks - https://raw.githubusercontent.com/github/copilot-cli/main/changelog.md