feat(pi-ask-user): support RPC UI dialogs

This commit is contained in:
云服务部-叶林立
2026-09-01 11:04:31 +08:00
parent e80959cc3f
commit 44f27f7585
8 changed files with 291 additions and 17 deletions
+8 -5
View File
@@ -4,16 +4,17 @@ A locally maintained Pi extension that consolidates the upstream `question.ts` a
## Tool
The extension registers `ask_user_question`. The model can present one to eight questions in one sequential TUI interaction:
The extension registers `ask_user_question`. The model can present one to eight questions through an interactive Pi UI:
- `select`: one to eight stable `{ value, label, description? }` choices, always followed by a free-form choice that the model cannot disable;
- `text`: a free-form Editor answer;
- `text`: a free-form answer;
- `required: false`: lets the user explicitly skip the question;
- multiple questions: progress tabs plus a final review page.
- TUI mode: one sequential custom interaction with progress tabs and a final review page;
- RPC mode: standard Pi `select` / `input` dialogs shown one question at a time by compatible clients such as Paseo.
The model should call the tool only when a missing decision, preference, or clarification is needed to continue. It should not repeat questions already answered in the user's direct messages.
## Controls
## TUI controls
- `↑` / `↓`: move through choices;
- `Enter`: select, edit, or submit;
@@ -22,6 +23,8 @@ The model should call the tool only when a missing decision, preference, or clar
The outer component propagates focus to the embedded Editor for IME cursor positioning.
RPC clients use their native dialog controls. Dismissing a dialog or aborting the tool returns `cancelled: true`; required blank text is requested again, while optional blank text is recorded as an explicit skip.
## Result contract
Successful results include readable text and structured `details`:
@@ -48,7 +51,7 @@ Successful results include readable text and structured `details`:
The tool name and the `question` / `answer` fields intentionally match `pi-permission-auto-review`'s trusted structured user-interaction envelope. Cancelled results are never treated as authorization evidence.
The tool requires Pi's interactive TUI mode. RPC, JSON, and print modes receive a tool error rather than an invented answer.
The tool requires dialog-capable interactive UI. TUI mode uses the custom questionnaire, RPC mode uses Pi's standard extension UI bridge, and JSON/print modes receive a tool error rather than an invented answer.
## Development