pi-ask-user 0.9.0 → 0.11.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 +2 -2
- package/index.ts +28 -7
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -117,7 +117,7 @@ Effective order for both `overlayToggleKey` and `commentToggleKey`:
|
|
|
117
117
|
2. Matching env var (`PI_ASK_USER_OVERLAY_TOGGLE_KEY` / `PI_ASK_USER_COMMENT_TOGGLE_KEY`)
|
|
118
118
|
3. Built-in defaults: `alt+o` and `ctrl+g`
|
|
119
119
|
|
|
120
|
-
Pass `"off"`, `"none"`, or `"disabled"` (at any level) to disable the shortcut entirely. Invalid specs are silently dropped and the next source is used. Specs follow the Pi-TUI [`KeyId`](https://github.com/
|
|
120
|
+
Pass `"off"`, `"none"`, or `"disabled"` (at any level) to disable the shortcut entirely. Invalid specs are silently dropped and the next source is used. Specs follow the Pi-TUI [`KeyId`](https://github.com/earendil-works/pi-mono/blob/main/packages/tui/src/keys.ts) format: `[mod+]...key` where modifiers are `ctrl`, `shift`, `alt`, `super`, in any order, joined by `+` (e.g. `ctrl+g`, `alt+shift+x`, `escape`, `tab`).
|
|
121
121
|
|
|
122
122
|
## Controls
|
|
123
123
|
|
|
@@ -129,7 +129,7 @@ While an `ask_user` prompt is open:
|
|
|
129
129
|
| `ctrl+g` (configurable via `commentToggleKey`) | Toggle the optional comment/extra-context row (when `allowComment: true`). |
|
|
130
130
|
| `enter` | Confirm the focused option, submit a freeform response, or submit/skip an optional comment. |
|
|
131
131
|
| `esc` | Clear the search filter, exit freeform/comment mode, or cancel the prompt. |
|
|
132
|
-
| `↑` /
|
|
132
|
+
| `↑` / `↓`, `ctrl+k` / `ctrl+j` | Navigate options. `ctrl+k` / `ctrl+j` (vim-style) work while typing in searchable prompts without disturbing the filter. |
|
|
133
133
|
|
|
134
134
|
If you prefer never to see the overlay, set `displayMode: "inline"` per call or `PI_ASK_USER_DISPLAY_MODE=inline` globally.
|
|
135
135
|
|
package/index.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* and a custom box border instead of manual ANSI box drawing.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type { ExtensionAPI, Theme } from "@
|
|
9
|
-
import { getMarkdownTheme } from "@
|
|
8
|
+
import type { ExtensionAPI, Theme } from "@earendil-works/pi-coding-agent";
|
|
9
|
+
import { getMarkdownTheme } from "@earendil-works/pi-coding-agent";
|
|
10
10
|
import { Type, type TUnsafe } from "@sinclair/typebox";
|
|
11
11
|
import {
|
|
12
12
|
Container,
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
type TUI,
|
|
28
28
|
truncateToWidth,
|
|
29
29
|
wrapTextWithAnsi,
|
|
30
|
-
} from "@
|
|
30
|
+
} from "@earendil-works/pi-tui";
|
|
31
31
|
import { renderSingleSelectRows } from "./single-select-layout";
|
|
32
32
|
|
|
33
33
|
import { createRequire } from "node:module";
|
|
@@ -320,6 +320,27 @@ const COMMENT_TOGGLE_LABEL = "Add extra context after selection";
|
|
|
320
320
|
const DEFAULT_OVERLAY_TOGGLE_KEY = "alt+o";
|
|
321
321
|
const DEFAULT_COMMENT_TOGGLE_KEY = "ctrl+g";
|
|
322
322
|
|
|
323
|
+
// Vim-style aliases for navigating option lists. ctrl+j/k are safe in the
|
|
324
|
+
// searchable single-select because they don't collide with fuzzy-search input.
|
|
325
|
+
const VIM_SELECT_UP_KEY = Key.ctrl("k");
|
|
326
|
+
const VIM_SELECT_DOWN_KEY = Key.ctrl("j");
|
|
327
|
+
|
|
328
|
+
function matchesSelectUp(data: string, keybindings: KeybindingsManager): boolean {
|
|
329
|
+
return (
|
|
330
|
+
keybindings.matches(data, "tui.select.up") ||
|
|
331
|
+
matchesKey(data, Key.shift("tab")) ||
|
|
332
|
+
matchesKey(data, VIM_SELECT_UP_KEY)
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
function matchesSelectDown(data: string, keybindings: KeybindingsManager): boolean {
|
|
337
|
+
return (
|
|
338
|
+
keybindings.matches(data, "tui.select.down") ||
|
|
339
|
+
matchesKey(data, Key.tab) ||
|
|
340
|
+
matchesKey(data, VIM_SELECT_DOWN_KEY)
|
|
341
|
+
);
|
|
342
|
+
}
|
|
343
|
+
|
|
323
344
|
function buildCustomUIOptions(
|
|
324
345
|
displayMode: AskDisplayMode,
|
|
325
346
|
onHandle?: (handle: OverlayHandle) => void,
|
|
@@ -449,13 +470,13 @@ class MultiSelectList implements Component {
|
|
|
449
470
|
return;
|
|
450
471
|
}
|
|
451
472
|
|
|
452
|
-
if (
|
|
473
|
+
if (matchesSelectUp(data, this.keybindings)) {
|
|
453
474
|
this.selectedIndex = this.selectedIndex === 0 ? count - 1 : this.selectedIndex - 1;
|
|
454
475
|
this.invalidate();
|
|
455
476
|
return;
|
|
456
477
|
}
|
|
457
478
|
|
|
458
|
-
if (
|
|
479
|
+
if (matchesSelectDown(data, this.keybindings)) {
|
|
459
480
|
this.selectedIndex = this.selectedIndex === count - 1 ? 0 : this.selectedIndex + 1;
|
|
460
481
|
this.invalidate();
|
|
461
482
|
return;
|
|
@@ -842,13 +863,13 @@ class WrappedSingleSelectList implements Component {
|
|
|
842
863
|
const filteredOptions = this.getFilteredOptions();
|
|
843
864
|
const count = this.getItemCount(filteredOptions);
|
|
844
865
|
|
|
845
|
-
if ((
|
|
866
|
+
if (matchesSelectUp(data, this.keybindings) && count > 0) {
|
|
846
867
|
this.selectedIndex = this.selectedIndex === 0 ? count - 1 : this.selectedIndex - 1;
|
|
847
868
|
this.invalidate();
|
|
848
869
|
return;
|
|
849
870
|
}
|
|
850
871
|
|
|
851
|
-
if ((
|
|
872
|
+
if (matchesSelectDown(data, this.keybindings) && count > 0) {
|
|
852
873
|
this.selectedIndex = this.selectedIndex === count - 1 ? 0 : this.selectedIndex + 1;
|
|
853
874
|
this.invalidate();
|
|
854
875
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-ask-user",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.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": [
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"check": "npm pack --dry-run"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@
|
|
48
|
-
"@
|
|
47
|
+
"@earendil-works/pi-coding-agent": "*",
|
|
48
|
+
"@earendil-works/pi-tui": "*",
|
|
49
49
|
"@sinclair/typebox": "*"
|
|
50
50
|
}
|
|
51
51
|
}
|