@mrclrchtr/supi-ask-user 5.0.0 → 6.0.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/README.md CHANGED
@@ -99,7 +99,6 @@ The form shows context-specific key hints at the bottom.
99
99
  | Key | Action |
100
100
  |---|---|
101
101
  | `↑` `↓` | Move through choices or review rows; at the first or last row, scroll surrounding content |
102
- | `Page Up` / `Page Down` | Scroll an overflowing choice or review form by one page |
103
102
  | `Alt+Page Up` / `Alt+Page Down` | Scroll the outer form while editing text or comments |
104
103
  | `Space` | Select a single choice or toggle a multi-select option |
105
104
  | `Enter` | Accept an answer, save text or comments, edit a review row, or submit the form |
@@ -110,11 +109,11 @@ The form shows context-specific key hints at the bottom.
110
109
  | `u` / `Alt+U` | Mark the question unanswered (`Alt+U` for text questions) |
111
110
  | `Esc` | Cancel the form; in a comment editor, discard unsaved comment text |
112
111
 
113
- On wide terminals, option details appear beside the choices. On narrow terminals, they appear below the choices. If a form is taller than its inline height limit, Ask User keeps the focused row visible and shows a scroll position indicator.
112
+ On wide terminals, option details appear beside the choices. On narrow terminals, they appear below the choices. Ask User uses up to 85% of the terminal height, capped at 36 rows. If a form is taller than its inline height limit, Ask User keeps the focused row visible and shows a scroll position indicator.
114
113
 
115
114
  ## Requirements, defaults, and limits
116
115
 
117
- - `ask_user` requires Pi's interactive TUI and custom component support. It does not run in RPC, JSON, or print mode.
116
+ - `ask_user` requires Pi's interactive TUI and custom component support. The tool is only registered in TUI sessions and is not offered to the model in RPC, JSON, or print mode.
118
117
  - The package needs no additional binary, service, or API key.
119
118
  - Only one form can be active. The tool uses sequential execution, so sibling tool calls do not run beside a live form.
120
119
  - Cancelling a form cancels the current agent turn. It does not record a user response.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-core",
3
- "version": "5.0.0",
3
+ "version": "6.0.0",
4
4
  "description": "Shared settings, configuration, reporting, and session infrastructure",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -53,7 +53,7 @@
53
53
  "./api": "./src/api.ts",
54
54
  "./config": "./src/config.ts",
55
55
  "./context": "./src/context.ts",
56
- "./debug": "./src/debug-registry.ts",
56
+ "./debug": "./src/debug.ts",
57
57
  "./evidence-badge": "./src/evidence-badge.ts",
58
58
  "./footer-registry": "./src/footer-registry.ts",
59
59
  "./llm": "./src/llm.ts",
@@ -11,7 +11,7 @@ export * from "./config.ts";
11
11
  // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
12
12
  export * from "./context.ts";
13
13
  // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
14
- export * from "./debug-registry.ts";
14
+ export * from "./debug.ts";
15
15
  // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
16
16
  export * from "./evidence-badge.ts";
17
17
  // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
@@ -4,9 +4,6 @@
4
4
  // supi-debug extension owns policy/configuration and exposes events through a
5
5
  // command/tool while this module stays dependency-free for producers.
6
6
 
7
- // biome-ignore lint/performance/noReExportAll: preserve the stable debug domain entry point
8
- export * from "./debug-timing.ts";
9
-
10
7
  export type DebugLevel = "debug" | "info" | "warning" | "error";
11
8
  export type DebugAgentAccess = "off" | "sanitized" | "raw";
