pi-move-session

Move a live Pi session to another working directory, including back to a repository's main worktree

Package details

extension

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

$ pi install npm:pi-move-session
Package
pi-move-session
Version
0.3.0
Published
Apr 26, 2026
Downloads
268/mo · 200/wk
Author
w-winter
License
MIT
Types
extension
Size
15.7 KB
Dependencies
0 dependencies · 1 peer
Pi manifest JSON
{
  "extensions": [
    "extensions/move-session.ts"
  ]
}

Security note

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

README

Move Session for Pi (pi-move-session)

Losslessly move a live Pi session to a different working directory and jump into the new session. Useful when you need a session to move to a different working directory after it's already built up valuable context.

Install

From npm:

pi install npm:pi-move-session

From the dot314 git bundle (filtered install):

{
  "packages": [
    {
      "source": "git:github.com/w-winter/dot314",
      "extensions": ["extensions/move-session.ts"],
      "skills": [],
      "themes": [],
      "prompts": []
    }
  ]
}

Usage

/move-session <targetCwd>

Supports ~ expansion (e.g. /move-session ~/code/my-project).

Use /move-session $main-worktree from a Git linked worktree to move the session back to the repository's main worktree.

If your current /tree selection is not the session file's default branch tip, the extension warns before proceeding because that selection is not preserved yet.

How it works

  1. Forks the current session JSONL into the target cwd's session bucket via SessionManager.forkFrom()
  2. Clears the fork header's parentSession pointer
  3. Tears down the parent's terminal state (Kitty keyboard protocol, bracketed paste, cursor visibility)
  4. Spawns a new pi --session <fork> process in the target directory with inherited stdio
  5. Trashes the old session file (via trash if available; never permanently deletes)
  6. Destroys the parent's stdin so it can't steal keypresses from the child

The parent process stays alive as an inert wrapper that forwards the child's exit code.