# pi-fork-session-herdr

A Pi extension that forks the current persisted session into a new Herdr pane without replacing or stopping the Pi session in the original pane.

This is useful while the current agent is still running: invoke the command, continue the original task in its pane, and start an independent conversation from the saved session state in the new pane.

## Requirements

- Pi interactive mode
- Pi running inside Herdr
- A persisted Pi session (not `--no-session`)
- `herdr` and `pi` available on `PATH`

## Install

From GitHub:

```bash
pi install git:github.com/wujunchuan/pi-fork-session-herdr
```

For local development:

```bash
pi install /Users/john/Project/github/pi-fork-session-herdr
```

Then reload Pi:

```text
/reload
```

## Commands

```text
/fork-session-herdr [right|down] [--focus|--no-focus]
/fork-herdr [right|down] [--focus|--no-focus]
```

Examples:

```text
/fork-session-herdr
/fork-session-herdr down
/fork-session-herdr right --no-focus
/fork-herdr --no-focus
```

Defaults are `right` and `--focus`.

## How it works

The extension:

1. Reads the current persisted session file from Pi.
2. Splits the current Herdr pane.
3. Starts `pi --fork <session-file>` in the new pane.

It intentionally does **not** call Pi's `ctx.fork()`, because that would replace the session in the original pane and abort its running agent.

The new Pi process sees the session state that had already been saved when the command ran. An assistant response that is still streaming may therefore be absent or incomplete in the fork.

## Development

```bash
npm install
npm run check
```

## License

MIT
