# Interactive Pi Questionnaire Extension

## Status
Done

## Goal
Create a project-local pi extension that lets the assistant ask structured multi-question clarification quizzes through an interactive TUI instead of plain numbered text.

## Requirements
- Assistant can ask multiple numbered questions with selectable options.
- User can navigate options with arrow keys and confirm with Enter.
- Every question always supports a custom written response.
- User can extend any supplied option with written notes before submission.
- User can move backward/forward through questions and change answers before final submission.
- A review/submit screen shows the full quiz before final submission.
- On submission, the full quiz and answers are echoed into the chat/session.
- Existing `/tree` behavior can be used to go back before the questionnaire result and redo answers.

## Approach
- Implement as project-local extension: `.pi/extensions/questionnaire.ts`.
- Register a model-callable tool named `questionnaire`.
- Use `ctx.ui.custom()` and pi TUI keyboard handling for the interactive flow.
- Store full question/answer details in tool result `details` for session branching and rendering.

## Acceptance Criteria
- [x] Extension file exists and is auto-discoverable by pi.
- [x] Tool schema supports question IDs, prompts, labels, and option arrays.
- [x] Custom and extension text paths are available from the TUI.
- [x] Submit output includes every question and answer.
- [x] Agent behavior docs instruct Nimrod to prefer `questionnaire` over plain numbered question lists when several pieces of user input are needed.
- [x] Questionnaire work is scoped to the extension/README/ticket group; repo still contains unrelated pre-existing dirty work tracked separately.

## Verification
- Static file review.
- Best-effort runtime/type smoke test in this container:
  - `NODE_PATH=/usr/local/lib/node_modules:/usr/local/lib/node_modules/@earendil-works/pi-coding-agent/node_modules node ...` loaded extension through `jiti`, confirming tool `questionnaire` and command `questionnaire-demo` registered.
  - `pi --no-extensions -e .pi/extensions/questionnaire.ts --list-models questionnaire-smoke` exited `0`, confirming pi can load the extension.
- Manual interactive validation after `/reload` in pi:
  - User ran `/questionnaire-demo`.
  - Submitted answers:
    - Style: selected `Interactive questionnaire`.
    - Pace: selected `Balanced`.
