pi-answer
Interactive Q&A extraction extension for pi
Package details
Install pi-answer from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:pi-answer- Package
pi-answer- Version
0.1.4- Published
- Apr 24, 2026
- Downloads
- 912/mo · 561/wk
- Author
- siddr
- License
- MIT
- Types
- extension
- Size
- 35.4 KB
- Dependencies
- 1 dependency · 3 peers
Pi manifest JSON
{
"extensions": [
"./index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
Answer extension
Interactive Q&A extraction for pi. Run /answer to extract questions from the last assistant message, answer them in a TUI, and send the compiled answers back into the chat.
Install
pi install npm:pi-answer
Usage
- Trigger with
/answer. - Review each extracted question.
- If options are available, choose one with ↑/↓ (or 1-9) or switch to Other and type a custom answer.
- Press Enter to commit the current answer and move forward; use Tab/Shift+Tab to navigate without committing.
- On the last question, press Enter once to open confirmation and Enter again to submit.
Note: The compiled response omits context lines and skips unanswered questions.
Navigation:
- Tab: next question (without committing current answer)
- Shift+Tab: previous question (without committing current answer)
- Enter: commit current answer and move to next question
- ↑/↓: select an option (when options are present and not editing custom text)
- 1-9: jump to option number (including Other, when not editing custom text)
- Type while an option is selected: switch to custom answer input
- When editing Other: clear the custom text, then use ↑/↓ to switch back to options
- Shift+Enter: newline in custom answer input
- Ctrl+T: apply the next answer template (if configured)
- Ctrl+C: cancel
- Esc (on submit confirmation): keep editing
Configuration
The extension reads settings from Pi's global agent dir settings.json (for example ~/.pi/agent/settings.json, or the directory selected via PI_CODING_AGENT_DIR) and .pi/settings.json (project overrides global). Add an answer block:
{
"answer": {
"systemPrompt": "Custom extraction prompt...",
"extractionModels": [
{ "provider": "openai-codex", "id": "gpt-5.4-mini" },
{ "provider": "github-copilot", "id": "gpt-5.4-mini" },
{ "provider": "openai-codex", "id": "gpt-5.3-codex-spark" },
{ "provider": "github-copilot", "id": "gemini-3-flash-preview" },
{ "provider": "github-copilot", "id": "claude-haiku-4.5" },
{ "provider": "anthropic", "id": "claude-haiku-4-5" }
],
"answerTemplates": [
{ "label": "Brief", "template": "{{answer}}" },
{ "label": "Need info", "template": "I need more details about: " }
],
"drafts": {
"enabled": true,
"autosaveMs": 1000,
"promptOnRestore": true
}
}
}
Template placeholders
Templates support these placeholders:
{{question}}— current question text{{context}}— optional context (empty if missing){{answer}}— current answer text{{index}}— 1-based question index{{total}}— total number of questions
Draft persistence
Draft answers are saved to the session while you type. When you re-run /answer for the same assistant message, the extension can restore the draft (if enabled).
Draft settings:
autosaveMs: debounce interval in milliseconds for saving drafts (0saves immediately).promptOnRestore: prompt before restoring saved drafts whentrue(auto-restore whenfalse).
Acknowledgements
This extension is inspired by the original implementation from mitsuhiko/agent-stuff.
Tests
Run the utility tests with bun:
bun test answer/tests/utils.test.ts
bun test answer/tests/qna-adapter.test.ts