@monkeyman520/pi-session-tree-explorer0.1.0
Enhanced Session Tree Explorer extension for Pi coding agent with fast Vim navigation and safe branching
Untested on omp
This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.
Reports 0
No reports yet.
Readme
Pi Session Tree Explorer
An independently installable interactive Session Explorer extension for Pi coding agents. Supports non-destructive browsing and live Preview, reachable branch tip navigation, an in-memory restoration stack, tool-call aggregation, smart folding, contextual search, two-tier branch comparison, branch bookmarks, and session statistics. Native /tree remains completely unchanged.
Status
The v2.0 Interactive Session Explorer implementation (Spec 0008 / Ticket Set 0007) passes tsc --noEmit, Biome, Bun (including E01–E07 acceptance suites), and isolated Pi RPC loading/smoke checks on Windows x64 (Pi 1.5.2, Node.js >= 22.19.0). Live physical-terminal keyboard testing across WSL and Unix terminals remains external to automated headless verification.
Approved configuration constraints (Spec 0008 U4)
session.forkPositionaccepts only"at"(f/Fremain fixed At / Before actions).navigation.skipHiddenNodesandsearch.preserveFoldStateaccept onlytrue. Conflicting non-default values produce validation diagnostics and are rejected cleanly.fold.collapseLinearPathscompresses linear chains into expandable virtual summaries without mutating raw topology.session.busyBehavior = "wait"prompts for post-UI confirmation, notifies visibly while waiting, and revalidates session identity and safety before executing.
Compatibility, installation and resources
- Node.js >=22.19.0; TypeScript ESM with a Rolldown build.
- Verified against Pi
1.5.2on Windows x64 (prior v1.0 evidence used Pi1.5.0). Wildcard peer ranges are not universal compatibility claims. - Host peers:
@earendil-works/pi-coding-agent,@earendil-works/pi-ai,@earendil-works/pi-tui, andtypebox. - Rolldown inlines the private support library where used. Pi SDKs and TypeBox remain host peers, and each plugin owns its state and lifecycle.
- Extension resource:
dist/index.js.
After the package is available on npm, install it without a version pin:
pi install npm:@monkeyman520/pi-session-tree-explorer
pi update npm:@monkeyman520/pi-session-tree-explorer
Use pi update --extensions for all installed extensions. Pinned versions do not follow later releases. On a fresh launch after an update, Pi can show the bundled changelog under Extension Updates; the plugin does not poll for updates.
From the repository root, prepare the workspace and build before loading locally:
bun install --frozen-lockfile
bun run --cwd packages/pi-session-tree-explorer build
pi -e ./packages/pi-session-tree-explorer
# Or persist this local package:
pi install ./packages/pi-session-tree-explorer
Commands and interaction
| Command | Behavior |
|---|---|
/stree |
Open Explorer in TUI; explain the interactive requirement in other modes |
/stree config |
Open the installed-plugin settings panel, or show a text summary outside TUI |
/stree config reload |
Reload safely; retain the previous effective settings on failure |
/stree config <key> [v] |
Inspect or update an existing setting |
/stree help |
Show command usage |
Settings panels are discovered over pi.events from actually loaded plugins (ADR 0004/0005). The Explorer's help panel links to settings with s.
Core keys (87 cataloged Actions)
- Navigation:
j/kor arrows move visible rows;H/LeftandL/Rightmove logical parent/first child;gg/Groot/last;gccurrent active leaf;Ctrl+d/uhalf-page. - Branch & Tip traversal:
]b/[bsibling branch;gp/gb/gebranch parent/root/preferred leaf;]f/[fand]l/[lfork/leaf traversal;gaactive branch;gGo to Branch Tip (single-tip direct jump, multi-tip picker, explicit editor-restoration notice for user-message tips). - Preview & History Stack:
Taborpopens/toggles non-destructive Preview (live dual-pane on>= 100columns with 60/40 split; modal overlay on< 100columns);rRestore Previous pops and restores prior activeleafIdfrom the in-memory navigation stack;Rrefreshes host snapshot. - Folding & Tool Aggregation:
Space/l/htoggle/expand/collapse (including in-place expansion of[Tools ×N]aggregates);zR/zMexpand/collapse all;za/zs/zc/zrpolicy controls;fold.mode = "smart"expands short sessions (< 20turns) and folds tool chains/inactive branches in long sessions. - Search:
/opens Search (printablej/kedit query; arrows/Ctrl+n/pmove results;Enteraccepts and reveals ancestor paths with inline match highlighting;Esccancels/clears). - Session & Metadata:
Enterexecutes nativenavigateTree(with optional 3-option branch summary prompt whensession.promptSummary = true) or expands virtual summaries;f/FFork At/Fork Before;mhost label;Bbranch bookmark (★[name]);gBbranch switcher;gdTwo-Tier Branch Diff (zero-dep topology diff + progressivegit diff --stat);SSession Statistics;yi/yyclipboard ID/content;?effective help;qclose.
Three-Tier State & Configuration
- Global Config: Layered precedence
defaults -> global session-tree.json -> trusted .pi/session-tree.json -> runtime overrides, validated via TypeBox (session-tree.schema.json). - Session View State (
version: 2): Stored atstate/session-tree/<session-id>.jsonoutside Session JSONL. Persists only explicit user display overrides (explicitDisplayOverrides), manual fold sets,focusedBranchId,selectedNodeId, andbranchBookmarks. Legacyversion: 1files are automatically migrated on load, stripping fulldisplayOptionssnapshots so global config edits take effect immediately. - Runtime State:
sessionLeafIdis always sourced authoritatively fromctx.sessionManager.getLeafId(), decoupled fromselectedEntryId,previewNodeId, and the in-memoryNavigationHistorystack.
Default configuration summary
vimMode:truenavigation:initialFocus="active",branchNavigationScope="nearest-fork",branchWrap=false,focusFollowsSelection="branch-actions",autoRevealTarget=true,skipHiddenNodes=truedisplay:showAssistantNodes=false,showToolNodes=false,showThinkingNodes=false,showMetadataNodes=false,showCompactionNodes=true,depthMode="turn",showDepth=true,maxMessageLength=80,layout="normal"fold:mode="focused-only"(supports"smart","all","active-only","depth-limited","manual"),collapseInactiveBranches=true,collapseLinearPaths=false,rememberManualOverrides=true,maxExpandDepth=0search:mode="fuzzy",scope="all",includeHiddenNodes=true,autoExpandMatches=true,preserveFoldState=true,caseSensitive=false,maxResults=100context:enabled=true,showTokens=true,showPercentage=true,showModel=false,estimateHistorical=true,showEstimateMarker=true,lazyEvaluation=true,cacheSize=512session:forkPosition="at",navigateSummarize=false,promptSummary=false,confirmFork=false,busyBehavior="reject"performance:virtualRendering=true,renderOverscan=20,searchDebounceMs=40
Verification
After the root frozen install and build:
cd packages/pi-session-tree-explorer
bun run typecheck
bun run check
bun run test
bun run smoke
typecheck:tsc --noEmit(zero errors).check: Biome lint & format check.test: Bun unit, integration, and E01–E07 acceptance suite.smoke: Isolated temporary production dependency install + live Pi RPC verification of/streecommands and native Navigate / Fork At / Fork Before safety.
Permissions and risks
Extensions run with Pi's process privileges, not in a sandbox:
- Reads host session data, trusted configuration, and per-session view state.
- Writes global configuration and isolated per-session view files (
state/session-tree/<session-id>.json). - Invokes
git rev-parse,git diff --stat, andgit status --shortread-only when running Branch Diff inside a Git workspace. - Explicit labels, Navigate, and Fork use native host APIs; Fork creates independent session files.
- Clipboard Actions invoke
clip.exe,pbcopy,wl-copy, orxclip. - Pure browsing, search, stats, and context metrics do not issue model requests. Native branch summarization occurs only when explicitly configured or chosen by the user.