<!--
SPDX-FileCopyrightText: Amolith <amolith@secluded.site>

SPDX-License-Identifier: CC0-1.0
-->

# pi-extensions

A collection of [Pi](https://github.com/badlogic/pi-mono) extensions. They're
all quite rough currently, having just been imported to this repo from ad-hoc,
vibed individual scripts created by saying "go change
`~/.config/pi/extensions/foo.ts` so it bars".

## Packages

### `@amolith/pi-handoff`

[![npm](https://img.shields.io/npm/v/@amolith/pi-handoff)](https://www.npmjs.com/package/@amolith/pi-handoff)

Get to the end of the thing you're doing, then use a lightweight subagent to
extract particular bits from the current session and create a new one from those
bits with `/handoff thorough goal description`. You can also tell Pi to hand
something off (it has a tool).

```sh
pi install npm:@amolith/pi-handoff
```

> Based on [handoff.ts](https://github.com/pasky/pi-amplike/blob/main/extensions/handoff.ts)
> and [session-query.ts](https://github.com/pasky/pi-amplike/blob/main/extensions/session-query.ts)
> by Petr Baudis, licensed MIT accordingly. Reworked so the subagent calls a
> tool instead of expecting it to produce well-formed JSON, added an auto-submit
> countdown, and make the extraction model configurable via `PI_HANDOFF_MODEL`.

### `@amolith/pi-answer`

[![npm](https://img.shields.io/npm/v/@amolith/pi-answer)](https://www.npmjs.com/package/@amolith/pi-answer)

See that Pi spit a bunch of Markdown at you with some embedded questions, use
`/answer` to have a lightweight subagent extract those questions so you can
answer them in a nice form instead of mentally parsing all that LLM-speak. For
best results, give a good description of `/answer what you want to turned into questions for answering`.

```sh
pi install npm:@amolith/pi-answer
```

> Based on [answer.ts](https://github.com/mitsuhiko/agent-stuff/blob/main/pi-extensions/answer.ts)
> by Armin Ronacher, licensed Apache-2.0 accordingly. Reworked so the subagent
> calls a tool instead of expecting it to produce well-formed JSON, rewrote the
> system prompt with few-shot examples, added a notes editor (Alt+N) and
> fallback extraction with the current model when the preferred model is
> unavailable.

### `@amolith/pi-questionnaire`

[![npm](https://img.shields.io/npm/v/@amolith/pi-questionnaire)](https://www.npmjs.com/package/@amolith/pi-questionnaire)

Have Pi construct on-the-fly questionnaires to ask you stuff before it goes off
and does the wrong thing.

```sh
pi install npm:@amolith/pi-questionnaire
```

> Based on [questionnaire.ts](https://github.com/badlogic/pi-mono/blob/main/packages/coding-agent/examples/extensions/questionnaire.ts)
> by Mario Zechner, licensed MIT accordingly. Added a free-text notes editor,
> word wrapping for long prompts, and custom answers are sent as a steering
> user message so the user can go back and edit them later.

### `@amolith/pi-personas`

[![npm](https://img.shields.io/npm/v/@amolith/pi-personas)](https://www.npmjs.com/package/@amolith/pi-personas)

Drop markdown files in `$PI_CODING_AGENT_DIR/personas/` and switch between them
with `/persona`. Lets your agent be a grumpy senior today and a patient tutor
tomorrow. The active persona gets injected into the system prompt and persists
across sessions until you change it.

```sh
pi install npm:@amolith/pi-personas
```

> All mine :)

## Development

Prerequisites: [mise](https://mise.jdx.dev/) (installs bun automatically).

```sh
# Install dependencies
bun install

# Format, lint, and type-check everything
mise run check
```
