← Catalog

pi-grove

A lazygit-style graph for pi's session tree, with a history of your moves and equal peer agents that each own a session branch and a git worktree.

Extension

Install

Install with PiG

pig install npm:pi-grove

Install with Pi

pi install npm:pi-grove
Review before installing

Packages 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.

{
  "image": "https://raw.githubusercontent.com/Buchi-dev-dzn/pi-grove/main/docs/screenshot.png",
  "skills": [
    "./skills"
  ],
  "extensions": [
    "./src/index.ts"
  ]
}

README

Written by the package's publisher, shown as published in version 0.1.2 (README.md). PiG does not review it.

pi-grove

CI npm version

A pi extension that makes the session tree something you actually use.

  • A lazygit-style graph of the session tree. Every branch of the conversation is a lane, the way commits are in lazygit. Jump, fork, label and search from one panel.
  • A history of your moves in the tree. Every jump between branches is recorded, so you can always go back to where you were.
  • Peers. Several pi agents work in one repository as equals. Each peer has its own branch of the session tree, its own git worktree and its own git branch, and they talk to each other directly.

The grove view: the session tree of one session and its two peers, drawn as a graph

The screenshot shows one real session. The agent in main split a task and started the peers strings and docs. Each lane is a branch of the conversation, and the lines between lanes are the messages the peers sent each other.

Why

pi stores every conversation as a tree. Going back to an earlier point does not erase anything: the path you leave stays in the session as a branch. That is one of pi's best features, and it is easy to never use, because the built-in /tree shows an indented list in which it is hard to see how the branches relate.

pi-grove draws the same tree the way git tools draw history. Once branches are visible, they are cheap to create, and the next step follows: give a branch to another agent and let it run in parallel.

Install

pi install npm:pi-grove

# or from git
pi install git:github.com/Buchi-dev-dzn/pi-grove

# or try it for one run without installing
pi -e npm:pi-grove

Developed and tested against pi 1.5.2. Peers also require git 2.31 or later.

The graph

Run /grove, or press alt+g. The view has three tabs: Tree, History and Peers. The title of the panel shows what the tab currently displays, for example Tree · turns · 3 sessions.

Each row is one entry of the session. The columns are the same as in lazygit's commits panel:

ColumnMeaning
6e124f85Entry id. Dimmed when the entry belongs to another session and is read-only.
Us Cl MaWho wrote it: Us is you, Su a branch summary, Co a compaction, To a tool result. An assistant message shows the first two letters of the model name, or of the peer name when peers are involved.
● │ ╮The graph. One lane per branch.
textFirst line of the entry, with (HEAD), (peer) and [label] markers. +3 means three entries are folded into the row.

Node glyphs:

  • ◉ is HEAD: the entry the conversation continues from.
  • ● is on the active branch, the path from HEAD to the root. This is what the model sees.
  • ○ is on another branch.

A session tree has no merges, but information does flow between branches. The graph draws those places as merge edges:

  • Branch summaries. When you leave a branch with a summary, the summary row is connected to the branch it summarizes.
  • Peer messages. A message from a peer is connected to the point the peer had reached when it sent it.

By default the graph shows one row per turn: your prompt, with the assistant's work folded into it, and the last entry of every branch. Press t to show every message, and again to show tool results too.

Forked sessions keep the entry ids of the session they came from. pi-grove uses that to draw a session together with the sessions it was forked from, the sessions forked from it, and the sessions of its peers, as one graph. Press a to show only the current session.

Keys

KeyAction
j k ↑ ↓Move
g GFirst and last row
ctrl+u ctrl+dPage up and down
tab 1 2 3Switch between Tree, History and Peers
rReload
?Help
q escClose

Tree:

KeyAction
enterJump to the entry. Jumping to one of your prompts puts its text back in the editor, so you can edit it and branch from there.
sJump, and summarize the branch you leave
fFork a new session from the entry
lSet or clear a label
pStart a peer from the entry
tCycle the rows shown: turns, messages, all
aShow or hide related sessions and peers
/ n NSearch, next match, previous match
HSelect HEAD

