@henryqw/pi-ask-question 0.1.6 → 0.1.8

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 CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  Ask the user one interactive question with up to three choices, or a custom answer.
4
4
 
5
+ ## Why
6
+
7
+ - **Created for**: Asking the user one interactive question with up to three choices during a Pi session.
8
+ - **Advantage**: Offers a keyboard-selectable prompt and returns one explicit answer instead of relying on free-form chat parsing.
9
+
5
10
  ## Install
6
11
 
7
12
  ```bash
@@ -18,6 +18,9 @@ interface QuestionOption {
18
18
  type DisplayOption = QuestionOption & { isOther?: boolean };
19
19
 
20
20
  const CUSTOM_OPTION_LABEL = "Something else.";
21
+ // Models are told to omit "(Recommended)" from labels but don't always comply; normalize instead of duplicating.
22
+ const RECOMMENDED_SUFFIX = /\s*\(recommended\)\s*$/i;
23
+ const withRecommended = (label: string): string => `${label.replace(RECOMMENDED_SUFFIX, "")} (Recommended)`;
21
24
  const NUMBER_KEYS = ["1", "2", "3", "4"] as const;
22
25
 
23
26
  interface QuestionDetails {
@@ -175,7 +178,7 @@ export default function askQuestionExtension(pi: ExtensionAPI): void {
175
178
  const option = allOptions[index]!;
176
179
  const selected = index === optionIndex;
177
180
  const prefix = selected ? theme.fg("accent", "> ") : " ";
178
- const label = `${index + 1}. ${option.label}${index === 0 ? " (Recommended)" : ""}${option.isOther && editMode ? " ✎" : ""}`;
181
+ const label = `${index + 1}. ${index === 0 ? withRecommended(option.label) : option.label}${option.isOther && editMode ? " ✎" : ""}`;
179
182
  addWrappedWithPrefix(prefix, theme.fg(selected || (option.isOther && editMode) ? "accent" : "text", label));
180
183
  if (option.description) addWrappedWithPrefix(" ", theme.fg("muted", option.description));
181
184
  }
@@ -230,7 +233,7 @@ export default function askQuestionExtension(pi: ExtensionAPI): void {
230
233
  const options = Array.isArray(args.options) ? args.options : [];
231
234
  if (options.length) {
232
235
  const labels = options.map((option: QuestionOption) => option.label);
233
- const numbered = [...labels, CUSTOM_OPTION_LABEL].map((option, index) => `${index + 1}. ${option}${index === 0 ? " (Recommended)" : ""}`);
236
+ const numbered = [...labels, CUSTOM_OPTION_LABEL].map((option, index) => `${index + 1}. ${index === 0 ? withRecommended(option) : option}`);
234
237
  text += `\n${theme.fg("dim", ` Options: ${numbered.join(", ")}`)}`;
235
238
  }
236
239
  return new Text(text, 0, 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@henryqw/pi-ask-question",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "Ask Pi users one interactive question with choices or a custom answer.",
5
5
  "keywords": [
6
6
  "pi-package",