@fradser/pi-btw

Side questions for Pi — /btw answers in a read-only overlay, never entering the session history. Unlike Claude Code's /btw, it can actually call read-only tools (read, grep, find, ls) to verify facts in the codebase.

Packages

Package details

extension

Install @fradser/pi-btw from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@fradser/pi-btw
Package
@fradser/pi-btw
Version
0.2.11
Published
Nov 11, 2026
Downloads
396/mo · 48/wk
Author
fradser
License
MIT
Types
extension
Size
38.5 KB
Dependencies
1 dependency · 2 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

@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:

  1. 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.
  2. Strictly read-only. Only read, grep, find, ls are allowed. bash, edit, and write are always excluded — a side question can look, but can never touch.
  3. Zero history pollution. The child runs with --no-session and the /btw command 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_MODEL env 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 enter to continue the side thread.
  • esc closes (or cancels while loading).
  • ↑/↓ scroll and pgup/pgdn page. home/end edit 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