@pi-unipi/ask-user 0.1.6 → 0.1.7

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/config.ts CHANGED
@@ -22,6 +22,8 @@ export interface AskUserSettings {
22
22
  /** Allow freeform text input */
23
23
  freeform: boolean;
24
24
  };
25
+ /** Send notification when agent pauses to ask a question */
26
+ notifyOnAsk: boolean;
25
27
  }
26
28
 
27
29
  /** Default settings */
@@ -32,6 +34,7 @@ export const DEFAULT_SETTINGS: AskUserSettings = {
32
34
  multiSelect: true,
33
35
  freeform: true,
34
36
  },
37
+ notifyOnAsk: true,
35
38
  };
36
39
 
37
40
  /** Settings path */
@@ -102,7 +105,9 @@ export function getAskUserSettings(): AskUserSettings {
102
105
  };
103
106
  }
104
107
 
105
- cachedSettings = { enabled, allowedFormats };
108
+ const notifyOnAsk = typeof askUser.notifyOnAsk === "boolean" ? askUser.notifyOnAsk : DEFAULT_SETTINGS.notifyOnAsk;
109
+
110
+ cachedSettings = { enabled, allowedFormats, notifyOnAsk };
106
111
  return cachedSettings;
107
112
  }
108
113
 
@@ -119,6 +124,7 @@ export function saveAskUserSettings(settings: AskUserSettings): void {
119
124
  (file[SETTINGS_KEY] as Record<string, unknown>).askUser = {
120
125
  enabled: settings.enabled,
121
126
  allowedFormats: settings.allowedFormats,
127
+ notifyOnAsk: settings.notifyOnAsk,
122
128
  };
123
129
 
124
130
  writeSettingsFile(file);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-unipi/ask-user",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Structured user input tool for Pi coding agent — single-select, multi-select, freeform",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/settings-tui.ts CHANGED
@@ -65,6 +65,13 @@ const SETTINGS: SettingItem[] = [
65
65
  getValue: (s) => s.allowedFormats.freeform,
66
66
  setValue: (s, v) => (s.allowedFormats.freeform = v),
67
67
  },
68
+ {
69
+ key: "notifyOnAsk",
70
+ label: "Notify when asking",
71
+ description: "Send notification when agent pauses for input",
72
+ getValue: (s) => s.notifyOnAsk,
73
+ setValue: (s, v) => (s.notifyOnAsk = v),
74
+ },
68
75
  ];
69
76
 
70
77
  /**
package/tools.ts CHANGED
@@ -6,7 +6,11 @@
6
6
 
7
7
  import { Type } from "@sinclair/typebox";
8
8
  import type { ExtensionAPI, ExtensionContext } from "@mariozechner/pi-coding-agent";
9
- import { ASK_USER_TOOLS } from "@pi-unipi/core";
9
+ import {
10
+ ASK_USER_TOOLS,
11
+ UNIPI_EVENTS,
12
+ emitEvent,
13
+ } from "@pi-unipi/core";
10
14
  import type { NormalizedOption, AskUserResponse } from "./types.js";
11
15
  import { renderAskUI, createRenderCall, createRenderResult } from "./ask-ui.js";
12
16
  import { getAskUserSettings } from "./config.js";
@@ -246,6 +250,17 @@ export function registerAskUserTools(pi: ExtensionAPI): void {
246
250
  prefill: opt.prefill,
247
251
  }));
248
252
 
253
+ // Emit ASK_USER_PROMPT event if notifyOnAsk is enabled
254
+ if (settings.notifyOnAsk) {
255
+ emitEvent(pi, UNIPI_EVENTS.ASK_USER_PROMPT, {
256
+ question,
257
+ context,
258
+ optionCount: normalizedOptions.length,
259
+ allowMultiple,
260
+ allowFreeform,
261
+ });
262
+ }
263
+
249
264
  // Render interactive UI
250
265
  const result = await ctx.ui.custom<{ response: AskUserResponse } | null>(
251
266
  renderAskUI({