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

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

# `@amolith/pi-personas`

[![pi-personas on NPM](https://img.shields.io/npm/v/@amolith/pi-personas)](https://www.npmjs.com/package/@amolith/pi-personas)
[![Licensed under MutuaL-1.2](https://img.shields.io/badge/License-MutuaL--1.2-af2e1a?style=flat&labelColor=110402&link=https%3A%2F%2Fcodeberg.org%2FMutualism%2FMutualist-License)](https://codeberg.org/Mutualism/Mutualist-License)
[![REUSE status](https://api.reuse.software/badge/git.secluded.site/pi-extensions)](https://api.reuse.software/info/git.secluded.site/pi-extensions)
[![scratchanitch.dev badge](https://img.shields.io/badge/scratchanitch-dev-FFC4B5)](https://scratchanitch.dev)
[![Liberapay donation status](https://img.shields.io/liberapay/receives/Amolith.svg?logo=liberapay)](https://liberapay.com/Amolith/)

Code with a grumpy senior today and work with a patient tutor tomorrow. Switch
between them with `/persona`. The active one persists across sessions until
changed. Setting a persona prior to startup appends it to the system prompt.
Changing it mid-session sends the persona content as a steering message.

Personas are loaded from `persona-name.md` files in
`$PI_CODING_AGENT_DIR/personas/`. `/persona` is interactive and `/persona grug`
sets it directly.

## Install

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

## Write personas

Create one markdown file per persona in `$PI_CODING_AGENT_DIR/personas/`:

```text
$PI_CODING_AGENT_DIR/personas/grumpy-senior.md
$PI_CODING_AGENT_DIR/personas/patient-tutor.md
```

The file name without `.md` is the persona name. That's what `/persona` and the
`persona` setting use.

## Switch personas

Open an interactive picker:

```text
/persona
```

Switch directly:

```text
/persona patient-tutor
```

Clear the active persona:

```text
/persona none
```

`unset` and `clear` also clear the active persona.

## Remember the active persona

The active persona persists as the `persona` key in
`$PI_CODING_AGENT_DIR/settings.json`:

```json
{
  "persona": "patient-tutor"
}
```

The extension only accepts persona names that match markdown files under
`$PI_CODING_AGENT_DIR/personas/`.

## What happens when it changes

If a persona is set before startup, the extension reads it at session start and
appends it to the system prompt for the lifetime of the session.

When you set or clear a persona mid-session, the extension updates the setting
immediately and sends a one-shot hidden reminder message. It does not rewrite
the session's system prompt mid-stream.
