mirror of
https://bitbucket.org/siakitem/my-pi.git
synced 2026-10-26 10:45:22 +00:00
64 lines
2.5 KiB
Markdown
64 lines
2.5 KiB
Markdown
# pi-ask-user
|
|
|
|
A locally maintained Pi extension that consolidates the upstream `question.ts` and `questionnaire.ts` examples into one model-initiated tool. It intentionally does not include the `/qna` command.
|
|
|
|
## Tool
|
|
|
|
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 answer;
|
|
- `required: false`: lets the user explicitly skip the question;
|
|
- 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.
|
|
|
|
## TUI controls
|
|
|
|
- `↑` / `↓`: move through choices;
|
|
- `Enter`: select, edit, or submit;
|
|
- `Tab`, `Shift+Tab`, `←`, `→`: move between questions and review;
|
|
- `Esc`: leave text entry, or cancel from a question/review page.
|
|
|
|
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`:
|
|
|
|
```json
|
|
{
|
|
"version": 1,
|
|
"cancelled": false,
|
|
"questions": [],
|
|
"answers": [
|
|
{
|
|
"id": "language",
|
|
"question": "Which language should be used?",
|
|
"type": "select",
|
|
"answer": "TypeScript",
|
|
"value": "typescript",
|
|
"label": "TypeScript",
|
|
"custom": false,
|
|
"skipped": false
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
The tool name and the `question` / `answer` fields intentionally match `pi-permission-system`'s integrated AutoReview trusted structured user-interaction envelope. Cancelled results are never treated as authorization evidence.
|
|
|
|
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
|
|
|
|
```sh
|
|
npm test
|
|
npm run check
|
|
```
|
|
|
|
See `UPSTREAM.md` for the imported reference snapshot and local differences.
|