# pi-export-config

Pi package that adds commands for backing up and restoring `~/.pi/agent` configuration, including extensions, themes, skills, auth files, MCP config, and extension secrets/state.

> Security: this extension intentionally handles secrets. Review archives and keep private repositories private.

## Install

```bash
pi install npm:pi-export-config
```

Then run `/reload` if pi is already open.

## Commands

### Local encrypted export/import

```text
/export-config [output-path]
/import-config <archive-path> <password>
```

`/export-config` creates a password-protected archive and prints a generated 12-character lowercase alphanumeric password.

### SSH import

```text
/import-config user@host
```

Tries SSH public-key auth first. If it fails, prompts for a password and uses `sshpass` if available. Remote exports are stored on the remote machine under `~/.pi/agent/export-config/` and are unencrypted because transport is protected by SSH.

### GitHub sync

```text
/export-config-github [owner/repo|repo]
/import-config-github [owner/repo|repo]
```

Uses the GitHub CLI (`gh`) and creates/uses a private repository. Default repo name is `pi-config-backup`. Exports include both `install.sh` and `install.ps1` setup scripts so the latest config can be installed on Linux/macOS or Windows PowerShell.

## Clean import

Import flows can perform a clean import: the current config is backed up, then current `~/.pi/agent` is reset except for `sessions/` and `backups/`, then the selected config is applied.

## Requirements

- `tar`
- `openssl` for local encrypted archives
- `ssh` for SSH import
- `sshpass` only for SSH password fallback
- `gh` and `git` for GitHub sync
- Windows setup script uses PowerShell 5.1+, `tar.exe`, and `winget` when it needs to install Node.js or GitHub CLI