Jumping needs the agent to be idle. Entries of other sessions are read-only.

History

pi only records a move between branches when it writes a branch summary. pi-grove records every move, the way git reflog does for a repository. The History tab lists them, newest first:

25s ago summarized 1a9148b0 summary: The user explored a different branch
25s ago left       fcb5b75d Result: Added both utility modules
 4m ago opened at  df4b8ed3 Add two independent utility modules
  • jumped to is a jump, from /tree or from the graph.
  • summarized is a jump that left a branch summary.
  • left is where the conversation stood before you jumped away from it. This is the row to pick to undo a jump.
  • opened at is where the session stood when it was opened.

Press enter on a row to go back to that position.

Peers

A peer is a pi agent with three things of its own:

  • a branch of the session tree: its session is forked from yours, so it knows the conversation so far;
  • a git worktree, in <repository>.grove/<name> next to your repository;
  • a git branch, grove/<name>, created at your current commit.

Peers are not subagents. A subagent is called by a parent, does one job, returns a result and is gone. Peers have no parent:

  • Every pi process that loads pi-grove inside a repository is a peer, whether you started it in a terminal or another peer started it in the background. The session you are typing in is a peer too, usually named main.
  • All peers have the same four tools. A background peer can list, message and start peers exactly like your session can.
  • Peers send messages to each other directly. A message appears in the receiver's conversation and wakes it if it is idle. Nobody polls and nobody relays.
  • A peer that finishes its task stays alive and idle. You, or any peer, can send it a follow-up.

To work side by side with a peer yourself, open a second terminal in its worktree and run pi there, or start your own with git worktree add and pi. Both join the same grove.

In the conversation

Peer activity is drawn as an exchange, not as generic tool calls. The peer's name has the same color as its lane in the graph.

Peer activity in the conversation: a new peer, messages in both directions and a board note

The image shows parts of the session from the screenshot at the top; ⋮ marks where the conversation is cut.

+ starts a peer, → is a message your agent sent, ← is a message that arrived, and ▪ is a note on the shared board. Long texts show their first three rows; expand them like any tool output (ctrl+o by default).

Tools

ToolWhat it does
grove_peersList the peers: status, branch, worktree, task, and how many commits each branch has that you do not
grove_spawnStart a peer in a new worktree with a task. context: "fresh" starts it without the conversation.
grove_sendSend a message to one peer, or to all
grove_boardRead or post short notes that every peer sees: decisions, interface contracts, who owns what

Modes

The mode decides how eagerly agents use peers.

ModeBehavior
auto (default)Agents start peers on their own initiative when work splits into independent parts, or when two approaches are worth trying side by side.
manualThe tools are available, but agents start a peer only when you ask.
offNo peers. The tools are hidden from the model and the session does not join the grove. The graph and the history still work.
/grove peers                 choose the mode from an inline list
/grove peers manual          set the mode for this repository
/grove peers manual global   set your default for every repository
pi --grove-peers off         override the mode for one run

/grove peers temporarily replaces the input editor with an English, description-backed mode list. The current mode is selected initially. Use j/k or the arrow keys to move, Enter to apply to this repository, and Esc to cancel without changing anything. The editor returns when the list closes. In non-TUI modes, the command reports the current mode instead.

Command arguments also support completion: /grove peers offers auto, manual, and off with explanations; /grove peers manual offers global. A global default does not overwrite repository-specific settings.

Background peers use your model account like any other pi session. In auto mode an agent can start peers without asking, up to the limit. If you want to decide each time, run /grove peers manual global once.

Settings

SettingDefaultMeaning
mode"auto""auto", "manual" or "off"
maxPeers4How many peers can be alive at a time, including your own sessions

Settings are read from two JSON files. A value in the second file overrides the first:

  1. ~/.pi/agent/pi-grove/config.json: your defaults for every repository.
  2. <repository>/.git/pi-grove/config.json: one repository. All peers in the repository share it.
{ "mode": "manual", "maxPeers": 2 }

Commands

