@zhushanwen/pi-ask-user 7.2.3 → 7.2.4

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.
Files changed (2) hide show
  1. package/README.md +6 -4
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -57,7 +57,7 @@ If you recommend an option, prefix its label with `(Recommended)` and list it fi
57
57
  | `questions` | 1-4 entries | schema (`minItems`/`maxItems`) |
58
58
  | `options` | 2-4 entries | schema |
59
59
  | `question` | ≤1000 chars, no control chars (incl. `\n`), unique within the call | schema description + `validate.ts` |
60
- | `header` | ≤12 chars; required when `questions.length > 1` | `validate.ts` (length + non-empty) |
60
+ | `header` | ≤12 chars (always); non-empty and unique when `questions.length > 1` | `validate.ts` (length; non-empty + uniqueness in multi-question mode) |
61
61
  | `options[].label` | non-empty, unique within the question | `validate.ts` |
62
62
 
63
63
  Validation failures make the tool `throw` with a message that names the violation and tells you how to fix it — correct the parameters and retry. (Pi converts a thrown error into an `isError: true` tool result; business outcomes like answers and cancellation are returned normally.)
@@ -80,11 +80,12 @@ A question with no answer reports as `(no answer)`.
80
80
  | No interactive UI (headless) | `throw`, tool **disabled for the session** | Proceed with a defensible decision stated in text, or wait for the user — **do not retry** |
81
81
  | Agent aborted (goal cancelled / context compacted) | `cancelled: true` | The text identifies it as an agent abort, not a user cancel. Do not assume an answer; do not retry ask_user — propagate the abort, or wait for new instructions if the decision is still required. |
82
82
  | User cancels (Esc → confirm, or Cancel button) | `cancelled: true` | Wait for new instructions, or re-ask with refined options if the decision is still required |
83
- | Unexpected error during interaction | `throw` (Pi shows it as `isError: true`) | Retry once with corrected parameters, or proceed with a defensible decision |
83
+ | Unexpected error during interaction (TUI) | `throw` (Pi shows it as `isError: true`) | Tool stays enabled — retry with corrected parameters, or proceed with a defensible decision |
84
+ | Unexpected error during interaction (RPC/GUI) | `throw` + tool **disabled for the session** | Same as the headless row — do not retry |
84
85
 
85
86
  Business outcomes (answers / cancellation) are returned as normal results; only validation failures and unexpected exceptions `throw` — Pi marks a thrown error `isError: true` with empty `details`.
86
87
 
87
- The headless branch physically removes the tool from the session (`setActiveTools`) — this is deliberate, so a function-calling loop cannot keep retrying `ask_user` in a non-interactive context.
88
+ The headless and RPC-failure branches physically remove the tool from the session (`setActiveTools`) — this is deliberate, so a function-calling loop cannot keep retrying `ask_user` in a non-interactive context. The TUI branch does not disable: an interaction failure there is usually transient, so the tool stays enabled for a retry.
88
89
 
89
90
  ## Features
90
91
 
@@ -92,7 +93,7 @@ The headless branch physically removes the tool from the session (`setActiveTool
92
93
  - **Split-pane preview** (≥84 cols): option list left, selected option detail right. The right pane is **plain-text** option detail (label + description), not a Markdown renderer.
93
94
  - **Inline free-text editor**: select "Other" → Enter → type a custom answer. Multi-line aware, soft-wrapped. No comment mode — this editor is the only free-form input.
94
95
  - **Multi-select**: `multiSelect: true` → toggle checkboxes with Space, Enter to confirm.
95
- - **Esc confirm-to-cancel**: Esc on the first question opens a confirm overlay (a second Esc cancels; any other key stays).
96
+ - **Esc confirm-to-cancel**: in options mode, Esc on the first question opens a confirm overlay (a second Esc cancels; any other key stays). Elsewhere Esc means back, not cancel: on later question tabs it steps back one tab, on the Submit tab it returns to the last question, and in the Other editor it saves the draft and returns to the option list.
96
97
  - **Headless-safe**: disables the tool and throws when no UI is available.
97
98
 
98
99
  ## File structure
@@ -104,6 +105,7 @@ extensions/universal/ask-user/
104
105
  ├── README.md # this file — usage contract for LLM callers + overview
105
106
  ├── ARCHITECTURE.md # internals: dependency graph, state machine, defensive flow
106
107
  ├── vitest.config.ts
108
+ ├── tsconfig.json # typecheck config (not in the npm files allowlist)
107
109
  └── src/
108
110
  ├── index.ts # Tool factory: registerTool + execute (6-step defensive flow) + renderCall/renderResult
109
111
  ├── types.ts # Input schema, Result schema, shared state types (QuestionState/ThemeLike) — dependency leaf
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhushanwen/pi-ask-user",
3
- "version": "7.2.3",
3
+ "version": "7.2.4",
4
4
  "description": "Inline adaptive ask_user tool for Pi — single/multi-question structured input with split-pane preview and an inline free-text editor.",
5
5
  "type": "module",
6
6
  "main": "index.ts",