omp packages

pi-bang-bang0.2.1

Bash-style !! expansion of the previous prompt for the Pi coding agent

dieracdelta Published 1 day ago MIT ~0 downloads/mo

Untested on omp

This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.

Did it work for you?

Result

One report per person. A new report replaces your old one.

Reports 0

No reports yet.

Readme

pi-bang-bang

A Pi extension that expands !! to the previous prompt, as bash history expansion does, but in the editor as you type, so you see and can edit exactly what will be sent.

You type The editor shows
!! the previous prompt
same as !! but for tests same as <previous prompt> but for tests
\!! !! (escaped, not expanded)

The expansion happens when you type the second !, at the cursor, and is a normal edit: undo brings the !! back. "Previous prompt" is the text of the last user message on the current session branch, so it follows /tree navigation and resumed sessions. It is not taken from cross-session history. Images in that message are not repeated. With no previous prompt, the !! stays and Pi says so.

Only two ! typed one after the other expand. Pasted text (for example JavaScript's !!value), text recalled from history, and Vim normal-mode keys are left alone, and a prompt is sent exactly as the editor shows it.

Typing !! at the start of the prompt expands too, so it no longer starts Pi's !!command (run a shell command without adding it to the context). Type \!!command instead: the editor turns it into !!command.

Other editors

The extension wraps whatever editor is installed when the session starts, the way pi-atuin does, so it must load after extensions that replace the editor, such as pi-vim-keys. One way is a single entry point that fixes the order:

import vim from "pi-vim-keys";
import atuin from "pi-atuin";
import bangBang from "pi-bang-bang";

export default function (pi) {
  vim(pi);
  atuin(pi);
  bangBang(pi);
}

If another extension replaces the editor afterwards, nothing expands while you type, and !! is expanded when the prompt is sent instead. RPC prompts are also expanded when they are sent. Messages injected by other extensions are never expanded.

Install

pi install npm:pi-bang-bang

then /reload in running sessions. If you use pi-vim-keys or another extension that replaces the editor, see Other editors.

Tests

PI_PACKAGE_DIR=/path/to/lib/node_modules/pi-monorepo npm test

test/expand.test.ts needs only Node 22.18 or later. The other tests type into Pi's own editor and load the extension with Pi's own loader; they are skipped unless PI_PACKAGE_DIR names a pi-monorepo directory.