/grove spawn <name> <task>     start a peer from the current point
/grove send <peer|all> <text>  send a message
/grove stop <peer>             stop a background peer

The Peers tab of /grove shows every peer with its status, the recent messages and the board. Keys: n start a peer, m send a message, x stop a background peer, d forget a peer that has exited, o open the same inline mode picker, enter show the peer in the graph.

Skill

pi-grove ships a skill, grove-peers, that agents load when they plan peer work: when a peer is worth starting instead of a subagent, a template for the task, how to use the board and messages, and how to verify and integrate a peer's branch. It is loaded in every mode; with peers off the grove tools are hidden, so agents have no reason to use it.

What a peer may do

Peers are told the following, and the extension itself never does more:

  • A background peer works only inside its own worktree. It commits to its own branch, unless your project instructions or the task say not to commit; then it leaves its changes in the worktree and says so.
  • No peer merges, pushes or deletes a branch unless you asked for it. A peer reports which branch is ready; integrating it is your decision.
  • A new worktree starts from the last commit. Uncommitted changes in your checkout are not copied, and grove_spawn says so when there are any.
  • Stopping a peer keeps its worktree and its branch.
  • Forgetting an exited peer removes its worktree with plain git worktree remove, which refuses when the worktree has uncommitted changes. The branch is always kept.
  • A background peer loads the same extensions, skills and context files as any pi session started in that directory.
  • A background peer has nobody to answer dialogs. A dialog from any extension, such as a permission prompt, is cancelled, so that extension takes its safe default. A peer that is blocked this way says so in its report.

Background peers are child processes of the pi session that started them. They stop when that session exits. Their sessions, worktrees and branches stay, and pi --continue in a worktree picks the work up again.

Files

PathContent
<repository>/.git/pi-grove/The grove's shared state: peer records, inboxes, the message log, the board, config.json, and the logs of background peers in logs/. It is inside .git, so it is never committed and every worktree sees the same one.
~/.pi/agent/pi-grove/config.jsonYour default settings
<repository>.grove/<name>/Worktrees of peers
~/.pi/agent/pi-grove/reflog/The history of moves, one file per session

Session files are written only by pi, with one exception: starting a peer writes the peer's new session file, a copy of the path from the root of your session to the fork point. It is stored where pi keeps the sessions of the peer's worktree.

Limitations

  • The view needs pi's interactive mode. In RPC and print mode only the tools and the history recording are active.
  • A peer forks at the start of the current turn, not in the middle of it: a session cannot be cut between a tool call and its result.
  • The tip of another session is taken from the last entry in its file. If that session has jumped back in its own tree, its (name) marker can be on a different branch than the one it is on.
  • A session that was started with --no-session has no file, so it has no related sessions and its peers cannot link back to it.
  • Peers coordinate through files in .git. They must run on the same machine.

Development

npm install
npm run check    # type check
npm test         # unit tests
npm run demo -- ~/.pi/agent/sessions/<dir>/<session>.jsonl   # print a session as a graph
pi -e .          # run pi with the extension from this checkout

GitHub Actions runs npm ci, npm run check, and npm test on Node.js 22 and 24 for pull requests and pushes to main. The CI workflow can also be started manually from the Actions tab. It does not publish packages or modify the repository.

scripts/ansi-to-svg.ts turns a tmux capture-pane -p -e capture into an SVG. The screenshot above was made with it.

The code is split so that most of it runs without pi:

PathRole
src/graph/model.tsSession entries to graph nodes: filtering, folding, merge edges, ordering
src/graph/layout.tsLane layout and box-drawing glyphs
src/graph/render.tsA row as styled segments
src/graph/sessions.tsReading session files and finding related sessions
src/reflog/journal.tsThe history of moves
src/peers/hub.tsShared state on disk
src/peers/worktree.tsGit worktrees
src/peers/runtime.tsForking a session file and running a background peer
src/peers/controller.ts, tools.ts, prompt.tsWiring peers into a pi session
src/ui/grove-view.tsThe panel
src/ui/chat.tsHow peer activity is drawn in the conversation
src/index.tsExtension entry point

License

MIT