pi-session-merge
Pi Coding Agent Extension to import summarized context from another session.
Package details
Install pi-session-merge from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:pi-session-merge- Package
pi-session-merge- Version
0.1.0- Published
- May 5, 2026
- Downloads
- not available
- Author
- robbirob
- License
- MIT
- Types
- extension
- Size
- 23.1 KB
- Dependencies
- 0 dependencies · 1 peer
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-merge
A Pi Coding Agent Extension that adds /merge, allowing you to import summarized context from another Pi session into your current session.
pi-session-merge performs a safe context merge instead of rewriting or raw-merging session history. It lets you pick a source session, previews a structured summary of its goals, decisions, files, commands, constraints, risks, and TODOs, and then inserts that reviewed summary into the current session as contextual information.
Features
- Adds a
/mergeslash command to Pi - Lists candidate sessions from the current working directory by default
- Supports searching all known sessions with
/merge --all - Excludes the current session from candidates
- Builds a deterministic structured summary
- Shows an editable preview before insertion
- Requires confirmation before writing anything
- Inserts a clearly labeled
Imported Session Contextblock - Does not modify the source session
- Does not raw-merge or rewrite Pi JSONL session files
Installation / Usage
Install it as a Pi package so Pi uses the package name instead of showing the extension as src.
Install from GitHub:
pi install git:github.com/robbirob/pi-session-merge
For local development from a checkout, install the package directory instead of pointing Pi at src/index.ts:
pi install /path/to/pi-session-merge
Use pi -e ./index.ts only for quick one-off testing.
Then inside Pi:
/merge
Useful variants:
/merge --all
/merge --cwd ~/work/some-project
/merge <session-id-or-name-fragment>
How It Works
When /merge runs, the extension:
- Finds other Pi sessions for the current working directory.
- Lets you select a source session.
- Reads the selected session safely.
- Extracts useful messages from the active/latest branch.
- Builds a structured context summary.
- Opens an editable preview.
- Asks for confirmation.
- Inserts the reviewed summary into the current session as a custom context message.
The inserted block is marked as imported context and includes source metadata.
Safety Notes
This extension intentionally does not perform a raw session merge. Pi session files can contain branches, parent/child relationships, tool calls, compactions, labels, model metadata, and other internal state. Raw-merging those files risks corruption or misleading context.
For the MVP, pi-session-merge only imports a summarized context block.
It will not:
- mutate the source session
- rewrite current session history
- copy raw JSONL entries
- delete, compact, rename, or relabel sessions
- apply file patches or Git merges
Development
Run tests:
npm test
Project structure:
src/
index.ts
commands/
sessions/
merge/
ui/
utils/
test/
The core session parsing and digest-building logic is kept in pure functions where possible so it can be tested without depending on your real ~/.pi session directory.
License
MIT