@jmcombs/pi-prompt-enhancer
v4.0.0
Published
Codebase-aware prompt enhancer for the Pi coding agent — rewrites rough prompts into precise ones, with project tree, git context, and referenced file contents, before they reach the model.
Maintainers
Readme
@jmcombs/pi-prompt-enhancer
Codebase-aware prompt rewriting for the Pi coding agent. It turns a rough request into a precise one, then puts that rewrite back in the editor for you to review. Nothing is submitted until you say so.
The enhancer looks at your project tree, git status, any files the draft names, and the last few turns of the conversation, then rewrites the request instead of answering it. The original stays one keystroke away.
That last part is what makes a follow-up work: "help me with this skill" can be rewritten because the enhancer can see what "this" was. Only a small, capped slice of the conversation is sent, and it is sent to the enhancer model — the one shown on the status bar, which may not be the model running your session.
Install
pi install npm:@jmcombs/pi-prompt-enhancerSee the Pi packages documentation for git, local path, project-scoped install, and filtering options.
No extra API keys. It uses the model already active in your session, or one
you pick with /prompt_enhance_model.
Quick start
- Type a rough request.
- Press
Ctrl+Shift+E. - Read the rewrite. Nothing has been sent.
- Press Enter to send, or
Ctrl+Shift+Zfor the original.
Commands
| Command | What it does |
| --- | --- |
| /prompt_enhance [text] | Rewrite the text you pass, or whatever is already in the editor. |
| /prompt_enhance_model | Pick the enhancer model for the current session. Resets when Pi restarts. |
| /prompt_enhance_revert | Put back the last prompt you wrote and enhanced. Once only; also clears when you send a prompt. |
| /prompt_enhance_auto | Turn auto-enhance on or off for the current session. Off until you do. |
Shortcuts (also listed in /hotkeys):
Ctrl+Shift+E: enhance what is in the editor. Always works, even when auto-enhance would skip.Ctrl+Shift+Z: revert the last enhance.
After an enhance, the footer reminds you how to revert. With auto-enhance on it
also says Enter to send. Press Esc to cancel an enhance that is still
running.
Press Ctrl+Shift+E again on a rewrite you have not touched and you get another
rewrite of your original prompt, not a rewrite of the rewrite — press it a few
times to see different approaches to the same request. The footer says
Re-enhanced your original prompt when that is what happened, since a second
rewrite can read much like the first. Edit the rewrite first and enhancing takes
your edited text instead: an edit is you saying something, so it is what gets
rewritten — and from then on it is what "again" means. Every further press
re-rolls your edit, not the draft you started from, until you edit again.
So Ctrl+Shift+Z hands back the last thing you wrote and enhanced: your typed
draft if you never edited a rewrite, otherwise your most recent edit. Getting
back to the draft behind an edit is the editor's own undo, not this. Revert is
once per chain, and a chain ends when you send something.
If you edit a rewrite and press Ctrl+Shift+Z without enhancing first, that
edit is overwritten — the status line says later edits lost rather than
claiming it gave you your own words back.
When an enhance does not work
A slow or unreachable model is retried a few times first, and the loader names the reason so you can decide to wait or press Esc:
Retrying (1/3) in 2s… · Connection errorEsc cancels and changes nothing else. If the retries run out, three things happen and nothing else:
- your prompt goes back in the editor, exactly as you typed it;
- auto-enhance turns itself off for the rest of the session, so the next Enter
sends — turn it back on with
/prompt_enhance_auto; - one message says so on the status bar, names the reason, and clears itself after a few seconds:
prompt enhancement failed (Connection error); your prompt is unchangedConfiguration problems are the exception. No active model, credentials that will not resolve, no API key for the model — those stay on screen as notifications, because pressing the key again cannot help until you have changed something.
The status bar
Prompt Enhancer displays in the Pi status bar with the enhancer model, when auto-enhance is enabled, and a short status after an action is taken. Here are the elements of the status bar:
- Ready: a model is resolved. Enhance with
Ctrl+Shift+E. - Auto on:
/prompt_enhance_autois armed. Enter rewrites; Enter again sends. - No model: pick one with
/modelor/prompt_enhance_model. - Enhancing: the call is out. Input is blocked until it lands;
Esccancels. - Review: a rewrite is in the editor and has not been sent.
Ctrl+Shift+Zrestores the original.
A Nerd Font is required for the mark and separators to render.
Auto-enhance on Enter
Off by default. Run /prompt_enhance_auto to turn it on for the current session. A
green auto block on the status bar means it is on.
flowchart TD
A[Type a request] --> B[Enter]
B --> C[Rewrite appears in the editor]
C --> D{Keep it?}
D -->|Enter| E[Send to the model]
D -->|Ctrl+Shift+Z| F[Original comes back]Short replies like ok, yes, approved, or a brief answer to a question
are skipped: on those turns you did not ask for a rewrite, so auto-enhance
stands aside without a word. Naming a file is enough to count as a task, so
fix foo.ts is not skipped.
Ctrl+Shift+E and /prompt_enhance enhance a skipped reply anyway. Pressing
the key is asking for the call, and it is always made — whatever the draft says
and however short it is. The one thing that stops it is an empty editor, which
has nothing to send:
Nothing to enhance (editor is empty).Requirements
| | | | --- | --- | | Node | ≥ 22.19.0 | | Pi | any recent version | | A Nerd Font | for the status bar mark and separators | | A configured model | at least one Pi model with an API key |
Development
This package lives in the pi-extensions monorepo.
See CONTRIBUTING.md at the repo root for project conventions.
# From the repo root
npm ci
npm run check
npm run test -- packages/prompt-enhancer
# Try local changes (skip globally installed extensions so they do not collide)
pi --no-extensions -e ./packages/prompt-enhancerLicense
MIT © Jeremy Combs
