pi-tree-graph

Session tree visualization with git snapshot integration for pi coding agent (/tg + auto checkpoints)

Packages

Package details

extension

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

$ pi install npm:pi-tree-graph
Package
pi-tree-graph
Version
0.1.0
Published
Sep 9, 2026
Downloads
154/mo · 154/wk
Author
maimaimai
License
MIT
Types
extension
Size
52.2 KB
Dependencies
0 dependencies · 2 peers
Pi manifest JSON
{
  "extensions": [
    "./extensions"
  ]
}

Security note

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

README

pi-tree-graph

Session tree visualization with git snapshot integration for the pi coding agent.

  • /tg (alias /tree-graph) — time-ordered session tree (newest on top, git log --graph style), with branch tracks, merged repeated messages (继续 ×4), and git snapshot badges.
  • Auto checkpoints — every write/edit takes a "before edit" snapshot; every session start takes a snapshot. Broken code is one keypress away from recovery.
  • Press g on any snapshot row/badge to restore code to that moment (with confirmation).

Snapshots live in shadow repos under ~/.pi/agent/checkpoints/ — your project's own .git is never touched and your commit history stays clean.

Install

pi install npm:pi-tree-graph

Or try without installing:

pi -e npm:pi-tree-graph

Requirements: git on PATH. Snapshots cover projects under ~/code/ (first-level directory = project root) plus ~/.pi/agent itself.

Usage

Command What
/tg Open the time-ordered tree. ↑↓/jk move, PgUp/PgDn or ctrl-b/ctrl-f page, mouse wheel scrolls, click selects, f cycles filter (user / no-tools / full), enter jumps to node, g restores snapshot, esc closes
/checkpoints List recent snapshots per protected target
/checkpoint-restore <hash> Restore worktree files to a snapshot (tracked files overwritten; files created after the snapshot are kept)
/checkpoint-prune Prune snapshots older than retention (archives to bundles first, restorable)

Filters: user (default — user messages + anchors: checkpoints, compactions, branch summaries; assistant thinking hidden), no-tools, full.

Snapshot retention

Old snapshots are pruned automatically on session start (archived to archive-*.bundle first; restore falls back to bundles transparently). Tune with env vars:

Var Default Meaning
PI_CHECKPOINT_RETENTION_DAYS 30 Only prune commits older than this
PI_CHECKPOINT_MIN_KEEP 50 Always keep the newest N commits
PI_CHECKPOINT_HARD_CAP 1000 Hard cap on total snapshots (runaway protection)
PI_CHECKPOINT_PRUNE 1 Set to 0 to disable auto-prune (/checkpoint-prune still works)

Excluded from snapshots: node_modules, dist, build, __pycache__, .venv, *.log, etc. Files changed via bash (not write/edit) are captured by the next snapshot, not beforehand.

Layout

 Session Tree  session  ·  5 nodes
────────────────────────────────────────
│ ❯ latest message                            18:18
│ ❯ earlier message         ⎇76e216b(+3)      18:12
│ ❯ repeated message ×4                       18:08
│ /  ← branch merge line
❯ ❯ oldest message                            18:01

License

MIT

Troubleshooting

Slash commands sent as plain messages (/tg ignored): another copy of these extensions is loading at the same time (e.g. dev files under ~/.pi/agent/extensions/ plus this installed package). Duplicate command registration disables both copies. Keep only one: remove the dev files or run pi remove npm:pi-tree-graph.