pi-sessions-turbo

Feature-complete, performance-optimized local Pi session search backed by a Rust SQLite/FTS5 index.

Packages

Package details

extension

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

$ pi install npm:pi-sessions-turbo
Package
pi-sessions-turbo
Version
0.1.0
Published
Aug 4, 2026
Downloads
176/mo · 11/wk
Author
patlux
License
MIT
Types
extension
Size
31.1 KB
Dependencies
1 dependency · 1 peer
Pi manifest JSON
{
  "extensions": [
    "./extension/index.ts"
  ]
}

Security note

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

README

pi-sessions-turbo

Feature-complete, performance-optimized local Pi session search without Pi Session Manager, psm-bridge, or a localhost server.

The turbo distribution preserves the complete search and context tool surface while reducing peak memory and subprocess overhead. The project contains both pieces needed for a publishable Pi package:

  • a Rust CLI that indexes ~/.pi/agent/sessions/**/*.jsonl into SQLite/FTS5
  • a TypeScript Pi extension that registers session_search, session_context, session_recall, and /session-search-status

How it works

Pi tool call
  -> extension/index.ts
  -> extension/runner.ts
  -> pi-sessions Rust CLI
  -> ~/.pi/agent/sessions/pi-sessions.sqlite
  -> ~/.pi/agent/sessions/**/*.jsonl

No daemon. No HTTP port. No Pi Session Manager.app.

Install for Pi

Install the Pi extension from npm:

pi install npm:pi-sessions-turbo

The extension requires the separate native pi-sessions binary. Build it reproducibly with Nix or Cargo and place it on PATH, or set PI_SESSIONS_BIN:

nix build github:patlux/pi-sessions
install -m 0755 result/bin/pi-sessions ~/.local/bin/pi-sessions

The extension resolves the Rust binary in this order:

  1. PI_SESSIONS_BIN
  2. PI_LOCAL_SESSION_SEARCH_BIN (legacy env var)
  3. ~/.local/bin/pi-sessions
  4. ./target/debug/pi-sessions
  5. ./target/release/pi-sessions
  6. ./result/bin/pi-sessions
  7. cargo run --manifest-path ./Cargo.toml -- ...
  8. pi-sessions from PATH

For best startup speed, install/build the binary first:

cargo build --release
# or
nix build .#

Terminal UI

Run the full-screen TUI:

pi-sessions
# or explicitly
pi-sessions tui

The TUI works like a small search app with Vim-style modes:

  • starts in Insert mode; type to search immediately
  • incomplete last words match by prefix (psm-bri finds psm-bridge)
  • multi-word queries use all by default, so nix direnv means both words
  • results are grouped by session, with relative time, best matching snippet, and hit count
  • Esc switches to Normal mode; i / a switches back to Insert
  • Tab, h / l, or Ctrl-W changes focus between results and context
  • j / k or / moves the focused pane
  • gg / G or Home / End jumps to the start/end of the focused pane
  • the right pane follows the selected session and shows surrounding dialogue
  • in context focus, Ctrl-D / Ctrl-U scrolls by a page; Ctrl-E / Ctrl-Y by one line
  • PgUp / PgDn also scrolls context
  • Enter / o opens the selected session with pi --session <session-file>
  • / clears the current query and starts a fresh search in Insert mode
  • Ctrl-W deletes the previous query word in Insert mode; Delete / Ctrl-U clears it
  • y copies the selected session path with pbcopy
  • q or Ctrl-C quits
  • ? or F1 opens help

Useful flags:

pi-sessions tui --sort newest --page-size 20 --before 4 --after 4
pi-sessions tui --project-path "$PWD"
pi-sessions tui --path-glob '*/infra/*'
pi-sessions tui --match-mode any
pi-sessions tui --match-mode phrase

Development shell

This repo includes a Nix flake dev shell and direnv config.

git clone https://github.com/patlux/pi-sessions.git
cd pi-sessions
direnv allow
npm install
make check
npm run check

Without direnv:

nix develop

The shell provides Rust, Cargo, rustfmt, clippy, rust-analyzer, cargo-watch, Node.js/npm, SQLite, jq, git, nil, and nixfmt.

Interactive REPL

A simple line-oriented REPL is still available:

pi-sessions interactive

Inside the REPL:

pi-sessions [...]> psm-bridge     # search
pi-sessions [...]> 1              # open context for result 1
pi-sessions [...]> /role user     # filter by role
pi-sessions [...]> /mode phrase   # phrase search
pi-sessions [...]> /sort newest   # sort newest first
pi-sessions [...]> /limit 20      # show more hits
pi-sessions [...]> /glob '*/infra/*'
pi-sessions [...]> /help
pi-sessions [...]> /quit

Useful flags:

pi-sessions interactive --sort newest --page-size 12 --before 4 --after 4
pi-sessions interactive --project-path "$PWD"
pi-sessions interactive --path-glob '*/infra/*'

CLI

pi-sessions index --force --prune
pi-sessions search --query "psm-bridge" --page-size 3
pi-sessions recall --query "psm-bridge" --max-results 3 --before 2 --after 2
pi-sessions context --session <uuid-or-prefix-or-jsonl-path>
pi-sessions stats
pi-sessions prune

Defaults:

  • sessions dir: ~/.pi/agent/sessions
  • DB: ~/.pi/agent/sessions/pi-sessions.sqlite

Development

Rust checks:

make check

TypeScript extension check:

npm ci
npm run check

Nix build:

nix build .#

Scope

Indexed content is intentionally limited to user/assistant text. Tool calls, tool results, thinking blocks, and image/snapshot blocks are skipped.