@335g/pi-answer
v0.0.2
Published
Extract questions from the last assistant message and answer them in an interactive Q&A TUI.
Readme
pi-answer
Extract questions from the last assistant message and answer them in an interactive Q&A TUI.
Port of mitsuhiko/agent-stuff answer.ts.
Install
pi install npm:@335g/pi-answerpi install writes to the user settings (~/.pi/agent/settings.json). Add -l to write to the project settings
(.pi/settings.json) instead.
Usage
/answer— extract questions from the last assistant message/answer 2— extract from the assistant message before that (3,4, ... go further back)ctrl+.— same as/answer
Flow: questions are extracted with the configured extraction model (the session model by default), shown one at a time in a box, followed by a free-space step for notes, then reviewed as a whole, then submitted as one message that triggers a turn.
Keys:
- Answering:
Tab/Enternext,Shift+Tabprev,Shift+Enternewline,1-9insert an option,Ctrl+Xexclude the question,Esccancel - Review:
Enter/ysubmit,Esc/nback to the first question,lto the last question - Cancel dialog:
Enter/ydiscard,Esc/nkeep editing. The dialog only appears when something has been entered; with empty answersEscdiscards immediately.
The extraction model may attach options (2-4 short answers) to a question. They are listed under it and inserted at the
cursor with 1-9, but only while the answer is empty, so digits stay typeable and you can append an annotation after
picking one (はい -> はい、ただし本番のみ). Ctrl+X drops the question; it is not added to the message and the
remaining questions are renumbered.
Configuration
pi-answer.json, read on every /answer, so no restart is needed. A project file overrides the global one key by key,
and is only read for trusted projects (ctx.isProjectTrusted()):
| Location | Scope |
|----------|-------|
| ~/.pi/agent/pi-answer.json | global |
| .pi/pi-answer.json | project |
{ "lang": "ja_JP.UTF-8", "model": "anthropic/claude-haiku-4-5" }lang— locale in the same format asLANG(e.g.ja_JP.UTF-8); only the language prefix matters. Unset:LC_ALL, thenLANG.model— extraction model asprovider/modelIdor baremodelId. Unset: the session model. If it matches no available model, a warning is shown and the session model is used.
Submitted text is a numbered markdown block (### Q1: ... / Context: ... / Answer: ...), followed by a
### Notes section when the free-space step has text. Unanswered questions are omitted from the message, so a gap in
the numbering means "skipped". If nothing was answered and no notes were written, nothing is sent
(No answers to submit). The review screen is that message verbatim — the same string is rendered and sent, with no
truncation and no placeholder lines.
The wrapper forwards TUI focus to the inner editor so the editor emits CURSOR_MARKER. That keeps the IME preedit
(unconverted Japanese input) on the answer line instead of at the bottom of the box.