12
9
  export interface DebugRegistryConfig {
@@ -0,0 +1,9 @@
1
+ // Debug domain entry for `@mrclrchtr/supi-core/debug`.
2
+ //
3
+ // Kept separate from debug-registry.ts so debug-timing.ts can import the
4
+ // registry without creating an import cycle through the barrel re-export.
5
+
6
+ // biome-ignore lint/performance/noReExportAll: preserve the stable debug domain entry point
7
+ export * from "./debug-registry.ts";
8
+ // biome-ignore lint/performance/noReExportAll: preserve the stable debug domain entry point
9
+ export * from "./debug-timing.ts";
@@ -11,7 +11,7 @@ export * from "./config.ts";
11
11
  // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
12
12
  export * from "./context.ts";
13
13
  // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
14
- export * from "./debug-registry.ts";
14
+ export * from "./debug.ts";
15
15
  // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
16
16
  export * from "./footer-registry.ts";
17
17
  // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-ask-user",
3
- "version": "5.0.0",
3
+ "version": "6.0.0",
4
4
  "description": "Structured choice and text forms for agent-user decisions",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -32,7 +32,7 @@
32
32
  "!__tests__"
33
33
  ],
34
34
  "dependencies": {
35
- "@mrclrchtr/supi-core": "5.0.0"
35
+ "@mrclrchtr/supi-core": "6.0.0"
36
36
  },
37
37
  "bundledDependencies": [
38
38
  "@mrclrchtr/supi-core"
package/src/ask-user.ts CHANGED
@@ -1,40 +1,13 @@
1
- import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
1
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
2
  import {
3
3
  notifyToolPromptSurfaceDiagnostics,
4
4
  resolveToolPromptSurface,
5
5
  } from "@mrclrchtr/supi-core/prompt-surface";
6
6
  import { createSessionNameTracker } from "@mrclrchtr/supi-core/session";
7
- import { formatTitle, signalWaiting } from "@mrclrchtr/supi-core/terminal";
8
- import { AskUserValidationError, normalizeQuestionnaire } from "./normalize.ts";
9
- import { type AskUserToolResult, buildResult } from "./render/result.ts";
10
- import { renderAskUserCall, renderAskUserResult } from "./render/transcript.ts";
11
- import { type AskUserParams, AskUserParamsSchema } from "./schema.ts";
12
7
  import { ActiveQuestionnaireLock } from "./session/lock.ts";
13
- import {
14
- ASK_USER_PROMPT_SURFACE_DEFAULTS,
15
- ASK_USER_TOOL_LABEL,
16
- ASK_USER_TOOL_NAME,
17
- } from "./tool/guidance.ts";
18
- import type {
19
- AskUserInteractionResult,
20
- AskUserOutcome,
21
- AskUserToolDetails,
22
- NormalizedQuestionnaire,
23
- } from "./types.ts";
24
- import { runQuestionnaire } from "./ui/choose-renderer.ts";
25
- import type { EditorFactory } from "./ui/types.ts";
26
-
27
- export type AskUserExecutionContext = Pick<ExtensionContext, "cwd" | "hasUI" | "mode" | "abort"> & {
28
- ui: {
29
- custom?: unknown;
30
- notify?(message: string, type?: "info" | "warning" | "error"): void;
31
- setWorkingVisible?(visible: boolean): void;
32
- setTitle?(title: string): void;
33
- getToolsExpanded?(): boolean;
34
- setToolsExpanded?(expanded: boolean): void;
35
- getEditorComponent?(): EditorFactory | undefined;
36
- };
37
- };
8
+ import { ASK_USER_PROMPT_SURFACE_DEFAULTS } from "./tool/ask_user/guidance.ts";
9
+ import { registerAskUserTool } from "./tool/ask_user/register.ts";
10
+ import { ASK_USER_TOOL_NAME } from "./tool/ask_user/spec.ts";
38
11
 
39
12
  export default function askUserExtension(pi: ExtensionAPI): void {
40
13
  const lock = new ActiveQuestionnaireLock();
@@ -63,10 +36,12 @@ export default function askUserExtension(pi: ExtensionAPI): void {
63
36
  }, 0);
64
37
  });
65
38
 
