Pi ask-user-question #
Pi extension that lets the model ask free-form questions, then blocks that model turn until the user finishes a multiline answer.
The question remains fully visible in Pi's transcript. The answer opens in the configured editor inside a separate default-terminal window, so Pi keeps its normal transcript controls while the answer is pending.
Installation #
Build the package,
then add its repository path to global Pi settings at ~/.pi/agent/settings.json:
{
"packages": [
"/var/home/user/Monochromatic/package/pi-plugin/ask-user-question"
]
}
The extension is user-specific.
Do not add it to project .pi/settings.json.
Tool #
The extension registers ask_user_question with one parameter:
ask_user_question({
question: string,
})
The complete question is rendered in the Pi transcript without a line-count preview. The tool is sequential, so Pi does not open competing answer windows for sibling calls.
The tool works only in interactive TUI mode. RPC, JSON, and print modes receive an unavailable-tool error rather than opening a desktop terminal.
Answer workflow #
The extension resolves the preferred terminal through
@monochromatic-dev/cli-terminal-exec.
It resolves the editor in this order:
editorin~/.pi/agent/extensions/pi-ask-user-question.json$VISUAL$EDITORnotepad.exeon Windows orvielsewhere
The user-level JSON config accepts an editor executable with optional quoted arguments:
{
"editor": "nano"
}
Unknown keys,
blank commands,
and unsupported shell syntax fail extension startup with the config path in the diagnostic.
The editor command must remain attached until editing finishes.
For graphical editors,
configure a wait flag such as code --wait.
When terminal-exec resolves Ghostty and the effective editor is hx or helix,
the extension emits a warning-level logger message about intermittent Escape handling.
Choose another editor through the user-level config to avoid that pairing.
The editor opens an empty, answer-only UTF-8 file. The question stays in Pi, where scrolling, search, tool expansion, selection, copying, and links remain available.
Save and exit to submit.
In Nano,
use Ctrl+O,
Enter,
then Ctrl+X.
In Helix,
Vim,
and Neovim,
use :wq.
The launched terminal title gives an editor-neutral save-and-exit reminder.
An empty or whitespace-only file cancels.
A nonzero editor exit,
a closed answer terminal,
or a disconnected helper also cancels.
The returned answer removes at most one final \n or \r\n added by the editor.
Every other character and line break is preserved.
Answers are ordinary, non-secret model input. Do not enter passwords, tokens, or credentials.
Blocking and cleanup #
A private request file transfers a random channel token and loopback endpoint to the detached helper. The helper authenticates immediately, then keeps the channel open for the editor lifetime. The Pi tool awaits that channel, which blocks the model without taking input focus from the original Pi terminal.
Before opening the terminal, the extension copies its self-contained helper into the private request workspace. Replacing the installed helper after that point cannot remove the pending launch target. On Linux, it uses the live Pi executable through procfs to survive removal of the original runtime path. Other platforms and systems without accessible procfs use a checked original runtime path. Missing launch inputs fail inside Pi with a path-specific diagnostic.
The channel keeps the requester alive while the detached helper starts. A connection-start deadline detects a terminal that starts without running the helper and reports a startup timeout separately from user cancellation. There is no editing deadline after authentication. Aborting the tool or shutting down the session closes the channel and removes its answer workspace.
Long answers follow Pi's tool-output limits. The visible result is truncated when needed, and the complete answer is retained in a private temporary file whose path is returned to the model.
Validation #
Run package validation from the repository root:
cd package/pi-plugin/ask-user-question
mise run build
mise run test:unit
mise run lint
mise run verify:extension
mise run verify:terminal
verify:terminal opens the real default terminal with a scripted editor,
checking multiline submission and blank cancellation without changing editor settings.
For diagnosed startup failures and remaining uncertainty,
see the startup investigation.
End-to-end verification must also call the installed tool from a fresh interactive Pi session,
inspect the transcript while the editor remains open,
then exercise :wq,
empty cancellation,
and an overflowing question.