@hank-warren/pi-permission-selector
v0.1.0
Published
Numbered approval options and Tab-to-comment for Pi's extension select dialogs, including pi-auto-permissions command approval prompts.
Maintainers
Readme
permission-selector
Numbered approval options + Tab-to-comment for pi's extension select dialogs —
the UI behind ctx.ui.select, which is what pi-auto-permissions uses for its
command approval prompts.
What it does
Numbered options + digit hotkeys (all extension select dialogs)
Options render as 1. Allow, 2. Block, … and pressing 1–9 selects that
option instantly. Existing ↑↓/j/k navigation and Enter/Esc behavior is
untouched. Options beyond the ninth are un-numbered (arrow-only).
ctx.ui.confirm (Yes/No) dialogs share the same component and get numbering
for free.
Tab-to-comment (approval prompts only)
With an option highlighted, press Tab to pin it and type a note inline:
→ 1. Allow, after this command runs, we should check the logs▌
2. Block
enter submit · esc discard note · tab back- Enter submits: the calling extension receives the original option
string (
"Allow"/"Block"— required becausepi-auto-permissionsdoes an exact string compare), and the note is sent to the agent verbatim as a steering user message (pi.sendUserMessage(note, { deliverAs: "steer" })). - Esc discards the note and returns to normal navigation (Esc again cancels the dialog as usual).
- Tab toggles back to navigation, preserving the typed text.
- While typing, digits are literal text and arrow keys are inert.
- Pasting works (bracketed paste, including multi-chunk pastes); pasted newlines/tabs are flattened to spaces since the note is a single line.
- Key handling is encoding-aware via pi-tui's
matchesKey, so terminals using the Kitty keyboard protocol (Esc =\x1b[27u, CSI-u printables) work the same as legacy encodings. - An empty/whitespace note submits the option without sending anything.
This works for both directions: Allow + note runs the command and steers the next model turn ("check the logs after"); Block + note blocks with the normal reason plus your steer ("do X instead").
Scope and configuration
- Approval prompts are detected by title regex. Default:
/needs approval/i(matches pi-auto-permissions'"<label> — Auto Permissions needs approval"). Override with thePI_PERMISSION_SELECTOR_MATCHenv var (compiled case-insensitive; invalid patterns fall back to the default). - When auto-permissions is disabled, pi core shows no approval prompts (it is YOLO by default), so this extension has nothing to enhance — by design.
- Non-TUI modes (rpc/print/json) never instantiate the component; the patch is inert there.
Known coupling
This extension monkey-patches ExtensionSelectorComponent.prototype
(updateList/handleInput) from @earendil-works/pi-coding-agent, relying on
pi's extension loader aliasing that package to the running instance. If a
future pi version changes the component shape, the patch refuses to apply, the
selectors stay stock, and a warning notification is shown at session start —
it never crashes.
