# btw-pi

A lightweight [Pi](https://pi.dev) extension for asking an isolated side question while the main agent keeps working.

```text
/btw what does SIGPIPE mean?
```

The answer appears as a compact card in the chat transcript. The card is a custom session entry, so neither the question nor the answer is added to the main model context. There is no centered modal: input stays in Pi's normal editor and an animated activity row remains visible above it.

## UX

- `/btw <question>` starts an independent completion with the currently selected model.
- An animated `/btw <question>` activity row stays visible above the editor until the answer arrives.
- If Pi is still streaming, the completed side answer is shown immediately in that row instead of waiting for the main transcript to settle.
- Focus immediately returns to Pi's normal editor, so you can keep using the main conversation while `/btw` runs.
- Side questions use minimal reasoning and a concise output budget for lower latency.
- Pi's active inference continues; the side question is not queued as steer/follow-up.
- `/btw cancel` cancels the active side question without aborting Pi's main inference.
- One side request may run at a time.
- `Ctrl+O` expands a result card to show model and timestamp.

## Install

Install from npm:

```bash
pi install npm:btw-pi
```

Or try it for one run without installing:

```bash
pi -e npm:btw-pi
```

You can also install a local checkout while developing:

```bash
pi install /absolute/path/to/btw-pi
```

After changing a local extension, run `/reload` in Pi.

## Design

- Uses `pi.registerCommand()` rather than adding an LLM tool or system-prompt overhead.
- Calls Pi's compatibility `completeSimple()` API with minimal reasoning and no shared conversation state.
- Reuses Pi's selected model and credential registry.
- Uses `pi.appendEntry()` plus `registerEntryRenderer()` for durable, display-only results.
- Uses the injected theme and built-in TUI components.
- Aborts in-flight work on session shutdown/reload.

## Development

```bash
npm install
npm test
npm run pack:dry
```

Requires Node.js 20 or newer.

Release history is maintained in [CHANGELOG.md](./CHANGELOG.md).
