@pi-archimedes/notify 2.3.0 → 2.4.0

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 CHANGED
@@ -33,11 +33,12 @@ When the agent finishes a task (`agent_end`) or a question is asked (`ASK_REQUES
33
33
 
34
34
  | Setting | Type | Default | Description |
35
35
  |---------|------|---------|-------------|
36
- | `enabled` | bool | `true` | Enable desktop notifications |
37
36
  | `notifyOnAgentEnd` | bool | `true` | Notify when agent finishes a task |
38
37
  | `notifyOnQuestion` | bool | `true` | Notify when a question needs your answer |
39
38
  | `delayMs` | number | `30000` | Milliseconds to wait before sending notification (default 30 seconds) |
40
39
 
40
+ On/off is managed by the suite: toggle via `/plugins` (`archimedes.notify.enabled`, default on).
41
+
41
42
  Settings are stored in `~/.pi/agent/settings.json` under the `archimedes.notify` namespace.
42
43
 
43
44
  ## Terminal compatibility
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-archimedes/notify",
3
- "version": "2.3.0",
3
+ "version": "2.4.0",
4
4
  "type": "module",
5
5
  "keywords": [
6
6
  "pi-package"
@@ -14,7 +14,7 @@
14
14
  ".": "./src/index.ts"
15
15
  },
16
16
  "dependencies": {
17
- "@pi-archimedes/core": "2.3.0"
17
+ "@pi-archimedes/core": "2.4.0"
18
18
  },
19
19
  "peerDependencies": {
20
20
  "@earendil-works/pi-coding-agent": ">=0.1.0",
@@ -0,0 +1,25 @@
1
+ import { describe, expect, it, vi } from "vitest";
2
+ import defaultExport from "./index.js";
3
+
4
+ describe("notify default export (standalone factory)", () => {
5
+ it("is a function that registers the notify handlers (registerNotify subscribes its own session events)", () => {
6
+ expect(typeof defaultExport).toBe("function");
7
+
8
+ const on = vi.fn();
9
+ const pi = { on } as any;
10
+
11
+ defaultExport(pi);
12
+
13
+ const events = on.mock.calls.map((c: Array<unknown>) => c[0]);
14
+ expect(events).toEqual(
15
+ expect.arrayContaining([
16
+ "agent_end",
17
+ "input",
18
+ "before_agent_start",
19
+ "agent_start",
20
+ "session_start",
21
+ "session_shutdown",
22
+ ]),
23
+ );
24
+ });
25
+ });
package/src/index.ts CHANGED
@@ -15,14 +15,14 @@ type TriggerType = (typeof TRIGGER)[keyof typeof TRIGGER];
15
15
  // ── Config ──────────────────────────────────────────────────────────────────
16
16
 
17
17
  export interface NotifyConfig {
18
- enabled: boolean;
18
+ // suite-managed by meta's plugin gate (archimedes.notify.enabled — see ADR 0012); notify never reads this
19
+ enabled?: boolean;
19
20
  notifyOnAgentEnd: boolean;
20
21
  notifyOnQuestion: boolean;
21
22
  delayMs: number;
22
23
  }
23
24
 
24
25
  export const DEFAULT_NOTIFY_CONFIG: NotifyConfig = {
25
- enabled: true,
26
26
  notifyOnAgentEnd: true,
27
27
  notifyOnQuestion: true,
28
28
  delayMs: 30_000,
@@ -153,10 +153,6 @@ export function scheduleNotify(trigger: TriggerType): void {
153
153
  // Load config fresh on each trigger
154
154
  const config = loadNotifyConfig();
155
155
 
156
- if (!config.enabled) {
157
- return;
158
- }
159
-
160
156
  if (trigger === TRIGGER.AGENT_END && !config.notifyOnAgentEnd) {
161
157
  return;
162
158
  }
@@ -213,18 +209,19 @@ export function registerNotify(pi: ExtensionAPI): void {
213
209
  });
214
210
  }
215
211
 
212
+ // ── Default export (for standalone pi.extensions loading) ─────────────────
213
+
214
+ // registerNotify subscribes its own session_start/session_shutdown (and
215
+ // agent/input) handlers internally, so the default factory just registers it.
216
+ export default function (pi: ExtensionAPI): void {
217
+ registerNotify(pi);
218
+ }
219
+
216
220
  // ── Settings UI ─────────────────────────────────────────────────────────────
217
221
 
218
222
  /** Build settings UI items for the notify package. */
219
223
  export function getNotifySettingsItems(config: NotifyConfig): SettingItem[] {
220
224
  return [
221
- {
222
- id: "enabled",
223
- label: "Notifications",
224
- description: "Enable desktop notifications",
225
- currentValue: config.enabled ? "On" : "Off",
226
- values: ["On", "Off"],
227
- },
228
225
  {
229
226
  id: "notifyOnAgentEnd",
230
227
  label: "Notify on task complete",