@clang.engineer/pi-notify 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -2
- package/package.json +1 -1
- package/src/index.ts +9 -6
package/README.md
CHANGED
|
@@ -7,7 +7,8 @@ Notification extension for Pi coding agent.
|
|
|
7
7
|
- Notifies on `agent_settled`.
|
|
8
8
|
- Notifies on `permissions:ask`.
|
|
9
9
|
- Backend: `auto`, `macos`, `terminal`, or `off`.
|
|
10
|
-
- Optional last-input summary in completion
|
|
10
|
+
- Optional last-input summary in completion notification titles.
|
|
11
|
+
- Optional macOS notification sound.
|
|
11
12
|
- Optional script hook.
|
|
12
13
|
|
|
13
14
|
## Config
|
|
@@ -25,7 +26,10 @@ Project: `<project>/.pi/notify.json`
|
|
|
25
26
|
"permissionAsk": true,
|
|
26
27
|
"permissionMessage": "Permission required: {tool}",
|
|
27
28
|
"backend": "auto",
|
|
28
|
-
"skipWhenFrontmost": false
|
|
29
|
+
"skipWhenFrontmost": false,
|
|
30
|
+
"sound": "Glass"
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
33
|
```
|
|
34
|
+
|
|
35
|
+
Set `sound` to a macOS sound name such as `Glass`, `Ping`, or `Submarine`. Set it to `false` to disable sound.
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -16,6 +16,7 @@ type NotifyConfig = {
|
|
|
16
16
|
maxInputLength: number;
|
|
17
17
|
skipWhenFrontmost: boolean;
|
|
18
18
|
frontmostProcess: string;
|
|
19
|
+
sound: string | false;
|
|
19
20
|
script?: string;
|
|
20
21
|
};
|
|
21
22
|
|
|
@@ -40,6 +41,7 @@ const DEFAULT_CONFIG: NotifyConfig = {
|
|
|
40
41
|
maxInputLength: 80,
|
|
41
42
|
skipWhenFrontmost: false,
|
|
42
43
|
frontmostProcess: "ghostty",
|
|
44
|
+
sound: "Glass",
|
|
43
45
|
};
|
|
44
46
|
|
|
45
47
|
function execFileAsync(file: string, args: string[], input?: string, timeout = 5000): Promise<string> {
|
|
@@ -89,17 +91,18 @@ function notifyTerminal(title: string, message: string): void {
|
|
|
89
91
|
process.stdout.write(`\x1b]777;notify;${title};${message}\x07`);
|
|
90
92
|
}
|
|
91
93
|
|
|
92
|
-
async function notifyMacos(title: string, message: string): Promise<void> {
|
|
94
|
+
async function notifyMacos(title: string, message: string, sound: string | false): Promise<void> {
|
|
95
|
+
const soundClause = sound ? ` sound name "${escapeAppleScript(sound)}"` : "";
|
|
93
96
|
await execFileAsync("/usr/bin/osascript", [
|
|
94
97
|
"-e",
|
|
95
|
-
`display notification "${escapeAppleScript(message)}" with title "${escapeAppleScript(title)}"`,
|
|
98
|
+
`display notification "${escapeAppleScript(message)}" with title "${escapeAppleScript(title)}"${soundClause}`,
|
|
96
99
|
]);
|
|
97
100
|
}
|
|
98
101
|
|
|
99
102
|
async function sendNotification(config: NotifyConfig, payload: NotifyPayload): Promise<void> {
|
|
100
103
|
if (config.backend === "off") return;
|
|
101
104
|
if (config.backend === "macos" || (config.backend === "auto" && process.platform === "darwin")) {
|
|
102
|
-
await notifyMacos(payload.title, payload.message);
|
|
105
|
+
await notifyMacos(payload.title, payload.message, config.sound);
|
|
103
106
|
return;
|
|
104
107
|
}
|
|
105
108
|
notifyTerminal(payload.title, payload.message);
|
|
@@ -150,11 +153,11 @@ export default function (pi: any) {
|
|
|
150
153
|
|
|
151
154
|
async function handle(event: NotifyEvent, message: string) {
|
|
152
155
|
config = loadConfig(cwd);
|
|
153
|
-
const
|
|
156
|
+
const inputTitle = event === "agent_settled" && config.includeInput && lastInput ? ` 완료: ${lastInput}` : "";
|
|
154
157
|
const payload: NotifyPayload = {
|
|
155
158
|
event,
|
|
156
|
-
title: config.title
|
|
157
|
-
message
|
|
159
|
+
title: `${config.title}${inputTitle}`,
|
|
160
|
+
message,
|
|
158
161
|
timestamp: Date.now(),
|
|
159
162
|
cwd,
|
|
160
163
|
pid: process.pid,
|