@diegopetrucci/pi-extensions 0.1.7 → 0.1.8
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 +20 -2
- package/extensions/notify/README.md +43 -0
- package/extensions/notify/index.ts +55 -0
- package/extensions/notify/package.json +27 -0
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -10,6 +10,7 @@ A collection of [pi](https://github.com/badlogic/pi-mono) agent extensions I mad
|
|
|
10
10
|
| [`oracle`](./extensions/oracle) | Adds an Amp-style read-only oracle tool that auto-selects the strongest reasoning model on the current provider/subscription, covers pi’s built-in providers with hardcoded rankings, sets reasoning to xhigh by default, and shows live status while running. |
|
|
11
11
|
| [`permission-gate`](./extensions/permission-gate) | Prompts for confirmation before dangerous bash commands like `rm -rf`, `sudo`, and `chmod 777`. |
|
|
12
12
|
| [`confirm-destructive`](./extensions/confirm-destructive) | Confirms before destructive session actions like clear, switch, and fork. |
|
|
13
|
+
| [`notify`](./extensions/notify) | Sends a terminal or desktop notification when pi finishes and is ready for input. |
|
|
13
14
|
|
|
14
15
|
## Install
|
|
15
16
|
|
|
@@ -24,7 +25,7 @@ pi install git:github.com/diegopetrucci/pi-extensions
|
|
|
24
25
|
Or pin to a tagged version:
|
|
25
26
|
|
|
26
27
|
```bash
|
|
27
|
-
pi install git:github.com/diegopetrucci/pi-extensions@v0.1.
|
|
28
|
+
pi install git:github.com/diegopetrucci/pi-extensions@v0.1.8
|
|
28
29
|
```
|
|
29
30
|
|
|
30
31
|
### npm
|
|
@@ -63,6 +64,10 @@ pi install npm:@diegopetrucci/pi-permission-gate
|
|
|
63
64
|
pi install npm:@diegopetrucci/pi-confirm-destructive
|
|
64
65
|
```
|
|
65
66
|
|
|
67
|
+
```bash
|
|
68
|
+
pi install npm:@diegopetrucci/pi-notify
|
|
69
|
+
```
|
|
70
|
+
|
|
66
71
|
### Option 2: filter the repo package
|
|
67
72
|
|
|
68
73
|
If you prefer the collection package, you can filter it in your pi settings.
|
|
@@ -119,9 +124,22 @@ Confirm destructive only:
|
|
|
119
124
|
}
|
|
120
125
|
```
|
|
121
126
|
|
|
127
|
+
Notify only:
|
|
128
|
+
|
|
129
|
+
```json
|
|
130
|
+
{
|
|
131
|
+
"packages": [
|
|
132
|
+
{
|
|
133
|
+
"source": "npm:@diegopetrucci/pi-extensions",
|
|
134
|
+
"extensions": ["extensions/notify/index.ts"]
|
|
135
|
+
}
|
|
136
|
+
]
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
122
140
|
## npm publishing
|
|
123
141
|
|
|
124
142
|
The repo is set up to support both:
|
|
125
143
|
|
|
126
144
|
- the collection package: `@diegopetrucci/pi-extensions`
|
|
127
|
-
- standalone extension packages like `@diegopetrucci/pi-minimal-footer`, `@diegopetrucci/pi-oracle`, `@diegopetrucci/pi-permission-gate`,
|
|
145
|
+
- standalone extension packages like `@diegopetrucci/pi-minimal-footer`, `@diegopetrucci/pi-oracle`, `@diegopetrucci/pi-permission-gate`, `@diegopetrucci/pi-confirm-destructive`, and `@diegopetrucci/pi-notify`
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# notify
|
|
2
|
+
|
|
3
|
+
A small pi extension that sends a terminal or desktop notification when the agent finishes and is waiting for input.
|
|
4
|
+
|
|
5
|
+
This is adapted from the original `notify.ts` example in [`badlogic/pi-mono`](https://github.com/badlogic/pi-mono/blob/main/packages/coding-agent/examples/extensions/notify.ts) and kept basically the same.
|
|
6
|
+
|
|
7
|
+
## Supported notification backends
|
|
8
|
+
|
|
9
|
+
- OSC 777: Ghostty, iTerm2, WezTerm, rxvt-unicode
|
|
10
|
+
- OSC 99: Kitty
|
|
11
|
+
- Windows toast: Windows Terminal / WSL
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
### Standalone npm package
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pi install npm:@diegopetrucci/pi-notify
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Collection package
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pi install npm:@diegopetrucci/pi-extensions
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### GitHub package
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pi install git:github.com/diegopetrucci/pi-extensions
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Then reload pi:
|
|
34
|
+
|
|
35
|
+
```text
|
|
36
|
+
/reload
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Notes
|
|
40
|
+
|
|
41
|
+
- Hooks the `agent_end` event.
|
|
42
|
+
- Sends `Pi` / `Ready for input` when the agent finishes.
|
|
43
|
+
- Chooses the notification backend from the current terminal environment.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pi Notify Extension
|
|
3
|
+
*
|
|
4
|
+
* Sends a native terminal notification when Pi agent is done and waiting for input.
|
|
5
|
+
* Supports multiple terminal protocols:
|
|
6
|
+
* - OSC 777: Ghostty, iTerm2, WezTerm, rxvt-unicode
|
|
7
|
+
* - OSC 99: Kitty
|
|
8
|
+
* - Windows toast: Windows Terminal (WSL)
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
12
|
+
|
|
13
|
+
function windowsToastScript(title: string, body: string): string {
|
|
14
|
+
const type = "Windows.UI.Notifications";
|
|
15
|
+
const mgr = `[${type}.ToastNotificationManager, ${type}, ContentType = WindowsRuntime]`;
|
|
16
|
+
const template = `[${type}.ToastTemplateType]::ToastText01`;
|
|
17
|
+
const toast = `[${type}.ToastNotification]::new($xml)`;
|
|
18
|
+
return [
|
|
19
|
+
`${mgr} > $null`,
|
|
20
|
+
`$xml = [${type}.ToastNotificationManager]::GetTemplateContent(${template})`,
|
|
21
|
+
`$xml.GetElementsByTagName('text')[0].AppendChild($xml.CreateTextNode('${body}')) > $null`,
|
|
22
|
+
`[${type}.ToastNotificationManager]::CreateToastNotifier('${title}').Show(${toast})`,
|
|
23
|
+
].join("; ");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function notifyOSC777(title: string, body: string): void {
|
|
27
|
+
process.stdout.write(`\x1b]777;notify;${title};${body}\x07`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function notifyOSC99(title: string, body: string): void {
|
|
31
|
+
// Kitty OSC 99: i=notification id, d=0 means not done yet, p=body for second part
|
|
32
|
+
process.stdout.write(`\x1b]99;i=1:d=0;${title}\x1b\\`);
|
|
33
|
+
process.stdout.write(`\x1b]99;i=1:p=body;${body}\x1b\\`);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function notifyWindows(title: string, body: string): void {
|
|
37
|
+
const { execFile } = require("child_process");
|
|
38
|
+
execFile("powershell.exe", ["-NoProfile", "-Command", windowsToastScript(title, body)]);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function notify(title: string, body: string): void {
|
|
42
|
+
if (process.env.WT_SESSION) {
|
|
43
|
+
notifyWindows(title, body);
|
|
44
|
+
} else if (process.env.KITTY_WINDOW_ID) {
|
|
45
|
+
notifyOSC99(title, body);
|
|
46
|
+
} else {
|
|
47
|
+
notifyOSC777(title, body);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export default function (pi: ExtensionAPI) {
|
|
52
|
+
pi.on("agent_end", async () => {
|
|
53
|
+
notify("Pi", "Ready for input");
|
|
54
|
+
});
|
|
55
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@diegopetrucci/pi-notify",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A pi extension that sends a notification when the agent is ready for input.",
|
|
5
|
+
"keywords": ["pi-package", "pi", "notification", "terminal"],
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/diegopetrucci/pi-extensions.git",
|
|
10
|
+
"directory": "extensions/notify"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"index.ts",
|
|
14
|
+
"README.md"
|
|
15
|
+
],
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"pi": {
|
|
20
|
+
"extensions": [
|
|
21
|
+
"index.ts"
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"@mariozechner/pi-coding-agent": "*"
|
|
26
|
+
}
|
|
27
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diegopetrucci/pi-extensions",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "A collection of pi extensions, including a minimal custom footer, an Amp-style oracle, a permission gate for dangerous bash commands,
|
|
3
|
+
"version": "0.1.8",
|
|
4
|
+
"description": "A collection of pi extensions, including a minimal custom footer, an Amp-style oracle, a permission gate for dangerous bash commands, confirm-before-destructive session actions, and terminal notifications when pi is ready for input.",
|
|
5
5
|
"keywords": ["pi-package", "pi", "terminal", "agent"],
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"./extensions/minimal-footer/index.ts",
|
|
30
30
|
"./extensions/oracle/index.ts",
|
|
31
31
|
"./extensions/permission-gate/index.ts",
|
|
32
|
-
"./extensions/confirm-destructive/index.ts"
|
|
32
|
+
"./extensions/confirm-destructive/index.ts",
|
|
33
|
+
"./extensions/notify/index.ts"
|
|
33
34
|
],
|
|
34
35
|
"image": "https://raw.githubusercontent.com/diegopetrucci/pi-extensions/main/assets/oracle-preview.svg"
|
|
35
36
|
}
|