@yuru7/pi-prompt-history0.1.0
Shell-style prompt history extension for pi
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.
Reports 0
No reports yet.
Readme
Pi Prompt History
Search and restore prompts from Pi sessions with Ctrl+R. The picker opens at the bottom of the terminal, with the newest match selected at the bottom of the list. Restoring a prompt does not submit it or execute a command.
Install
Requires Pi 1.7.0 or later in the 1.x series. Clone this repository and install the extension directory as a local package:
git clone https://github.com/yuru7/my-pi-extensions.git
pi install "$PWD/my-pi-extensions/pi-prompt-history"
Restart Pi or run /reload. To try it for one run without installing, use pi -e /path/to/my-pi-extensions/pi-prompt-history/index.ts. Disable other prompt history extensions or custom editor extensions that take over the same editor or shortcut.
Use
| Key | Action |
|---|---|
| Ctrl+R in the editor | Open Current folder history. Any editor draft is used as the initial query. |
| Type / Backspace | Edit the fuzzy search query; select the newest match. |
| Ctrl+R or Up | Move to the next older match. |
| Down | Move to the next newer match. |
| PageUp / PageDown | Move by one page toward older / newer matches. |
| Tab | Toggle Current folder / All folders. |
| Enter | Restore the selected prompt to the editor without submitting it. |
| Esc / Ctrl+C | Close the picker without changing the editor draft. |
The picker supports both fullscreen and regular TUI modes. Plain Up/Down in the editor retains Pi's editor history behavior; use Ctrl+R for fresh cross-process results.
Configure
Copy pi-prompt-history.example.json to ~/.pi/agent/pi-prompt-history.json, or put it in the agent directory selected by --agent-dir or PI_CODING_AGENT_DIR. The file is optional and read again each time you open the picker. Invalid settings fall back to their defaults; the picker shows a warning without exposing any history content.
{
"historyLimit": 500,
"excludeSkillPrompts": false,
"excludeBashPrompts": false
}
| Setting | Default | Meaning |
|---|---|---|
historyLimit |
500 |
Positive integer: maximum unique entries per scope, keeping the newest. |
excludeSkillPrompts |
false |
Exclude /skill:… invocations, including those restored from saved sessions. |
excludeBashPrompts |
false |
Exclude prompts starting with ! or !! after trimming outer whitespace. |
The former excludeSkillBlocks and excludePrefixes settings are no longer used.
Blank prompts are always excluded. These settings filter only recall, not what Pi writes to its own sessions. History can contain sensitive prompts and shell commands; use the scope and exclude options accordingly.
Where history comes from
- Current folder reloads from Pi's session files each time the picker opens. All folders loads on the first switch to that scope in each picker. When Pi uses a custom session directory, All folders covers the working directories stored in that directory, not every Pi session on the machine. Current folder also checks the working directory recorded in each session; older sessions without a recorded directory retain Pi's own listing behavior.
- History written by other Pi processes becomes searchable without restarting Pi. The extension checks session files for changes and reuses unchanged results from a bounded in-memory cache. It does not write session files or maintain a separate history file. Another process's unsaved or
--no-sessioninput is not visible. - Interactive inputs and
!/!!commands are also kept in memory for the current session. They are searchable before Pi persists them, including in--no-sessionmode, and are discarded on session replacement, reload, or exit. Saved bash entries contribute only the command, not its output. - Identical prompts, ignoring outer whitespace, appear once at their latest timestamp. For Skill commands, whitespace between the name and arguments is also ignored when merging duplicates. Fuzzy matches remain in chronological order regardless of their match score.
- Saved Skill invocations are restored as
/skill:nameor/skill:name args, not as expanded Skill text. Pi may have already trimmed the original argument whitespace. Reading a Skill through a tool is not a user prompt and does not create a history entry. - Built-in slash commands such as
/settingsand registered extension commands that Pi dispatches before theinputevent are not captured unless they produce a normal saved user message. Unknown slash input and prompt template invocations that reachinputcan be recalled in the same session; Pi may save only the expanded template. Unsubmitted editor drafts are not history entries. - Malformed JSONL rows are skipped while reading a discovered file; an incomplete final row is ignored until a later open can read it. Files without a session header are not treated as sessions.
Development
Run pnpm install and pnpm check for type checking and unit tests. pnpm test:pty additionally requires Python 3 and tmux; it runs real Pi instances with an isolated agent directory and an offline test provider in both TUI modes.
Credits and license
Based on ravshansbox/pi-prompt-history (MIT), with command capture and configuration informed by light4/pi-prompt-history (MIT). See LICENSE.