|
18 | 18 | * - Esc to cancel |
19 | 19 | */ |
20 | 20 |
|
21 | | -import type { ExtensionAPI } from "@mariozechner/pi-coding-agent"; |
22 | | -import { Editor, type EditorTheme, Key, matchesKey, Text, truncateToWidth, visibleWidth } from "@mariozechner/pi-tui"; |
| 21 | +import type { ExtensionAPI } from "@earendil-works/pi-coding-agent"; |
| 22 | +import { Editor, type EditorTheme, Key, matchesKey, Text, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui"; |
23 | 23 | import { Type } from "@sinclair/typebox"; |
24 | 24 |
|
25 | 25 | // ─── Types ─────────────────────────────────────────────────────────────────── |
@@ -63,6 +63,12 @@ interface FormResult { |
63 | 63 | cancelled: boolean; |
64 | 64 | } |
65 | 65 |
|
| 66 | +interface AskUserQuestionInput { |
| 67 | + title?: string; |
| 68 | + description?: string; |
| 69 | + questions: Question[]; |
| 70 | +} |
| 71 | + |
66 | 72 | // ─── Schema ────────────────────────────────────────────────────────────────── |
67 | 73 |
|
68 | 74 | const OptionSchema = Type.Object({ |
@@ -182,11 +188,12 @@ Use this tool when you need user input to proceed — for clarifying requirement |
182 | 188 | if (!ctx.hasUI) { |
183 | 189 | return errorResult("Error: UI not available (running in non-interactive mode)"); |
184 | 190 | } |
185 | | - if (!params.questions.length) { |
| 191 | + const input = params as AskUserQuestionInput; |
| 192 | + if (!input.questions.length) { |
186 | 193 | return errorResult("Error: No questions provided"); |
187 | 194 | } |
188 | 195 |
|
189 | | - const questions = normalize(params.questions as Question[]); |
| 196 | + const questions = normalize(input.questions); |
190 | 197 | const isMulti = questions.length > 1; |
191 | 198 | const totalTabs = questions.length + (isMulti ? 1 : 0); // +1 for Submit tab |
192 | 199 |
|
@@ -344,7 +351,7 @@ Use this tool when you need user input to proceed — for clarifying requirement |
344 | 351 | answers.push({ id: q.id, type: "text", value: t, wasCustom: true }); |
345 | 352 | } |
346 | 353 | } |
347 | | - done({ title: params.title, questions, answers, cancelled }); |
| 354 | + done({ title: input.title, questions, answers, cancelled }); |
348 | 355 | } |
349 | 356 |
|
350 | 357 | // ── Editor submit (for "Other" mode) ──────────────────── |
@@ -549,13 +556,13 @@ Use this tool when you need user input to proceed — for clarifying requirement |
549 | 556 | hr(); |
550 | 557 |
|
551 | 558 | // Title & description |
552 | | - if (params.title) { |
553 | | - add(` ${theme.fg("accent", theme.bold(params.title))}`); |
| 559 | + if (input.title) { |
| 560 | + add(` ${theme.fg("accent", theme.bold(input.title))}`); |
554 | 561 | } |
555 | | - if (params.description) { |
556 | | - add(` ${theme.fg("muted", params.description)}`); |
| 562 | + if (input.description) { |
| 563 | + add(` ${theme.fg("muted", input.description)}`); |
557 | 564 | } |
558 | | - if (params.title || params.description) lines.push(""); |
| 565 | + if (input.title || input.description) lines.push(""); |
559 | 566 |
|
560 | 567 | // Tab bar (multi-question) |
561 | 568 | if (isMulti) { |
@@ -876,8 +883,9 @@ Use this tool when you need user input to proceed — for clarifying requirement |
876 | 883 | // ── Custom rendering ───────────────────────────────────────────── |
877 | 884 |
|
878 | 885 | renderCall(args, theme, _context) { |
879 | | - const qs = (args.questions as Question[]) || []; |
880 | | - const title = args.title as string | undefined; |
| 886 | + const input = args as Partial<AskUserQuestionInput>; |
| 887 | + const qs = input.questions || []; |
| 888 | + const title = input.title; |
881 | 889 | let text = theme.fg("toolTitle", theme.bold("ask_user_question ")); |
882 | 890 | if (title) { |
883 | 891 | text += theme.fg("accent", title) + " "; |
|
0 commit comments