66
- // Factory-time: register with package defaults.
67
- registerAskUserTool(pi, lock, ASK_USER_PROMPT_SURFACE_DEFAULTS, getSessionName);
68
-
69
- // session_start: re-register with resolved prompt surface (global + trusted project config).
39
+ // Register ask_user only for interactive TUI sessions: the form UI has no
40
+ // degraded fallback, so the tool must not be offered in RPC, JSON, or print
41
+ // modes. The run mode is only available on the event context, not at
42
+ // extension factory time, so registration happens on session_start instead
43
+ // of eagerly at load. Config diagnostics stay mode-independent and are
44
+ // still reported so misconfigured prompt surfaces surface in every mode.
70
45
  pi.on("session_start", async (_event, ctx) => {
71
46
  const { surface, diagnostics } = resolveToolPromptSurface({
72
47
  section: "ask-user",
@@ -74,136 +49,18 @@ export default function askUserExtension(pi: ExtensionAPI): void {
74
49
  defaults: ASK_USER_PROMPT_SURFACE_DEFAULTS,
75
50
  ctx,
76
51
  });
77
-
78
- registerAskUserTool(pi, lock, surface, getSessionName);
79
52
  notifyToolPromptSurfaceDiagnostics(ctx, diagnostics);
80
- });
81
- }
82
53
 
83
- function registerAskUserTool(
84
- pi: ExtensionAPI,
85
- lock: ActiveQuestionnaireLock,
86
- surface: typeof ASK_USER_PROMPT_SURFACE_DEFAULTS,
87
- getSessionName: () => string | undefined,
88
- ): void {
89
- pi.registerTool<typeof AskUserParamsSchema, AskUserToolDetails>({
90
- name: ASK_USER_TOOL_NAME,
91
- label: ASK_USER_TOOL_LABEL,
92
- description: surface.description,
93
- promptSnippet: surface.promptSnippet,
94
- promptGuidelines: surface.promptGuidelines,
95
- parameters: AskUserParamsSchema,
96
- executionMode: "sequential",
97
- // biome-ignore lint/complexity/useMaxParams: pi ToolDefinition.execute signature
98
- async execute(_toolCallId, params, signal, _onUpdate, ctx) {
99
- return executeAskUser(params, signal, ctx, lock, pi, getSessionName());
100
- },
101
- renderCall: (args, theme) => renderAskUserCall(args, theme),
102
- renderResult: (result, options, theme, context) =>
103
- renderAskUserResult(result, theme, options, context),
104
- });
105
- }
106
-
107
- // biome-ignore lint/complexity/useMaxParams: keep the execution boundary explicit for tests
108
- export async function executeAskUser(
109
- params: AskUserParams,
110
- signal: AbortSignal | undefined,
111
- ctx: AskUserExecutionContext,
112
- lock: ActiveQuestionnaireLock,
113
- pi: ExtensionAPI,
114
- sessionName?: string,
115
- ): Promise<AskUserToolResult> {
116
- let questionnaire: NormalizedQuestionnaire;
117
- try {
118
- questionnaire = normalizeQuestionnaire(params);
119
- } catch (error) {
120
- if (error instanceof AskUserValidationError) {
121
- throw new Error(error.message, { cause: error });
122
- }
123
- throw error;
124
- }
125
-
126
- if (!ctx.hasUI || ctx.mode !== "tui") {
127
- throw new Error(
128
- "ask_user requires an interactive TUI session. No user-facing form UI is available in the current mode.",
129
- );
130
- }
131
- if (!lock.acquire()) {
132
- throw new Error(
133
- "another ask_user form is already in flight. Wait for it to complete before calling ask_user again.",
134
- );
135
- }
136
-
137
- signalAttention(ctx);
138
- pi.events.emit("supi:ask-user:start", { source: "supi-ask-user" });
139
-
140
- try {
141
- ctx.ui.setWorkingVisible?.(false);
142
- const outcome = await runQuestionnaire(questionnaire, {
143
- ui: {
144
- custom: asFunction(ctx.ui.custom),
145
- notify: ctx.ui.notify,
146
- getEditorComponent: ctx.ui.getEditorComponent
147
- ? () => ctx.ui.getEditorComponent?.()
148
- : undefined,
149
- },
150
- signal,
151
- onToggleToolsExpanded:
152
- ctx.ui.getToolsExpanded && ctx.ui.setToolsExpanded
153
- ? () => ctx.ui.setToolsExpanded?.(!ctx.ui.getToolsExpanded?.())
154
- : undefined,
155
- });
54
+ if (ctx.mode !== "tui") return;
156
55
 
157
- if (outcome === "unsupported") {
158
- throw new Error(
159
- "ask_user requires a TUI with custom form support. Do not use ask_user in non-interactive or degraded UI sessions.",
160
- );
161
- }
162
-
163
- // Internal cancel/abort: treat as control flow, abort the turn, and mark the tool failed.
164
- if (isInternalInteractionResult(outcome)) {
165
- ctx.abort();
166
- throw new Error("The user interaction was cancelled.");
167
- }
168
-
169
- pi.appendEntry("ask_user", {
170
- title: questionnaire.title,
171
- questions: questionnaire.questions.length,
172
- });
173
- return buildResult(questionnaire, outcome);
174
- } finally {
175
- ctx.ui.setWorkingVisible?.(true);
176
- pi.events.emit("supi:ask-user:end", { source: "supi-ask-user" });
177
- restoreTerminalTitle(ctx, sessionName);
178
- lock.release();
179
- }
180
- }
181
-
182
- function isInternalInteractionResult(
183
- outcome: AskUserOutcome | AskUserInteractionResult | "unsupported",
184
- ): outcome is AskUserInteractionResult {
185
- return (
186
- typeof outcome === "object" &&
187
- "kind" in outcome &&
188
- (outcome.kind === "cancel" || outcome.kind === "abort")
189
- );
190
- }
191
-
192
- function signalAttention(ctx: AskUserExecutionContext): void {
193
- signalWaiting(ctx, "pi — waiting for your input");
194
- }
195
-
196
- function restoreTerminalTitle(ctx: AskUserExecutionContext, sessionName: string | undefined): void {
197
- ctx.ui.setTitle?.(formatTitle(sessionName, ctx.cwd));
198
- }
199
-
200
- function asFunction<T extends (...args: never[]) => unknown>(value: unknown): T | undefined {
201
- return typeof value === "function" ? (value as T) : undefined;
56
+ registerAskUserTool(pi, lock, surface, getSessionName);
57
+ });
202
58
  }
