Install
Install with PiG
pig install npm:@fradser/pi-btwInstall with Pi
pi install npm:@fradser/pi-btwPackages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.
Pi manifest JSON
The pi field of package.json.
{
"extensions": [
"./index.ts"
]
}README
Written by the package's publisher, shown as published in version 0.2.11 (README.md). PiG does not review it.
@fradser/pi-btw
Side questions for Pi — /btw <question> answers a quick side question in a full-width
overlay directly covering the main session input area, without interrupting the current task and without ever
entering the session history.
Why btw
Claude Code's /btw answers from conversation context only — it cannot call tools, so
"what does function X do?" gets answered from what the model happens to remember. btw
fixes that:
- Tool-capable. The side question runs in a fresh child Pi process that CAN call
read-only tools (
read,grep,find,ls) to verify facts in the actual codebase. - Strictly read-only. Only
read,grep,find,lsare allowed.bash,edit, andwriteare always excluded — a side question can look, but can never touch. - Zero history pollution. The child runs with
--no-sessionand the/btwcommand is consumed by the extension (never recorded as a session message). The exchange is gone the moment the display clears.
Install
pi install npm:@fradser/pi-btw
Restart pi, then use /btw <question> in interactive mode.
Usage
/btw what does the --force flag do on git push?
/btw where is the retry logic for the API client?
/btw how do we handle pagination in this repo?
The answer appears in a full-width popup anchored to the bottom of the terminal (directly covering the main session input area), with height adapting to the content:
- Spinner while the read-only child answers (same model as your session; override with
the
BTW_MODELenv var, e.g.BTW_MODEL=anthropic/claude-sonnet-4-5). - Multi-turn conversation. Type follow-up questions directly in the overlay input prompt and press
enterto continue the side thread. esccloses (or cancels while loading).↑/↓scroll andpgup/pgdnpage.home/endedit the question when the composer is visible.- Small terminals use a compact layout. The minimum size is 20 columns and 8 rows.
- Fullscreen mouse-wheel events scroll the answer. Regular mode keeps terminal-owned scrollback.
- Short answers shrink the panel; long answers cap at ~40% of the terminal height and remain scrollable without adding a hidden-line count to the answer.
- The footer shows aggregated token usage and cost for the side conversation.
Pi 1.0.0 routes normalized mouse events to overlays. Keyboard scrolling remains available on older hosts and in regular mode.
The question is answered with the last ~4 user/assistant messages of the current session as compact read-only context (capped at 4000 characters, including the truncation marker), so it can answer about what you are working on right now — and then verify it against the actual files. Answers are kept concise: the child is instructed to stay within 150 words or 600 characters, use at most five short bullets, and avoid report-style summaries.
Design
| Piece | What it does |
|---|---|
src/spawner.ts | Spawns pi --print --mode json --no-session --no-extensions with --tools read,grep,find,ls --exclude-tools bash,edit,write; parses the JSONL stream into the final answer + usage. |
src/context.ts | Selects four recent user/assistant text messages in chronological order, capped at 4000 characters including the truncation marker. |
src/overlay.ts | The interactive popup: loading spinner → answer, esc closes, arrows/pgup/pgdn/home/end scroll, height adapts to content (capped at ~40% of the terminal). |
index.ts | Package-root entry point that loads the extension. |
src/index.ts | Registers the /btw command and wires context → child process → overlay. |
Requirements
- pi interactive (TUI) mode — the display needs a terminal.
- The same provider credentials as your main session (the child reuses your env).
License
MIT