Install
Install with PiG
pig install npm:@clementprevot/pi-session-searchInstall with Pi
pi install npm:@clementprevot/pi-session-searchPackages 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.2.0 (README.md). PiG does not review it.
@clementprevot/pi-session-search
A Pi extension that gives you fuzzy full-text search over every past pi session: user prompts, assistant answers, compaction and branch summaries, across all your projects. /search opens a picker that can resume the session you pick, or jump straight to the matched round inside its branching tree, and the agent gets a search_sessions tool so "which session did we discuss X in?" is one call instead of grepping raw JSONL.
Install
pi install npm:@clementprevot/pi-session-search
Updates ship with pi update --extensions. The extension applies to your next session (quit and relaunch or issue a /reload command).
How it works
The extension keeps an incremental index (byte offsets, append-only docs file) in ~/.pi/agent/session-search/. It scans at session start and after every agent turn, so the picker is always current. Only the useful text of each conversation round is indexed: the user prompt and the final assistant answer, plus compaction and branch summaries. Thinking, tool calls, tool results and image blobs are skipped, which keeps the index tiny next to the raw files.
Matching is fuzzy: per token, an exact match beats a prefix match, then a substring, then a subsequence. Queries are accent-insensitive and all query tokens must match. Results are ranked per session, with the best snippet shown.
In the picker:
- type to search, enter to resume the selected session
alt+jjumps to the matched round inside the session's branching treealt+ptoggles a preview of the matched texttabtoggles scope between the current directory and all sessionsalt+rtoggles extra index roots on or offctrl+stoggles between relevance and date sorting
/search --deep <topic> re-ranks the top candidates by spawning a headless pi subprocess locally (it can take up to 3 minutes) and lets you pick from its top 5, each with a one-line justification.
When the picked session file lives in the archive (from @clementprevot/pi-session-archive), it is restored to the live sessions tree first, with its subagent runs and screenshots, then resumed.
The agent-facing search_sessions tool answers "where did we talk about X?" and returns the top matching sessions with snippets and their file paths; it only reports, it never switches sessions.
Other extensions can borrow the picker to let you choose a session, over Pi's event bus. @clementprevot/pi-session-relocate uses it for /migrate. The caller emits session-search:rpc:v1:pick with { version: 1, requestId, ui, cwd?, excludeCwd?, title? }, where ui is its command context's ctx.ui. This extension answers at once on session-search:rpc:v1:ack:<requestId>, so a caller that gets no ack within a short timeout knows the picker is not installed. Once you pick, it sends { path } on session-search:rpc:v1:result:<requestId>: the session file, or null if you cancel. An archived session is restored to the live sessions tree before its path is returned.
Configuration
Optional file at ~/.pi/agent/extensions/session-search.json:
{
"extraRoots": ["/absolute/path", { "path": "/absolute/path", "label": "backups" }],
"indexIntermediate": true
}
extraRoots: more directories of pi session files to index, alongside the live sessions tree. Each entry is an absolute path, or an object with apathand a displaylabel. @clementprevot/pi-session-archive path is automatically included.indexIntermediate: whether assistant text from tool-call rounds is indexed (defaulttrue).
Omit the file for defaults.
Privacy
Everything is local. The index and the searches run entirely on your machine; session content never leaves it. The only subprocess is a local headless pi run for --deep.
One thing to know: the index duplicates session text into ~/.pi/agent/session-search/, so it is one more local file that holds whatever your sessions contain. It never leaves the machine, but it is a second copy of potentially sensitive conversation content, protected by the same file permissions as the rest of your pi directory.
Local development
npm install
npm test
npm run typecheck
To try the extension in a live session without installing it:
pi -e /path/to/this/repo