pi-session-find

Search your Pi session history and read the full message in a read-only overlay. AI thinking and tool/command output are hidden by default.

Packages

Package details

extension

Install pi-session-find from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:pi-session-find
Package
pi-session-find
Version
0.1.0
Published
Sep 24, 2026
Downloads
180/mo · 11/wk
Author
adrian_stark
License
MIT
Types
extension
Size
33.3 KB
Dependencies
0 dependencies · 2 peers
Pi manifest JSON
{
  "extensions": [
    "./index.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

pi-session-find

Search your Pi session history, read the full message, keep your place.

简体中文 · English

pi-session-find adds a /find command to Pi: a live-filtered overlay that searches the current session's history and shows the matched message in full — right below the result list. Nothing is injected into the model context, and your session position only changes if you press Enter.

 ────────────────────────────────────────────────────────────────────
  /find  查询: kimi  · 命中 6/295 · 活跃分支
  视图: 我 AI (思考) (工具) (系统)
  ────────────────────────────────────────────────────────────────────
  ▸ 09-23 18:42 我   为什么 kimi 在 pi 中使用的时候会有这个问题…
    09-23 18:49 AI   对,/find 是我刚为你现写的…
  ────────────────── 详情: AI · 09-23 18:49 ─────────────────────────
  (the full message, rendered as Markdown — scrollable, code blocks intact)
  焦点: 列表 · 打字过滤 · ↑↓ 选择 · Ctrl+O 视图 · Ctrl+K 思考 · Ctrl+T 工具 …

Why not just /tree?

Pi already ships two ways to look back. Both are good; /find covers the gap between them.

/tree (built-in) Fullscreen Ctrl+Shift+F (built-in) /find (this package)
Searches the session tree the rendered transcript raw session entries of the active branch
Text coverage first ~200 characters per message, text blocks only everything that got rendered full text: thinking blocks, tool-call arguments, tool output
Filtering filter keys (Ctrl+U user only, Ctrl+T hide tools, labels) — per-category toggles + presets
Read the full message not really — a one-line list yes yes, in the preview pane
Session position Enter moves the leaf unchanged unchanged unless you press Enter

The 200-character limit is real: Pi's tree indexer calls extractContent(content) { return this.extractFullContent(content).slice(0, 200) }, and it only reads text blocks. So /tree cannot find a word that appears in the middle of a long answer, in a thinking block, or in a bash result. /find indexes the whole thing.

Install

pi install npm:pi-session-find

Try it for one run without installing:

pi -e npm:pi-session-find

If Pi is already running, run /reload (or restart) so the command is registered.

Usage

/find <keywords> [options]

Open the overlay, then keep typing — every keystroke refines the filter (space-separated words must all match, case-insensitive).

Key Action
type refine the search
Backspace delete a character from the query
↑ / ↓ move the selection
PgUp / PgDn page the list (or scroll the preview when it has focus)
Tab switch focus between the list and the preview
Ctrl+O cycle views: Default → +thinking → Everything → Me only
Ctrl+K toggle AI thinking on/off
Ctrl+T toggle tool/command content on/off
Enter jump to that entry (moves the session position, like /tree)
Esc preview → list · clear the query · then close
Option Meaning
--thinking start with AI thinking included
--tools start with tool/command content included
-u, --user only what you wrote
-m, --ai only AI messages (text + thinking)
-t, --tool only tool calls / command output
-a, --all search the whole session file, including abandoned branches

Views and categories

Every entry is split into independent, filterable categories:

Category Content
Me (我) your prompts
AI assistant text (the reply as you read it)
Thinking (思考) thinking/reasoning blocks — hidden by default
Tool (工具) tool calls with arguments, tool results and command output, !cmd shell commands — hidden by default
System (系统) extension messages, compaction and branch summaries

The default view is Me + AI text. One assistant message becomes several rows, so a match can be reported specifically as thinking or tool call instead of dumping the whole turn.

Hidden categories are excluded from matching too. If your keywords only match hidden content, the header says so instead of pretending nothing was found:

没有命中;另有 9 条在隐藏的「思考/工具」里 → Ctrl+K / Ctrl+T 显示

Notes and limitations

  • Interactive TUI only. In --print, --mode json or --mode rpc the extension loads but /find only posts a notice; search ~/.pi/agent/sessions/**/*.jsonl directly instead.
  • Searching is read-only. Query text and the overlay never touch the session file or the model context. Enter does move the current position, exactly like selecting an entry in /tree — use Esc if you only want to read.
  • One parse per invocation. Building the index for a 2.3 MB / 784-entry session took ~6 ms in local testing; matching is instant afterwards.
  • Developed against Pi 0.87.1. It uses the documented extension API (registerCommand, ctx.ui.custom, ctx.sessionManager.getBranch, ctx.navigateTree).
  • Extensions run with your user permissions and can read your transcripts. Install packages you trust.
  • @earendil-works/pi-coding-agent and @earendil-works/pi-tui are declared as peer dependencies, matching the Pi package guide — Pi supplies them at runtime.

Development

git clone https://github.com/uniStark/pi-session-find.git
cd pi-session-find
pi -e ./index.ts        # load the working copy directly, no build step (Pi uses jiti)

The package is a single TypeScript file, index.ts. pi.registerCommand("find", …) is the only registration; everything else is exported for testing (buildHits, matchHits, parseArgs, initialCats, FindOverlay).

License

MIT © Adrian Stark