203
59
 
204
60
  export { AskUserValidationError, normalizeQuestionnaire } from "./normalize.ts";
205
61
  export { AskUserController } from "./session/controller.ts";
62
+ export { type AskUserExecutionContext, executeAskUser } from "./tool/ask_user/execute.ts";
206
63
  export {
207
64
  promptGuidelines as askUserPromptGuidelines,
208
65
  promptSnippet as askUserPromptSnippet,
209
- } from "./tool/guidance.ts";
66
+ } from "./tool/ask_user/guidance.ts";
package/src/schema.ts CHANGED
@@ -34,7 +34,7 @@ const ChoiceQuestionSchema = Type.Object({
34
34
  header: Type.String({ description: "Short label" }),
35
35
  prompt: Type.String({ description: "Question text" }),
36
36
  options: Type.Array(OptionSchema, {
37
- description: "Allowed options with unique values",
37
+ description: "Each option requires `label` (shown text) and a unique `value` (returned id).",
38
38
  ...ChoiceOptionCount,
39
39
  }),
40
40
  multi: Type.Optional(
@@ -0,0 +1,122 @@
1
+ import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
2
+ import { formatTitle, signalWaiting } from "@mrclrchtr/supi-core/terminal";
3
+ import { AskUserValidationError, normalizeQuestionnaire } from "../../normalize.ts";
4
+ import type { AskUserParams } from "../../schema.ts";
5
+ import type { ActiveQuestionnaireLock } from "../../session/lock.ts";
6
+ import type {
7
+ AskUserInteractionResult,
8
+ AskUserOutcome,
9
+ NormalizedQuestionnaire,
10
+ } from "../../types.ts";
11
+ import { runQuestionnaire } from "../../ui/choose-renderer.ts";
12
+ import type { EditorFactory } from "../../ui/types.ts";
13
+ import { type AskUserToolResult, buildResult } from "./result.ts";
14
+
15
+ export type AskUserExecutionContext = Pick<ExtensionContext, "cwd" | "hasUI" | "mode" | "abort"> & {
16
+ ui: {
17
+ custom?: unknown;
18
+ notify?(message: string, type?: "info" | "warning" | "error"): void;
19
+ setWorkingVisible?(visible: boolean): void;
20
+ setTitle?(title: string): void;
21
+ getToolsExpanded?(): boolean;
22
+ setToolsExpanded?(expanded: boolean): void;
23
+ getEditorComponent?(): EditorFactory | undefined;
24
+ };
25
+ };
26
+
27
+ // biome-ignore lint/complexity/useMaxParams: keep the execution boundary explicit for tests
28
+ export async function executeAskUser(
29
+ params: AskUserParams,
30
+ signal: AbortSignal | undefined,
31
+ ctx: AskUserExecutionContext,
32
+ lock: ActiveQuestionnaireLock,
33
+ pi: ExtensionAPI,
34
+ sessionName?: string,
35
+ ): Promise<AskUserToolResult> {
36
+ let questionnaire: NormalizedQuestionnaire;
37
+ try {
38
+ questionnaire = normalizeQuestionnaire(params);
39
+ } catch (error) {
40
+ if (error instanceof AskUserValidationError) {
41
+ throw new Error(error.message, { cause: error });
42
+ }
43
+ throw error;
44
+ }
45
+
46
+ if (!ctx.hasUI || ctx.mode !== "tui") {
47
+ throw new Error(
48
+ "ask_user requires an interactive TUI session. No user-facing form UI is available in the current mode.",
49
+ );
50
+ }
51
+ if (!lock.acquire()) {
52
+ throw new Error(
53
+ "another ask_user form is already in flight. Wait for it to complete before calling ask_user again.",
54
+ );
55
+ }
56
+
57
+ signalAttention(ctx);
58
+ pi.events.emit("supi:ask-user:start", { source: "supi-ask-user" });
59
+
60
+ try {
61
+ ctx.ui.setWorkingVisible?.(false);
62
+ const outcome = await runQuestionnaire(questionnaire, {
63
+ ui: {
64
+ custom: asFunction(ctx.ui.custom),
65
+ notify: ctx.ui.notify,
66
+ getEditorComponent: ctx.ui.getEditorComponent
67
+ ? () => ctx.ui.getEditorComponent?.()
68
+ : undefined,
69
+ },
70
+ signal,
71
+ onToggleToolsExpanded:
72
+ ctx.ui.getToolsExpanded && ctx.ui.setToolsExpanded
73
+ ? () => ctx.ui.setToolsExpanded?.(!ctx.ui.getToolsExpanded?.())
74
+ : undefined,
75
+ });
76
+
77
+ if (outcome === "unsupported") {
78
+ throw new Error(
79
+ "ask_user requires a TUI with custom form support. Do not use ask_user in non-interactive or degraded UI sessions.",
80
+ );
81
+ }
82
+
83
+ // Internal cancel/abort: treat as control flow, abort the turn, and mark the tool failed.
84
+ if (isInternalInteractionResult(outcome)) {
85
+ ctx.abort();
86
+ throw new Error("The user interaction was cancelled.");
87
+ }
88
+
89
+ pi.appendEntry("ask_user", {
90
+ title: questionnaire.title,
91
+ questions: questionnaire.questions.length,
92
+ });
93
+ return buildResult(questionnaire, outcome);
94
+ } finally {
95
+ ctx.ui.setWorkingVisible?.(true);
96
+ pi.events.emit("supi:ask-user:end", { source: "supi-ask-user" });
97
+ restoreTerminalTitle(ctx, sessionName);
98
+ lock.release();
99
+ }
100
+ }
101
+
102
+ function isInternalInteractionResult(
103
+ outcome: AskUserOutcome | AskUserInteractionResult | "unsupported",
104
+ ): outcome is AskUserInteractionResult {
105
+ return (
106
+ typeof outcome === "object" &&
107
+ "kind" in outcome &&
108
+ (outcome.kind === "cancel" || outcome.kind === "abort")
109
+ );
110
+ }
111
+
112
+ function signalAttention(ctx: AskUserExecutionContext): void {
113
+ signalWaiting(ctx, "pi — waiting for your input");
114
+ }
115
+
116
+ function restoreTerminalTitle(ctx: AskUserExecutionContext, sessionName: string | undefined): void {
117
+ ctx.ui.setTitle?.(formatTitle(sessionName, ctx.cwd));
118
+ }
119
+
120
+ function asFunction<T extends (...args: never[]) => unknown>(value: unknown): T | undefined {
121
+ return typeof value === "function" ? (value as T) : undefined;
122
+ }
@@ -2,9 +2,6 @@
2
2
 
3
3
  import { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize } from "@earendil-works/pi-coding-agent";
4
4
 
5
- export const ASK_USER_TOOL_NAME = "ask_user";
6
- export const ASK_USER_TOOL_LABEL = "Ask User";
7
-
8
5
  export const toolDescription = `Open a blocking interactive TUI decision form for focused user input. Supports 1-10 choice/text questions, one active form, and sequential execution; requires TUI custom UI. Result text is truncated to ${DEFAULT_MAX_LINES} lines or ${formatSize(DEFAULT_MAX_BYTES)}.`;
9
6
 
10
7
  export const promptSnippet = "ask_user — request a focused blocking user decision";
@@ -0,0 +1,33 @@
1
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
+ import type { AskUserParamsSchema } from "../../schema.ts";
3
+ import type { ActiveQuestionnaireLock } from "../../session/lock.ts";
4
+ import type { AskUserToolDetails } from "../../types.ts";
5
+ import { executeAskUser } from "./execute.ts";
6
+ import type { ASK_USER_PROMPT_SURFACE_DEFAULTS } from "./guidance.ts";
7
+ import { renderAskUserCall, renderAskUserResult } from "./render.ts";
8
+ import { askUserSpec } from "./spec.ts";
9
+
10
+ /** Shape of the configurable ask_user prompt surface. */
11
+ export type AskUserPromptSurface = typeof ASK_USER_PROMPT_SURFACE_DEFAULTS;
12
+
13
+ /** Register ask_user with one resolved prompt surface. */
14
+ export function registerAskUserTool(
15
+ pi: ExtensionAPI,
16
+ lock: ActiveQuestionnaireLock,
17
+ surface: AskUserPromptSurface,
18
+ getSessionName: () => string | undefined,
19
+ ): void {
20
+ pi.registerTool<typeof AskUserParamsSchema, AskUserToolDetails>({
21
+ ...askUserSpec,
22
+ description: surface.description,
23
+ promptSnippet: surface.promptSnippet,
24
+ promptGuidelines: surface.promptGuidelines,
25
+ // biome-ignore lint/complexity/useMaxParams: pi ToolDefinition.execute signature
26
+ async execute(_toolCallId, params, signal, _onUpdate, ctx) {
27
+ return executeAskUser(params, signal, ctx, lock, pi, getSessionName());
28
+ },
29
+ renderCall: (args, theme) => renderAskUserCall(args, theme),
30
+ renderResult: (result, options, theme, context) =>
31
+ renderAskUserResult(result, theme, options, context),
32
+ });
33
+ }
@@ -1,15 +1,15 @@
1
1
  import { type AgentToolResult, keyText, type Theme } from "@earendil-works/pi-coding-agent";
2
2
  import { Text } from "@earendil-works/pi-tui";
3
- import type { AskUserParams } from "../schema.ts";
4
- import { ASK_USER_TOOL_NAME } from "../tool/guidance.ts";
3
+ import type { AskUserParams } from "../../schema.ts";
5
4
  import type {
6
5
  AskUserDetails,
7
6
  AskUserOutcomeKind,
8
7
  AskUserResponse,
9
8
  AskUserToolDetails,
10
9
  NormalizedQuestion,
11
- } from "../types.ts";
12
- import { isErrorDetails } from "../types.ts";
10
+ } from "../../types.ts";
11
+ import { isErrorDetails } from "../../types.ts";
12
+ import { ASK_USER_TOOL_NAME } from "./spec.ts";
13
13
 
14
14
  const COLLAPSED_ANSWER_LIMIT = 2;
15
15
  const DEFAULT_REVIEW_KEY = "Ctrl+O";
@@ -14,7 +14,7 @@ import type {
14
14
  ChoiceQuestionResponse,
15
15
  NormalizedQuestion,
16
16
  NormalizedQuestionnaire,
17
- } from "../types.ts";
17
+ } from "../../types.ts";
18
18
 
19
19
  export type AskUserToolResult = AgentToolResult<AskUserToolDetails>;
20
20
 
@@ -0,0 +1,12 @@
1
+ import { AskUserParamsSchema } from "../../schema.ts";
2
+
3
+ export const ASK_USER_TOOL_NAME = "ask_user";
4
+ export const ASK_USER_TOOL_LABEL = "Ask User";
5
+
6
+ /** Canonical provider-facing metadata for the ask_user tool. */
7
+ export const askUserSpec = {
8
+ name: ASK_USER_TOOL_NAME,
9
+ label: ASK_USER_TOOL_LABEL,
10
+ parameters: AskUserParamsSchema,
11
+ executionMode: "sequential",
12
+ } as const;
@@ -283,7 +283,7 @@ function renderScrollIndicator(
283
283
  }
284
284
 
285
285
  function scrollHint(args: RenderFormFrameArgs): string {
286
- return args.focus === "editor" ? "Alt+PgUp/PgDn" : "PgUp/PgDn";
286
+ return args.focus === "editor" ? "Alt+PgUp/PgDn" : "↑↓";
287
287
  }
288
288
 
289
289
  function frameLines(theme: Theme, content: string[], width: number): string[] {
@@ -1,6 +1,6 @@
1
1
  /** Maximum number of terminal rows used by the inline Ask User form. */
2
- const MAX_FORM_HEIGHT = 24;
3
- const TERMINAL_HEIGHT_SHARE = 0.7;
2
+ const MAX_FORM_HEIGHT = 36;
3
+ const TERMINAL_HEIGHT_SHARE = 0.85;
4
4
 
5
5
  /** A zero-based, end-exclusive range in rendered form content. */
6
6
  export interface FormLineRange {
@@ -25,9 +25,9 @@ export interface FormViewportLayout {
25
25
  }
26
26
 
27
27
  /**
28
- * Calculate a conservative inline height that leaves room for Pi's transcript and footer.
29
- * The absolute cap keeps the form stable on large terminals, while the terminal share
30
- * keeps it usable on small terminals.
28
+ * Calculate the inline height budget for an active form. The form may take most of the
29
+ * terminal while a decision is pending. The absolute cap keeps the form stable on large
30
+ * terminals, while the terminal share keeps it usable on small terminals.
31
31
  */
32
32
  export function calculateFormHeightLimit(terminalRows: number): number {
33
33
  const rows = Math.max(1, Math.floor(terminalRows));