@pi-unipi/ask-user 2.6.1 → 2.9.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/package.json +11 -7
- package/settings-tui.ts +18 -34
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-unipi/ask-user",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "Structured user input tool for Pi coding agent
|
|
3
|
+
"version": "2.9.0",
|
|
4
|
+
"description": "Structured user input tool for Pi coding agent \u2014 single-select, multi-select, freeform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.ts",
|
|
7
7
|
"license": "MIT",
|
|
@@ -40,16 +40,20 @@
|
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@pi-unipi/core": "2.
|
|
43
|
+
"@pi-unipi/core": "2.9.0"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"@earendil-works/pi-coding-agent": "^0.
|
|
47
|
-
"@earendil-works/pi-tui": "^0.
|
|
46
|
+
"@earendil-works/pi-coding-agent": "^0.84.0",
|
|
47
|
+
"@earendil-works/pi-tui": "^0.84.0",
|
|
48
48
|
"typebox": "^1.1.38"
|
|
49
49
|
},
|
|
50
50
|
"pi": {
|
|
51
|
-
"extensions": [
|
|
52
|
-
|
|
51
|
+
"extensions": [
|
|
52
|
+
"./index.ts"
|
|
53
|
+
],
|
|
54
|
+
"skills": [
|
|
55
|
+
"./skills"
|
|
56
|
+
],
|
|
53
57
|
"prompts": [],
|
|
54
58
|
"themes": []
|
|
55
59
|
}
|
package/settings-tui.ts
CHANGED
|
@@ -6,26 +6,13 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import type { Component } from "@earendil-works/pi-tui";
|
|
9
|
-
import { truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
10
|
-
import { adaptiveInnerWidth, normalizeWidth, safeRepeat, shouldRenderBorder } from "@pi-unipi/core";
|
|
9
|
+
import { Key, matchesKey, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
10
|
+
import { adaptiveInnerWidth, normalizeWidth, safeRepeat, shouldRenderBorder, ansi, TOGGLE_ON, TOGGLE_OFF } from "@pi-unipi/core";
|
|
11
11
|
import { getAskUserSettings, saveAskUserSettings, type AskUserSettings } from "./config.js";
|
|
12
12
|
|
|
13
13
|
/** ANSI escape codes */
|
|
14
|
-
const ansi = {
|
|
15
|
-
reset: "\x1b[0m",
|
|
16
|
-
bold: "\x1b[1m",
|
|
17
|
-
dim: "\x1b[2m",
|
|
18
|
-
// Colors
|
|
19
|
-
cyan: "\x1b[36m",
|
|
20
|
-
green: "\x1b[32m",
|
|
21
|
-
yellow: "\x1b[33m",
|
|
22
|
-
red: "\x1b[31m",
|
|
23
|
-
gray: "\x1b[90m",
|
|
24
|
-
};
|
|
25
14
|
|
|
26
15
|
/** Toggle symbols */
|
|
27
|
-
const TOGGLE_ON = `${ansi.green}●${ansi.reset}`;
|
|
28
|
-
const TOGGLE_OFF = `${ansi.dim}○${ansi.reset}`;
|
|
29
16
|
|
|
30
17
|
/** Setting items */
|
|
31
18
|
interface SettingItem {
|
|
@@ -99,25 +86,22 @@ export class AskUserSettingsOverlay implements Component {
|
|
|
99
86
|
* Handle keyboard input.
|
|
100
87
|
*/
|
|
101
88
|
handleInput(data: string): void {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
case "\x1b": // Escape - close without saving
|
|
119
|
-
this.onClose?.();
|
|
120
|
-
break;
|
|
89
|
+
if (matchesKey(data, Key.up) || data === "k") {
|
|
90
|
+
// Up
|
|
91
|
+
this.selectedIndex = (this.selectedIndex - 1 + SETTINGS.length) % SETTINGS.length;
|
|
92
|
+
} else if (matchesKey(data, Key.down) || data === "j") {
|
|
93
|
+
// Down
|
|
94
|
+
this.selectedIndex = (this.selectedIndex + 1) % SETTINGS.length;
|
|
95
|
+
} else if (matchesKey(data, Key.space)) {
|
|
96
|
+
// Space - toggle
|
|
97
|
+
this.toggleSetting(SETTINGS[this.selectedIndex].key);
|
|
98
|
+
} else if (matchesKey(data, Key.enter)) {
|
|
99
|
+
// Enter - save and close
|
|
100
|
+
this.save();
|
|
101
|
+
this.onClose?.();
|
|
102
|
+
} else if (matchesKey(data, Key.escape)) {
|
|
103
|
+
// Escape - close without saving
|
|
104
|
+
this.onClose?.();
|
|
121
105
|
}
|
|
122
106
|
}
|
|
123
107
|
|