A standalone ask_user tool for Pi. It lets the model ask one multiple-choice question in the TUI while always preserving a free-form answer path.
- Accepts exactly 2–5 model-provided options, each with a nonblank, unique effective label and optional description. Questions must also remain nonblank after display-text sanitization.
- Appends Write my own answer… automatically.
- Uses Pi's configured
tui.select.up,tui.select.down,tui.select.confirm, andtui.select.cancelkeybindings. Number keys remain direct-selection shortcuts. - Opens an inline editor for a custom answer. Blank submissions and the configured cancel key return to the options; nonblank answers are trimmed and submitted.
- Runs tool calls sequentially so multiple questions cannot open competing interactive views.
- Defers the question while a fleet, terminal inspector, or other overlay is open, leaving that topmost window in control until it closes.
- Treats an aborted tool signal as cancellation and removes its listener whenever the view settles or is disposed.
- Wraps ANSI-styled text by terminal display width, including CJK and emoji, and safely rerenders when the TUI width changes (including fullscreen mode).
- Removes terminal escape sequences, unsafe control characters, and bidirectional overrides from model-provided display text.
- Requests strict JSON Schema constrained sampling when the active model supports it, while falling back normally on models that do not.
- In non-TUI modes, tells the model that no interactive UI is available and to ask in plain text.
- Returns structured details containing the question, option labels, answer, selected option index, whether it was custom, and whether the interaction was cancelled or dismissed.
The tool prompt encourages Pi to use ask_user for enumerable choices and to ask only one question per call.
Install from npm:
pi install npm:@inv1x/pi-ask-userFor local development, install this checkout persistently so /reload can rediscover it:
npm install
pi install /absolute/path/to/pi-ask-userUse pi -e . only for a temporary development smoke test. You can also add the absolute package path to Pi's package settings.
The current release is developed and tested against Pi 0.84.1 (the tested minimum) and Node.js 22.19 or newer. Pi-bundled runtime modules (@earendil-works/pi-coding-agent, @earendil-works/pi-tui, and typebox) remain unbundled peer dependencies so the extension uses the host Pi runtime.
npm install
npm run format
npm run check
npm run typecheck
npm test
npm pack --dry-runnpm pack runs the same check, typecheck, and test quality gate automatically through prepack.
Run npm run changeset for each user-facing change and commit the generated .changeset/*.md file. To prepare a release, run npm run release:status and then npm run release:version; Changesets consumes the pending files and updates package.json, package-lock.json, and CHANGELOG.md. These commands do not publish to npm or create a GitHub Release.
Behavior and UI are based on the ask-user extension from davis7dotsh/my-pi-setup.
MIT