# pi-toolbox

A toolbox of small quality-of-life extensions for the [pi coding agent](https://github.com/earendil-works/pi-mono).

## Features

### Copy all editor text to clipboard

Press the hotkey (default **`Alt+C`**) to copy the *entire* contents of the
input editor to the system clipboard — no mouse selection needed.

pi's built-in `Ctrl+C` clears the editor and `Ctrl+X` copies the last *assistant*
message, but there was no single-key way to copy what *you* are currently typing.
This extension fills that gap.

## Installation

Published on npm as `@yuanwentao/pi-toolbox`. Install it with pi:

```bash
pi install npm:@yuanwentao/pi-toolbox
```

This adds it to `~/.pi/agent/settings.json` so it loads in every session.

**Try without installing** — load it just for the current run:

```bash
pi -e npm:@yuanwentao/pi-toolbox
```

**From git** (tracks a branch, no npm publish needed):

```bash
pi install git:github.com/15wtyuan/pi-toolbox
```

**From a local checkout** (for development):

```bash
pi -e ./src/index.ts
```

After editing `settings.json` by hand, run `/reload` in pi to pick up the change.

## Configuration

The hotkey is remapped in pi's standard `~/.pi/agent/keybindings.json`, using
the keybinding id `pi-toolbox.copyEditor`. A single string or an array of
strings (to bind multiple keys) is accepted:

```json
{
  "pi-toolbox.copyEditor": "ctrl+shift+c"
}
```

or, to bind several keys at once:

```json
{
  "pi-toolbox.copyEditor": ["alt+c", "ctrl+shift+c"]
}
```

Run `/reload` in pi after editing.

> **Why keybindings.json?** Pi's own shortcuts live there, so it's the natural
> place. Note that pi's `registerShortcut()` binds a concrete key sequence
> (like `alt+c`), not a keybinding id, and there is no extension API to register
> a custom id into pi's native keybinding table. So this extension reads your
> `keybindings.json` and binds the key you configured there — the id is ours,
> the file is pi's. Like pi's built-in keybindings, only the global
> `~/.pi/agent/keybindings.json` is read (not a project-local one).

### Key id format

Keys use the `modifier+key` format, e.g. `alt+c`, `ctrl+shift+c`, `ctrl+alt+k`.
See pi's [keybindings docs](https://pi.dev/docs/keybindings) for the full grammar.
Avoid reusing keys that pi already binds (e.g. `ctrl+c`, `ctrl+x`, `ctrl+d`).
The default `alt+c` is free — pi binds other `alt+` combos but not `alt+c`.

## Development

```bash
npm install        # install type dependencies
npm run typecheck  # tsc --noEmit
```

TypeScript is loaded directly by pi via jiti, so there is no build step — just
edit `src/index.ts` and `/reload`.
