@ftrdotdev/pi-inquiry 0.8.0 → 0.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/src/core/scene.ts CHANGED
@@ -16,7 +16,7 @@ import {
16
16
  multiEntries,
17
17
  type SuggestionState,
18
18
  } from "./machine.ts";
19
- import { truncateToWidth, visibleWidth } from "./text.ts";
19
+ import { isNonEmptyString, truncateToWidth, visibleWidth } from "./text.ts";
20
20
  import type { EditorState } from "./editor.ts";
21
21
 
22
22
  export type Style =
@@ -42,7 +42,7 @@ export interface Scene {
42
42
  readonly lines: readonly SceneLine[];
43
43
  }
44
44
 
45
- export const span = (text: string, style?: Style, bold = false): Span => ({
45
+ export const span = (text: string, style?: Style, bold: boolean = false): Span => ({
46
46
  text,
47
47
  ...(style === undefined ? {} : { style }),
48
48
  ...(bold ? { bold: true } : {}),
@@ -71,7 +71,11 @@ export const wrapLine = (content: SceneLine, width: number): readonly SceneLine[
71
71
  continue;
72
72
  }
73
73
  if (part !== "")
74
- segments[segments.length - 1]!.push({ text: part, style: s.style, bold: s.bold });
74
+ segments[segments.length - 1]!.push({
75
+ text: part,
76
+ ...(s.style === undefined ? {} : { style: s.style }),
77
+ ...(s.bold === undefined ? {} : { bold: s.bold }),
78
+ });
75
79
  }
76
80
  }
77
81
 
@@ -91,7 +95,12 @@ const wrapSegment = (segment: SceneLine, width: number): readonly SceneLine[] =>
91
95
  const tokens: Span[] = [];
92
96
  for (const s of segment) {
93
97
  for (const part of s.text.split(/(\s+)/)) {
94
- if (part !== "") tokens.push({ text: part, style: s.style, bold: s.bold });
98
+ if (part !== "")
99
+ tokens.push({
100
+ text: part,
101
+ ...(s.style === undefined ? {} : { style: s.style }),
102
+ ...(s.bold === undefined ? {} : { bold: s.bold }),
103
+ });
95
104
  }
96
105
  }
97
106
 
@@ -152,7 +161,13 @@ const breakLongSpan = (token: Span, width: number): readonly Span[][] => {
152
161
  }
153
162
  if (current !== "") chunks.push(current);
154
163
  if (chunks.length === 0) chunks.push("");
155
- return chunks.map((text) => [{ text, style: token.style, bold: token.bold }]);
164
+ return chunks.map((text) => [
165
+ {
166
+ text,
167
+ ...(token.style === undefined ? {} : { style: token.style }),
168
+ ...(token.bold === undefined ? {} : { bold: token.bold }),
169
+ },
170
+ ]);
156
171
  };
157
172
 
158
173
  /** Description and subtitle indent for the option block: seven cells, two more than before the marker column. */
@@ -183,7 +198,7 @@ const optionRowPrefix = (selected: boolean, recommended: boolean): SceneLine =>
183
198
  export const buildScene = (state: MachineState, width: number): Scene => {
184
199
  const renderWidth = Math.max(1, width);
185
200
  const frame = buildBoxFrame(renderWidth, { paddingX: 0 });
186
- if (!frame) return { lines: [] };
201
+ if (frame === null) return { lines: [] };
187
202
  const contentWidth = frame.contentWidth;
188
203
  const lines: SceneLine[] = [];
189
204
  const question = state.questions[state.currentTab];
@@ -204,7 +219,7 @@ export const buildScene = (state: MachineState, width: number): Scene => {
204
219
  };
205
220
 
206
221
  const renderOptions = (): void => {
207
- if (question?.multiple) {
222
+ if (question?.multiple ?? false) {
208
223
  renderMultiOptions();
209
224
  return;
210
225
  }
@@ -215,12 +230,14 @@ export const buildScene = (state: MachineState, width: number): Scene => {
215
230
  const labelText = `${i + 1}. ${option.label}${isOther && state.inputMode ? " ✎" : ""}`;
216
231
  const color = selected || (isOther && state.inputMode) ? "accent" : "text";
217
232
  pushWrapped(optionRowPrefix(selected, option.recommended), [span(labelText, color)]);
218
- if (option.description) {
233
+ if (isNonEmptyString(option.description)) {
219
234
  pushWrapped([span(OPTION_TEXT_INDENT)], [span(option.description, "muted")]);
220
- } else if (option.isOther && !state.inputMode && question) {
235
+ } else if (option.isOther && !state.inputMode && question !== undefined) {
221
236
  // Show an existing custom answer as a subtitle under "Type something".
237
+ // The strict comparison, rather than `?? false`, is what narrows
238
+ // `answer` for the label read below.
222
239
  const answer = state.answers.get(question.id)?.[0];
223
- if (answer?.wasCustom) {
240
+ if (answer?.wasCustom === true) {
224
241
  pushWrapped(
225
242
  [span(OPTION_TEXT_INDENT)],
226
243
  [span(`Current answer: ${answer.label}`, "muted")],
@@ -255,7 +272,7 @@ export const buildScene = (state: MachineState, width: number): Scene => {
255
272
  pushWrapped(optionRowPrefix(selected, entry.kind === "option" && entry.recommended), [
256
273
  span(labelText, selected ? "accent" : "text"),
257
274
  ]);
258
- if (description) {
275
+ if (isNonEmptyString(description)) {
259
276
  pushWrapped([span(OPTION_TEXT_INDENT)], [span(description, "muted")]);
260
277
  }
261
278
  }
@@ -288,7 +305,7 @@ export const buildScene = (state: MachineState, width: number): Scene => {
288
305
  }
289
306
 
290
307
  // Content
291
- if (state.inputMode && question) {
308
+ if (state.inputMode && question !== undefined) {
292
309
  pushWrapped([span(" ")], [span(question.prompt, "text")]);
293
310
  lines.push([]);
294
311
  renderOptions();
@@ -299,7 +316,7 @@ export const buildScene = (state: MachineState, width: number): Scene => {
299
316
  for (const editorLine of buildEditorBox(state.editor, Math.max(1, contentWidth - 1))) {
300
317
  lines.push([span(" "), ...editorLine]);
301
318
  }
302
- if (state.suggestions) {
319
+ if (state.suggestions !== null) {
303
320
  for (const popupLine of buildSuggestionPopup(
304
321
  state.suggestions,
305
322
  Math.max(1, contentWidth - 4),
@@ -308,7 +325,7 @@ export const buildScene = (state: MachineState, width: number): Scene => {
308
325
  }
309
326
  }
310
327
  lines.push([]);
311
- if (state.suggestions) {
328
+ if (state.suggestions !== null) {
312
329
  pushWrapped([span(" ")], [span("↑↓ pick • Enter/Tab complete • Esc close", "dim")]);
313
330
  } else {
314
331
  pushWrapped(
@@ -321,7 +338,7 @@ export const buildScene = (state: MachineState, width: number): Scene => {
321
338
  lines.push([]);
322
339
  for (const q of state.questions) {
323
340
  const answers = state.answers.get(q.id);
324
- if (answers && answers.length > 0) {
341
+ if (answers !== undefined && answers.length > 0) {
325
342
  // A single answer keeps the legacy bare label; a multi-select answer
326
343
  // lists each chosen option/alternative with its index.
327
344
  const rendered =
@@ -345,7 +362,7 @@ export const buildScene = (state: MachineState, width: number): Scene => {
345
362
  .join(", ");
346
363
  pushWrapped([span(" ")], [span(`Unanswered: ${missing}`, "warning")]);
347
364
  }
348
- } else if (question) {
365
+ } else if (question !== undefined) {
349
366
  pushWrapped([span(" ")], [span(question.prompt, "text")]);
350
367
  lines.push([]);
351
368
  renderOptions();
@@ -353,7 +370,7 @@ export const buildScene = (state: MachineState, width: number): Scene => {
353
370
 
354
371
  lines.push([]);
355
372
  if (!state.inputMode) {
356
- const isMultiSelect = question?.multiple === true;
373
+ const isMultiSelect = question?.multiple ?? false;
357
374
  const help =
358
375
  state.mode === "multi"
359
376
  ? isMultiSelect
@@ -420,7 +437,7 @@ export const clampLine = (content: SceneLine, width: number): SceneLine => {
420
437
  export const buildEditorBox = (editor: EditorState, boxWidth: number): readonly SceneLine[] => {
421
438
  const box = Math.max(4, boxWidth);
422
439
  const frame = buildBoxFrame(box, { paddingX: 1 });
423
- if (!frame) return [];
440
+ if (frame === null) return [];
424
441
  const border = (text: string): Span => span(text, "border");
425
442
  const rows = buildEditorRows(editor, frame.contentWidth);
426
443
  return [
@@ -504,7 +521,7 @@ export const buildEditorRows = (
504
521
  // cell counts toward the width).
505
522
  const renderedWidth = visibleWidth(plain(spans));
506
523
  const padding = " ".repeat(Math.max(0, contentWidth - renderedWidth));
507
- if (padding) spans.push(span(padding));
524
+ if (padding !== "") spans.push(span(padding));
508
525
  out.push(spans);
509
526
  }
510
527
  return out;
@@ -545,7 +562,7 @@ export const buildSuggestionPopup = (
545
562
  const marker = isSelected ? "→ " : " ";
546
563
  const label = item.label;
547
564
  const description = item.description?.replace(/\r\n|\r|\n/g, " ");
548
- if (description && renderWidth > 40) {
565
+ if (isNonEmptyString(description) && renderWidth > 40) {
549
566
  const primary = Math.max(1, Math.min(32, renderWidth - 6));
550
567
  const maxPrimary = Math.max(1, primary - 2);
551
568
  const truncatedLabel = truncateToWidth(label, maxPrimary);
@@ -29,10 +29,11 @@ export interface CompletionState {
29
29
  export class Keyboard extends Context.Service<
30
30
  Keyboard,
31
31
  {
32
- /** Wait for the next key event from the user. Blocks until one is available. */
33
- nextKey(): Effect.Effect<KeyEvent>;
32
+ /** Wait for the next key event from the user. Effect is already lazy, so the
33
+ * member is the Effect itself, not a factory returning one. */
34
+ readonly nextKey: Effect.Effect<KeyEvent>;
34
35
  }
35
- >()("inquiry/core/services/Keyboard") {}
36
+ >()("@ftrdotdev/pi-inquiry/core/services/Keyboard") {}
36
37
 
37
38
  export class Renderer extends Context.Service<
38
39
  Renderer,
@@ -42,7 +43,7 @@ export class Renderer extends Context.Service<
42
43
  /** Resolve the interaction with a final result. */
43
44
  complete(result: QuestionResult): Effect.Effect<void>;
44
45
  }
45
- >()("inquiry/core/services/Renderer") {}
46
+ >()("@ftrdotdev/pi-inquiry/core/services/Renderer") {}
46
47
 
47
48
  /**
48
49
  * File-reference completion for the inline editor (the `@`-token popup).
@@ -78,4 +79,4 @@ export class FileSuggestions extends Context.Service<
78
79
  prefix: string,
79
80
  ): Effect.Effect<{ readonly text: string; readonly cursor: number }>;
80
81
  }
81
- >()("inquiry/core/services/FileSuggestions") {}
82
+ >()("@ftrdotdev/pi-inquiry/core/services/FileSuggestions") {}
@@ -1,4 +1,6 @@
1
- import { describe, expect, it } from "vitest";
1
+ import { assert, describe, expect, it } from "@effect/vitest";
2
+ import { PROPERTY_RUNS } from "@ftrdotdev/pi-test-kit";
3
+ import { permittedTextArbitrary, widthArbitrary } from "../../test-support/generators.ts";
2
4
  import { charWidth, stripLeadingEmoji, truncateToWidth, visibleWidth, wrapText } from "./text.ts";
3
5
 
4
6
  describe("visibleWidth", () => {
@@ -90,16 +92,6 @@ describe("stripLeadingEmoji", () => {
90
92
  expect(stripLeadingEmoji("⚠️ careful")).toBe("careful");
91
93
  });
92
94
 
93
- it("strips a run of emoji, not just one", () => {
94
- expect(stripLeadingEmoji("➡️ ➡️ twice")).toBe("twice");
95
- });
96
-
97
- it("strips from each line independently", () => {
98
- expect(stripLeadingEmoji("❓ Question?\n\n➡️ Recommended: A.")).toBe(
99
- "Question?\n\nRecommended: A.",
100
- );
101
- });
102
-
103
95
  it("leaves non-emoji prefixes alone", () => {
104
96
  expect(stripLeadingEmoji("→ text")).toBe("→ text");
105
97
  expect(stripLeadingEmoji("• bullet")).toBe("• bullet");
@@ -125,10 +117,6 @@ describe("wrapText", () => {
125
117
  expect(wrapText("one two three", 7)).toEqual(["one two", "three"]);
126
118
  });
127
119
 
128
- it("breaks long words character by character", () => {
129
- expect(wrapText("abcdefghij", 4)).toEqual(["abcd", "efgh", "ij"]);
130
- });
131
-
132
120
  it("trims trailing whitespace", () => {
133
121
  expect(wrapText("one two ", 7)).toEqual(["one two"]);
134
122
  });
@@ -153,3 +141,44 @@ describe("wrapText", () => {
153
141
  expect(wrapText("あああ", 4)).toEqual(["ああ", "あ"]);
154
142
  });
155
143
  });
144
+
145
+ it.prop(
146
+ "truncation stays within the target width",
147
+ { text: permittedTextArbitrary, width: widthArbitrary },
148
+ ({ text, width }) => {
149
+ assert.isAtMost(visibleWidth(truncateToWidth(text, width)), width);
150
+ },
151
+ { arbitrary: { runs: PROPERTY_RUNS } },
152
+ );
153
+
154
+ it.prop(
155
+ "truncation is idempotent",
156
+ { text: permittedTextArbitrary, width: widthArbitrary },
157
+ ({ text, width }) => {
158
+ assert.strictEqual(
159
+ truncateToWidth(truncateToWidth(text, width), width),
160
+ truncateToWidth(text, width),
161
+ );
162
+ },
163
+ { arbitrary: { runs: PROPERTY_RUNS } },
164
+ );
165
+
166
+ it.prop(
167
+ "every wrapped line is within the width",
168
+ { text: permittedTextArbitrary, width: widthArbitrary },
169
+ ({ text, width }) => {
170
+ for (const line of wrapText(text, width)) assert.isAtMost(visibleWidth(line), width);
171
+ },
172
+ { arbitrary: { runs: PROPERTY_RUNS } },
173
+ );
174
+
175
+ it.prop(
176
+ "stripping leading emoji is idempotent and preserves newlines",
177
+ { text: permittedTextArbitrary },
178
+ ({ text }) => {
179
+ const once = stripLeadingEmoji(text);
180
+ assert.strictEqual(stripLeadingEmoji(once), once);
181
+ assert.strictEqual(once.split("\n").length, text.split(/\r\n|\r|\n/).length);
182
+ },
183
+ { arbitrary: { runs: PROPERTY_RUNS } },
184
+ );
package/src/core/text.ts CHANGED
@@ -45,6 +45,13 @@ const graphemeWidth = (segment: string): number => {
45
45
  const isEmoji = (segment: string): boolean => couldBeEmoji(segment) && rgiEmojiRegex.test(segment);
46
46
 
47
47
  /** Width in terminal columns of a single character (code point). */
48
+ /**
49
+ * True when a string carries text. A decoded optional field is
50
+ * `string | undefined`, and the empty string means the same thing: absent.
51
+ */
52
+ export const isNonEmptyString = (value: string | undefined): value is string =>
53
+ value !== undefined && value !== "";
54
+
48
55
  export const charWidth = (ch: string): number => {
49
56
  const cp = ch.codePointAt(0) ?? 0;
50
57
  if (cp === 0x09) return 3; // tab
@@ -0,0 +1,27 @@
1
+ import { expect, it, vi } from "@effect/vitest";
2
+ import { fileURLToPath } from "node:url";
3
+ import { createVitest } from "vitest/node";
4
+
5
+ const PACKAGE_ROOT = fileURLToPath(new URL("..", import.meta.url));
6
+ const PROBE = "PI_HARNESS_PROBE";
7
+
8
+ it("this package resolves the shared policy although a second consumer states no key", async () => {
9
+ const vitest = await createVitest({ root: PACKAGE_ROOT, watch: false });
10
+ try {
11
+ const project = vitest.projects.at(0);
12
+ expect(project?.config.name).toBe("inquiry");
13
+ expect(project?.config.restoreMocks).toBe(true);
14
+ expect(project?.config.unstubEnvs).toBe(true);
15
+ expect(project?.config.unstubGlobals).toBe(true);
16
+ } finally {
17
+ await vitest.close();
18
+ }
19
+ });
20
+
21
+ it("a stubbed environment variable is set for the test that stubs it", () => {
22
+ vi.stubEnv(PROBE, "1");
23
+ });
24
+
25
+ it("a stubbed environment variable is absent in the next test", () => {
26
+ expect(process.env[PROBE]).toBeUndefined();
27
+ });
@@ -10,7 +10,7 @@
10
10
  * editor box and the tui/tracker/preview boxes diverge visually.
11
11
  */
12
12
  import { assert, it } from "@effect/vitest";
13
- import type { Theme } from "@earendil-works/pi-coding-agent";
13
+ import { themeDouble } from "@ftrdotdev/pi-test-kit";
14
14
  import type { Component } from "@earendil-works/pi-tui";
15
15
  import { makeBorderedBox } from "@ftrdotdev/pi-tui";
16
16
  import { buildBoxFrame } from "@ftrdotdev/pi-tui/box-frame";
@@ -18,12 +18,7 @@ import type { EditorState } from "../core/editor.ts";
18
18
  import { buildEditorBox, buildEditorRows } from "../core/scene.ts";
19
19
  import { paintScene } from "./painter.ts";
20
20
 
21
- const identityTheme = {
22
- fg: (_color: string, text: string): string => text,
23
- inverse: (text: string): string => text,
24
- bold: (text: string): string => text,
25
- style: (text: string): string => text,
26
- } as unknown as Theme;
21
+ const identityTheme = themeDouble({ inverse: (text) => text });
27
22
 
28
23
  const THEMED = [
29
24
  { text: "", cursor: 0 },
@@ -1,4 +1,9 @@
1
- import { describe, expect, it } from "vitest";
1
+ import { assert, describe, expect, it } from "@effect/vitest";
2
+ import { PROPERTY_RUNS } from "@ftrdotdev/pi-test-kit";
3
+ import {
4
+ permittedTextArbitrary,
5
+ refusedControlByteArbitrary,
6
+ } from "../../test-support/generators.ts";
2
7
  import { parseKey } from "./keys.ts";
3
8
  import { KeyEvent } from "../core/keyboard.ts";
4
9
 
@@ -57,3 +62,21 @@ describe("parseKey", () => {
57
62
  expect(parseKey("\x1b[1;5C")).toBeNull(); // ctrl+right, unsupported
58
63
  });
59
64
  });
65
+
66
+ it.prop(
67
+ "a bracketed paste of any text parses back to that text",
68
+ { text: permittedTextArbitrary },
69
+ ({ text }) => {
70
+ assert.deepStrictEqual(parseKey(`\x1b[200~${text}\x1b[201~`), KeyEvent.paste(text));
71
+ },
72
+ { arbitrary: { runs: PROPERTY_RUNS } },
73
+ );
74
+
75
+ it.prop(
76
+ "a lone control byte yields no event",
77
+ { byte: refusedControlByteArbitrary },
78
+ ({ byte }) => {
79
+ assert.strictEqual(parseKey(String.fromCharCode(byte)), null);
80
+ },
81
+ { arbitrary: { runs: PROPERTY_RUNS } },
82
+ );
@@ -25,10 +25,10 @@ const paintSpan = (span: Span, theme: Theme): string => {
25
25
  // One `theme.style()` call per span: fg (or the cursor's inverse) and bold
26
26
  // combine into a single SGR wrapper instead of nested fg(bold(text)).
27
27
  if (span.style === "cursor") {
28
- return theme.style(span.text, { inverse: true, bold: span.bold });
28
+ return theme.style(span.text, { inverse: true, bold: span.bold ?? false });
29
29
  }
30
30
  if (span.style !== undefined) {
31
- return theme.style(span.text, { fg: span.style, bold: span.bold });
31
+ return theme.style(span.text, { fg: span.style, bold: span.bold ?? false });
32
32
  }
33
- return span.bold ? theme.bold(span.text) : span.text;
33
+ return (span.bold ?? false) ? theme.bold(span.text) : span.text;
34
34
  };
@@ -1,4 +1,5 @@
1
1
  import { describe, expect, it, vi } from "vitest";
2
+ import { themeDouble } from "@ftrdotdev/pi-test-kit";
2
3
  import type { ExtensionUIContext, Theme } from "@earendil-works/pi-coding-agent";
3
4
  import { KeybindingsManager, TUI_KEYBINDINGS } from "@earendil-works/pi-tui";
4
5
  import { initialMachineState, step, type MachineState } from "../core/machine.ts";
@@ -15,27 +16,26 @@ import {
15
16
  describe("makeSceneRenderer cache", () => {
16
17
  const fixture = (): { state: MachineState; theme: Theme; paints: () => number } => {
17
18
  let count = 0;
18
- const theme = {
19
- fg: (_color: string, text: string): string => {
19
+ const theme = themeDouble({
20
+ fg: (_color, text) => {
20
21
  count++;
21
22
  return text;
22
23
  },
23
- inverse: (text: string): string => {
24
+ inverse: (text) => {
24
25
  count++;
25
26
  return text;
26
27
  },
27
- bold: (text: string): string => text,
28
- style: (text: string): string => {
28
+ style: (text) => {
29
29
  count++;
30
30
  return text;
31
31
  },
32
- } as unknown as Theme;
32
+ });
33
33
  const state = initialMachineState([
34
- new Question({
34
+ Question.make({
35
35
  id: "q1",
36
36
  label: "Q1",
37
37
  prompt: "Pick one?",
38
- options: [new Option({ label: "Yes" }), new Option({ label: "No" })],
38
+ options: [Option.make({ label: "Yes" }), Option.make({ label: "No" })],
39
39
  allowOther: true,
40
40
  multiple: false,
41
41
  }),
@@ -96,10 +96,12 @@ describe("runQuestionUi input routing", () => {
96
96
  const makeFakeUi = (): {
97
97
  ui: ExtensionUIContext;
98
98
  component: () => { handleInput: (data: string) => void };
99
+ customOptions: () => unknown;
99
100
  setToolsExpanded: ReturnType<typeof vi.fn>;
100
101
  } => {
101
102
  let expanded = false;
102
103
  let component: { handleInput: (data: string) => void } | undefined;
104
+ let customOptions: unknown;
103
105
  // Mirror the app's KEYBINDINGS: TUI defaults plus the app.tools.expand
104
106
  // action (default ctrl+o), so `matches` has real semantics.
105
107
  const keybindings = new KeybindingsManager({
@@ -114,7 +116,9 @@ describe("runQuestionUi input routing", () => {
114
116
  injectedKeybindings: unknown,
115
117
  done: () => void,
116
118
  ) => unknown,
119
+ options: unknown,
117
120
  ) => {
121
+ customOptions = options;
118
122
  component = factory({ requestRender: () => {} }, {}, keybindings, () => {}) as {
119
123
  handleInput: (data: string) => void;
120
124
  };
@@ -128,21 +132,46 @@ describe("runQuestionUi input routing", () => {
128
132
  return {
129
133
  ui: ui as unknown as ExtensionUIContext,
130
134
  component: () => component!,
135
+ customOptions: () => customOptions,
131
136
  setToolsExpanded: ui.setToolsExpanded as unknown as ReturnType<typeof vi.fn>,
132
137
  };
133
138
  };
134
139
 
135
140
  const questions = [
136
- new Question({
141
+ Question.make({
137
142
  id: "q1",
138
143
  label: "Q1",
139
144
  prompt: "Pick one?",
140
- options: [new Option({ label: "Yes" })],
145
+ options: [Option.make({ label: "Yes" })],
141
146
  allowOther: true,
142
147
  multiple: false,
143
148
  }),
144
149
  ];
145
150
 
151
+ it("reports blocked program status while a question waits", () => {
152
+ const { ui, customOptions } = makeFakeUi();
153
+ void runQuestionUi(ui, questions, "/tmp");
154
+ expect(customOptions()).toEqual({
155
+ blocked: { kind: "question", message: "Answer the question" },
156
+ });
157
+ });
158
+
159
+ it("uses a count for several questions", () => {
160
+ const { ui, customOptions } = makeFakeUi();
161
+ const second = Question.make({
162
+ id: "q2",
163
+ label: "Q2",
164
+ prompt: "Pick another?",
165
+ options: [Option.make({ label: "Yes" })],
166
+ allowOther: true,
167
+ multiple: false,
168
+ });
169
+ void runQuestionUi(ui, [...questions, second], "/tmp");
170
+ expect(customOptions()).toEqual({
171
+ blocked: { kind: "question", message: "Answer 2 questions" },
172
+ });
173
+ });
174
+
146
175
  it("toggles tool output expansion on ctrl+o while the questionnaire is open", () => {
147
176
  const { ui, component, setToolsExpanded } = makeFakeUi();
148
177
  void runQuestionUi(ui, questions, "/tmp");
@@ -198,11 +227,11 @@ describe("cursor unit conversion", () => {
198
227
 
199
228
  describe("questionClipboardText", () => {
200
229
  const question = (allowOther: boolean): Question =>
201
- new Question({
230
+ Question.make({
202
231
  id: "q1",
203
232
  label: "Q1",
204
233
  prompt: "Pick one?",
205
- options: [new Option({ label: "First" }), new Option({ label: "Second" })],
234
+ options: [Option.make({ label: "First" }), Option.make({ label: "Second" })],
206
235
  allowOther,
207
236
  multiple: false,
208
237
  });
@@ -218,11 +247,14 @@ describe("questionClipboardText", () => {
218
247
  });
219
248
 
220
249
  it("ignores the recommended flag", () => {
221
- const q = new Question({
250
+ const q = Question.make({
222
251
  id: "q1",
223
252
  label: "Q1",
224
253
  prompt: "Pick one?",
225
- options: [new Option({ label: "First", recommended: true }), new Option({ label: "Second" })],
254
+ options: [
255
+ Option.make({ label: "First", recommended: true }),
256
+ Option.make({ label: "Second" }),
257
+ ],
226
258
  allowOther: false,
227
259
  multiple: false,
228
260
  });