@geoqiao/pi-ask 1.2.3 → 1.3.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/CHANGELOG.md +61 -85
- package/README.md +11 -3
- package/docs/architecture.md +6 -1
- package/docs/configuration.md +4 -3
- package/docs/contract.md +34 -14
- package/docs/remote-events.md +14 -14
- package/package.json +17 -17
- package/skills/ask-user/SKILL.md +2 -0
- package/src/answer-commands.ts +37 -10
- package/src/answer-extraction.ts +155 -115
- package/src/ask-payload-store.ts +23 -1
- package/src/ask-tool-helpers.ts +12 -11
- package/src/ask-tool.ts +2 -0
- package/src/constants/ui.ts +1 -0
- package/src/index.ts +2 -0
- package/src/pending-ask.ts +128 -0
- package/src/remote-ask.ts +11 -6
- package/src/result-format.ts +13 -3
- package/src/result.ts +1 -1
- package/src/resume-pending-ask.ts +95 -0
- package/src/rpc/controller.ts +2 -1
- package/src/schema.ts +59 -24
- package/src/state/create.ts +1 -1
- package/src/state/normalize.ts +50 -31
- package/src/state/result.ts +3 -0
- package/src/types.ts +1 -0
- package/src/ui/render-helpers.ts +9 -2
- package/src/ui/render-question.ts +39 -7
- package/src/ui/view-models/question.ts +2 -0
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
truncateToWidth,
|
|
3
|
+
visibleWidth,
|
|
4
|
+
wrapTextWithAnsi,
|
|
5
|
+
} from "@earendil-works/pi-tui";
|
|
6
|
+
import { UI_DIMENSIONS, UI_TEXT } from "../constants/ui.ts";
|
|
3
7
|
import {
|
|
4
8
|
measurePreviewLeftWidth,
|
|
5
9
|
mergeColumns,
|
|
@@ -83,7 +87,13 @@ function renderStandardOption(
|
|
|
83
87
|
row.pointer,
|
|
84
88
|
" ".repeat(visibleWidth(row.pointer))
|
|
85
89
|
);
|
|
86
|
-
|
|
90
|
+
renderOptionSubtitle(
|
|
91
|
+
lines,
|
|
92
|
+
row.description,
|
|
93
|
+
row.recommended,
|
|
94
|
+
context.width,
|
|
95
|
+
context.theme
|
|
96
|
+
);
|
|
87
97
|
renderOptionDetail(lines, row.detail, context, {
|
|
88
98
|
suppressLeadingGap: !!row.description,
|
|
89
99
|
});
|
|
@@ -170,7 +180,7 @@ function renderPreviewOptionList(
|
|
|
170
180
|
row.pointer,
|
|
171
181
|
" "
|
|
172
182
|
);
|
|
173
|
-
|
|
183
|
+
renderOptionSubtitle(lines, row.description, row.recommended, width, theme);
|
|
174
184
|
}
|
|
175
185
|
return lines;
|
|
176
186
|
}
|
|
@@ -275,14 +285,36 @@ function renderInteractiveCustomOption(
|
|
|
275
285
|
});
|
|
276
286
|
}
|
|
277
287
|
|
|
278
|
-
function
|
|
288
|
+
function renderOptionSubtitle(
|
|
279
289
|
lines: string[],
|
|
280
290
|
description: string | undefined,
|
|
291
|
+
recommended: boolean,
|
|
281
292
|
width: number,
|
|
282
293
|
theme: Theme
|
|
283
294
|
) {
|
|
284
|
-
if (!
|
|
295
|
+
if (!recommended) {
|
|
296
|
+
if (description) {
|
|
297
|
+
pushWrappedText(
|
|
298
|
+
lines,
|
|
299
|
+
description,
|
|
300
|
+
width,
|
|
301
|
+
theme,
|
|
302
|
+
"muted",
|
|
303
|
+
" ",
|
|
304
|
+
" "
|
|
305
|
+
);
|
|
306
|
+
}
|
|
285
307
|
return;
|
|
286
308
|
}
|
|
287
|
-
|
|
309
|
+
|
|
310
|
+
const indent = " ";
|
|
311
|
+
const text =
|
|
312
|
+
theme.fg("warning", UI_TEXT.recommendedMarker) +
|
|
313
|
+
(description ? theme.fg("muted", ` | ${description}`) : "");
|
|
314
|
+
for (const line of wrapTextWithAnsi(
|
|
315
|
+
text,
|
|
316
|
+
Math.max(1, width - visibleWidth(indent))
|
|
317
|
+
)) {
|
|
318
|
+
lines.push(truncateToWidth(`${indent}${line}`, width));
|
|
319
|
+
}
|
|
288
320
|
}
|
|
@@ -30,6 +30,7 @@ export interface OptionRowModel {
|
|
|
30
30
|
label: string;
|
|
31
31
|
pointer: string;
|
|
32
32
|
prefix: string;
|
|
33
|
+
recommended: boolean;
|
|
33
34
|
selected: boolean;
|
|
34
35
|
}
|
|
35
36
|
|
|
@@ -104,6 +105,7 @@ function buildOptionRowModel(
|
|
|
104
105
|
label: option.label,
|
|
105
106
|
pointer,
|
|
106
107
|
prefix: getOptionPrefix(question.type, option, answered),
|
|
108
|
+
recommended: option.recommended === true,
|
|
107
109
|
selected,
|
|
108
110
|
};
|
|
109
111
|
}
|