@lanlance/pi-btw

Claude Code-style /btw side questions for pi: read-only sub-session answers in a floating overlay while the main agent keeps running

Packages

Package details

extension

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

$ pi install npm:@lanlance/pi-btw
Package
@lanlance/pi-btw
Version
0.1.1
Published
Aug 18, 2026
Downloads
not available
Author
lanlance
License
Apache-2.0
Types
extension
Size
33.6 KB
Dependencies
0 dependencies · 3 peers
Pi manifest JSON
{
  "extensions": [
    "./extensions/btw.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

/btw for pi — ask while it works.

License: Apache 2.0 CI TypeScript

中文说明

What Is This

The main agent is elbow-deep in a refactor, and a random question pops into your head — what was that config file called? Until now you either interrupted the run or opened another terminal.

/btw answers it in a floating overlay while the main agent keeps running:

/btw what was that config file called?
/btw what does this error actually mean?

Inspired by Claude Code's /btw, rebuilt natively for pi:

  • the answer streams into a top-center overlay; the main view keeps moving
  • never enters the main conversation or its context window
  • the side agent sees the main session's real messages, and remembers your earlier side questions — up to 20 exchanges
  • read-only tools (read / grep / find / ls): it can inspect the repo itself, but cannot touch anything
  • follow-ups typed straight into the overlay continue the same side thread

pi-btw in action

Install

pi install npm:@lanlance/pi-btw

or via git:

pi install git:https://github.com/L2ncE/pi-btw

or try without installing:

pi -e /path/to/pi-btw

Usage

Type /btw <question> at any time — including while the main agent is mid-task (pi runs extension commands immediately instead of queueing them).

Overlay keys:

Key Action
Enter submit the follow-up in the input
Esc abort while answering; close when idle
c copy the current answer (raw markdown) to the clipboard
/ page through this session's side Q&A history
/ scroll a long answer
Alt+/ toggle focus between the overlay and the main editor (overlay stays visible; Ctrl+Alt+W as fallback)

Earlier questions appear as a dimmed list above the current answer. The side thread lives in memory only — /new, restarts and reloads clear it, and none of it ever reaches the main conversation.

Design

  • one lazily-created in-memory AgentSession sub-session per pi session (SessionManager.inMemory(), nothing on disk), seeded by writing the main session's messages (buildSessionContext + convertToLlm) into the sub-session journal before creation — createAgentSession restores them through its own path, so they also survive compaction rebuilds
  • tool whitelist ["read", "grep", "find", "ls"] — no bash, no edit, no write
  • model and thinking level inherit the main session and re-sync before every ask
  • the system prompt is composed fresh by the sub-session from the main session's raw customPrompt and appendSystemPrompt (via getSystemPromptOptions()) plus the btw role prompt; context files and skills load from disk at first /btw, and the tools section lists exactly the four read-only tools
  • the system prompt tells the side agent exactly what it is: temporary, read-only, never promises actions

License

Apache-2.0