Install
Install with PiG
pig install npm:pi-escape-guardInstall with Pi
pi install npm:pi-escape-guardPackages 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.1.1 (README.md). PiG does not review it.
pi-escape-guard
Prevent accidental interruptions in Pi. Press Esc three times to interrupt an active agent operation, instead of stopping it with a single accidental press.
The counter stays hidden until you press Esc. All on-screen instructions and notifications are in English.
Installation
pi install npm:pi-escape-guard
Run /reload in an existing Pi session, or restart Pi.
If you already have a local copy of Escape Guard, disable it before loading this package. Two copies can intercept the same key presses.
How it works
The first Esc press during an active operation displays a widget above the editor:
Esc: 1/3 — Press Esc 3 times to interrupt (within 1s of each press)
- The first two Esc presses are swallowed; the second updates the counter to
2/3. - The third press is passed through to Pi, and an
Esc: 3/3 — Interrupt requestednotification is displayed. - Each press must arrive within one second of the previous press.
- The widget disappears and the counter resets after one second without another press, another key, the end of an agent run, or a session switch.
- Nothing is displayed before the first Esc press.
- Idle Esc behavior and Ctrl+C remain unchanged.
- Esc in
/resume, other selectors, dialogs, and autocomplete dismisses those interfaces normally without counting an interrupt.
The extension preserves Pi's native interrupt behavior, including restoring queued messages to the editor.
Scope and limitations
- Protection applies when
ctx.isIdle()is false, including agent processing and automatic retries. Standalone!shell commands while the agent is idle and direct aborts from other extensions are not protected. - Protection applies only while the main editor has focus and its autocomplete menu is closed. Opening a selector or dialog and pressing a key clears any pending interrupt count.
- Existing custom editor factories are preserved. Custom editors that do not expose a
focusedproperty bypass the guard to avoid intercepting unrelated UI actions. An editor factory installed by another extension after Escape Guard may also bypass protection. - Kitty key-release and held-key repeat events do not count. Terminals that do not report repeats cannot distinguish holding Esc from pressing it repeatedly.
- Non-interactive sessions are unaffected.
Development
No build step or runtime dependency installation is required. Pi loads index.ts directly and provides the host APIs declared in peerDependencies.
Tests require Node.js 22.19+ and a global npm installation of Pi. CI tests Node.js 22, 24, and 26 with Pi 1.5.2:
npm install --global @earendil-works/pi-coding-agent@1.5.2
npm test
npm pack --dry-run
For other installations, set PI_PACKAGE_ROOT to the @earendil-works/pi-coding-agent package directory before running tests. Tests use the installed host's TypeScript loader and keyboard implementation.
To try the checkout without installing it:
pi -e ./index.ts
Disable any installed copy first to avoid duplicate input handlers.
Contributing
Bug reports and focused pull requests are welcome. When reporting an input issue, include your Pi version, Node.js version, terminal application, and whether Kitty keyboard protocol is enabled. Do not include API keys or private session content.
Run npm test and npm pack --dry-run before submitting changes. Keep the extension free of runtime dependencies and preserve native idle key behavior.
Links
License
MIT. See LICENSE.