@ogulcancelik/pi-worktree
Relocate the active pi session to another git working tree while preserving conversation history.
Package details
Install @ogulcancelik/pi-worktree from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:@ogulcancelik/pi-worktree- Package
@ogulcancelik/pi-worktree- Version
0.1.1- Published
- May 16, 2026
- Downloads
- 48/mo · 48/wk
- Author
- ogulcancelik
- License
- MIT
- Types
- extension
- Size
- 11.5 KB
- Dependencies
- 0 dependencies · 0 peers
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-worktree
Relocate the active pi session to another git working tree while preserving the full conversation history. When you create a new worktree or switch to another repository and want to keep working there without losing context, this extension forks the session file, moves it to the new directory, and auto-continues.
Install
pi install npm:@ogulcancelik/pi-worktree
Or add manually to ~/.pi/agent/settings.json:
{
"packages": ["npm:@ogulcancelik/pi-worktree"]
}
What it does
switch_worktree tool
Validates that the target path is inside a non-bare git working tree, then pre-fills the editor with /switch-worktree <path>. Press Enter to confirm the relocation.
/switch-worktree command
Direct command for manual relocation. Usage:
/switch-worktree <path>
How the switch works
- Validates the path is inside a non-bare git working tree
- Forks the current session file to the worktree directory via
SessionManager.forkFrom - Removes the
parentSessionreference so the forked session is standalone - Switches the active session to the new file
- Deletes the old session file
- Sends an auto-continue message so work resumes automatically
Herdr integration
When running inside herdr (HERDR_ENV is set), the extension emits herdr:blocked events so the UI can show a pending state while waiting for the user to press Enter. Outside herdr, these events are silently skipped.
Requirements
- pi v0.40+
- Git
License
MIT