pi-ask-user 0.12.0 → 0.13.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.
Files changed (3) hide show
  1. package/README.md +17 -2
  2. package/index.ts +24 -3
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -64,7 +64,7 @@ The registered tool name is:
64
64
  | `options` | `{title, description?}[]?` | `[]` | Multiple-choice options. The schema is a flat object shape (no `anyOf`, which some provider proxies strip or reject); plain strings and common alias keys (`label`, `text`, `value`, `name`, `option`) are still accepted at runtime |
65
65
  | `allowMultiple` | `boolean?` | `false` | Enable multi-select mode |
66
66
  | `allowFreeform` | `boolean?` | `true` | Add a "Type something" freeform option |
67
- | `allowComment` | `boolean?` | `false` | Expose a user-toggleable extra-context option in the custom UI (`ctrl+g` or the toggle row) and collect an optional comment in fallback dialogs |
67
+ | `allowComment` | `boolean?` | env var or `false` | Expose a user-toggleable extra-context option in the custom UI (`ctrl+g` or the toggle row) and collect an optional comment in fallback dialogs |
68
68
  | `displayMode` | `"overlay" \| "inline"?` | env var or `"overlay"` | Controls custom UI rendering: `overlay` shows the centered modal (current behavior), `inline` renders without overlay framing |
69
69
  | `overlayToggleKey` | `string?` | env var or `"alt+o"` | Shortcut for hiding/showing the overlay popup (overlay mode only). Pi-TUI key spec, e.g. `"alt+o"`, `"ctrl+shift+h"`. Pass `"off"` to disable. |
70
70
  | `commentToggleKey` | `string?` | env var or `"ctrl+g"` | Shortcut for toggling the optional comment/extra-context row when `allowComment: true`. Pass `"off"` to disable. |
@@ -95,10 +95,13 @@ Configure your defaults globally by setting these in your shell profile (`~/.zsh
95
95
 
96
96
  ```bash
97
97
  export PI_ASK_USER_DISPLAY_MODE=inline
98
+ export PI_ASK_USER_ALLOW_COMMENT=true
98
99
  export PI_ASK_USER_OVERLAY_TOGGLE_KEY=alt+h
99
100
  export PI_ASK_USER_COMMENT_TOGGLE_KEY=alt+c
100
101
  ```
101
102
 
103
+ Environment variables must be present in the process that launches Pi. If Pi is launched from a desktop app or a different shell, changes in `~/.zshrc` may not be inherited; launch Pi from a terminal where `echo $PI_ASK_USER_DISPLAY_MODE` shows the expected value.
104
+
102
105
  ### Display mode
103
106
 
104
107
  Effective order:
@@ -109,6 +112,14 @@ Effective order:
109
112
 
110
113
  Unrecognised values are silently ignored and fall back to `"overlay"`.
111
114
 
115
+ ### Optional comments
116
+
117
+ Effective order:
118
+
119
+ 1. Per-call `allowComment` parameter (if provided)
120
+ 2. `PI_ASK_USER_ALLOW_COMMENT` (`true`, `1`, `yes`, or `on`; corresponding false values are also accepted)
121
+ 3. Fallback default: `false`
122
+
112
123
  ### Shortcuts
113
124
 
114
125
  Effective order for both `overlayToggleKey` and `commentToggleKey`:
@@ -133,6 +144,10 @@ While an `ask_user` prompt is open:
133
144
 
134
145
  If you prefer never to see the overlay, set `displayMode: "inline"` per call or `PI_ASK_USER_DISPLAY_MODE=inline` globally.
135
146
 
147
+ ## Known limitations
148
+
149
+ - **Overlays cannot draw over inline images** ([#8](https://github.com/edlsh/pi-ask-user/issues/8)). Pi-TUI's overlay compositor skips rows occupied by terminal images (Kitty/iTerm2 graphics), so an `ask_user` overlay that intersects an image is partially or fully invisible. This must be fixed upstream in pi-tui (`compositeLineAt` returns image rows unchanged). Until then, `displayMode: "inline"` (or `PI_ASK_USER_DISPLAY_MODE=inline`) sidesteps the overlay compositor entirely and should keep the prompt visible.
150
+
136
151
  ## Result details
137
152
 
138
153
  All tool results include a structured `details` object for rendering and session state reconstruction:
@@ -153,4 +168,4 @@ interface AskToolDetails {
153
168
 
154
169
  ## Changelog
155
170
 
156
- See [CHANGELOG.md](./CHANGELOG.md).
171
+ See [CHANGELOG.md](./CHANGELOG.md).
package/index.ts CHANGED
@@ -160,6 +160,24 @@ function normalizeOptionalComment(text: string | null | undefined): string | und
160
160
  return trimmed ? trimmed : undefined;
161
161
  }
162
162
 
163
+ function parseBooleanPreference(value: string | undefined): boolean | undefined {
164
+ if (value === undefined) return undefined;
165
+ switch (value.trim().toLowerCase()) {
166
+ case "1":
167
+ case "true":
168
+ case "yes":
169
+ case "on":
170
+ return true;
171
+ case "0":
172
+ case "false":
173
+ case "no":
174
+ case "off":
175
+ return false;
176
+ default:
177
+ return undefined;
178
+ }
179
+ }
180
+
163
181
  function createFreeformResponse(text: string | null | undefined): AskResponse | null {
164
182
  const trimmed = text?.trim();
165
183
  return trimmed ? { kind: "freeform", text: trimmed } : null;
@@ -1849,7 +1867,7 @@ export default function(pi: ExtensionAPI) {
1849
1867
  Type.Boolean({ description: "Add a freeform text option. Default: true" }),
1850
1868
  ),
1851
1869
  allowComment: Type.Optional(
1852
- Type.Boolean({ description: "Collect an optional comment after selecting one or more options. Default: false" }),
1870
+ Type.Boolean({ description: "Collect an optional comment after selecting one or more options. Default: PI_ASK_USER_ALLOW_COMMENT env var if set, otherwise false." }),
1853
1871
  ),
1854
1872
  displayMode: Type.Optional(
1855
1873
  StringEnum(["overlay", "inline"] as const, {
@@ -1887,16 +1905,19 @@ export default function(pi: ExtensionAPI) {
1887
1905
  options: rawOptions = [],
1888
1906
  allowMultiple = false,
1889
1907
  allowFreeform = true,
1890
- allowComment = false,
1908
+ allowComment: requestedAllowComment,
1891
1909
  displayMode,
1892
1910
  overlayToggleKey,
1893
1911
  commentToggleKey,
1894
1912
  timeout,
1895
1913
  } = params as AskParams;
1896
- const envMode = process.env.PI_ASK_USER_DISPLAY_MODE;
1914
+ const envMode = process.env.PI_ASK_USER_DISPLAY_MODE?.trim().toLowerCase();
1897
1915
  const envDisplayMode: AskDisplayMode | undefined =
1898
1916
  envMode === "overlay" || envMode === "inline" ? envMode : undefined;
1899
1917
  const effectiveDisplayMode: AskDisplayMode = displayMode ?? envDisplayMode ?? "overlay";
1918
+ const allowComment = requestedAllowComment
1919
+ ?? parseBooleanPreference(process.env.PI_ASK_USER_ALLOW_COMMENT)
1920
+ ?? false;
1900
1921
  const shortcuts: ResolvedAskShortcuts = {
1901
1922
  overlayToggle: resolveShortcut(
1902
1923
  overlayToggleKey,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-ask-user",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "Interactive ask_user tool for pi-coding-agent with searchable split-pane selection UI, multi-select, and freeform input",
5
5
  "type": "module",
6
6
  "keywords": [