An extension for the Pi coding agent that adds a structured ask tool with interactive, tab-based questioning and inline note editing.
ask({
questions: [
{
id: "auth",
question: "Which authentication model should we use?",
options: [{ label: "JWT" }, { label: "Session" }],
recommended: 1
}
]
})When an agent needs a decision from you, free-form prompts are slow and inconsistent. This extension provides:
- Structured options with clear IDs and deterministic outputs
- Single + multi-select in one tool
- Tab-based multi-question flow with a final submit review tab
- Inline note editing (no large UI pane shifts)
- Question text auto-wrap (avoids one-line
...truncation) - Optional Markdown context for longer explanations/structure diagrams
- Automatic
Other (type your own)handling
pi install npm:pi-ask-tool-extensionpi install git:github.com/devkade/pi-ask-tool@main
# or pin a tag
pi install git:github.com/devkade/pi-ask-tool@v0.1.0pi -e ./src/index.tsask({
questions: [
{
id: "auth",
question: "Which auth approach?",
options: [{ label: "JWT" }, { label: "Session" }],
recommended: 1
}
]
})Result example:
User answers:
auth: Session
Answer context:
Question 1 (auth)
Prompt: Which auth approach?
Options:
1. JWT
2. Session
Response:
Selected: Sessionask({
questions: [
{
id: "features",
question: "Which features should be enabled?",
options: [{ label: "Logging" }, { label: "Metrics" }, { label: "Tracing" }],
multi: true
}
]
})Result example:
User answers:
features: [Logging, Metrics]
Answer context:
Question 1 (features)
Prompt: Which features should be enabled?
Options:
1. Logging
2. Metrics
3. Tracing
Response:
Selected: [Logging, Metrics]ask({
questions: [
{
id: "auth",
question: "Which auth approach?",
options: [{ label: "JWT" }, { label: "Session" }]
},
{
id: "cache",
question: "Which cache strategy?",
options: [{ label: "Redis" }, { label: "None" }]
}
]
})Result example:
User answers:
auth: Session
cache: Redis
Answer context:
Question 1 (auth)
Prompt: Which auth approach?
Options:
1. JWT
2. Session
Response:
Selected: Session
Question 2 (cache)
Prompt: Which cache strategy?
Options:
1. Redis
2. None
Response:
Selected: Redisask({
questions: [
{
id: "architecture",
question: "Which execution path should we prioritize?",
description: `# Background\n\n- Current bottleneck: network I/O\n- Goal: reduce response latency\n\n\`\`\`text\n[Client] -> [API] -> [Cache] -> [DB]\n\`\`\``,
options: [{ label: "Cache-first" }, { label: "DB-first" }],
recommended: 0
}
]
})description accepts both Markdown and plain text, and is wrapped above options.
| Flow | UI style | Submit behavior |
|---|---|---|
Single + multi: false |
one-question picker | Enter submits immediately |
Single + multi: true |
tab UI (Question + Submit) |
Submit tab confirms |
| Multiple questions (mixed allowed) | tab UI (Q1..Qn + Submit) |
Submit tab confirms all |
Press Tab on any option to edit a note inline on that same row.
- Display format:
Option — note: ... - Editing cursor: inverse block on the character under caret (or space at end)
- Notes are sanitized for inline display (line breaks/control chars)
- Narrow-width rendering keeps the edit cursor visible
For Other, a note is required to become valid.
↑ / ↓: move between options← / →: switch question tabsEnter: select/toggle or submit (on Submit tab)Tab: start/stop inline note editingEsc: cancel flow
{
questions: [
{
id: string,
question: string,
description?: string, // optional Markdown/plain context shown above options
options: [{ label: string }],
multi?: boolean,
recommended?: number // 0-indexed
}
]
}Do not include an
Otheroption inoptions. The UI injects it automatically.
npm install
npm run checknpm run check runs:
- TypeScript checks (
npm run typecheck) - Test suite with coverage (
npm run test:coverage) - Coverage gate (
npm run coverage:check)
Coverage gate defaults (override via env vars in CI if needed):
- Overall: lines >= 38%, functions >= 80%
src/index.ts: lines >= 95%, functions >= 100%src/ask-logic.ts: lines >= 95%, functions >= 100%src/ask-inline-note.ts: lines >= 80%, functions >= 70%
src/index.ts- extension entrypoint, tool registration, and orchestrationsrc/ask-logic.ts- selection/result mapping helperssrc/ask-inline-ui.ts- single-question UIsrc/ask-tabs-ui.ts- tabbed multi-question UIsrc/ask-inline-note.ts- inline note rendering helpersrc/ask-text-wrap.ts- shared line-wrapping helper for long promptstest/*.test.ts- logic + UI mapping + integration coverage