# @jrryfn/pi-retune

One-command session naming toggle for **pi**.

- Run `/retune` to auto-name old sessions (repo-scoped by default).
- Run `/retune` again to restore the original names (only if the session name is still what retune set).

## Install

```bash
pi install npm:@jrryfn/pi-retune
```

## Usage

### Happy path

- `/retune` (auto apply)
- `/retune` again (auto restore)

### Options

- `--review` open a plan editor to edit/skip items before applying
- `--dry` preview plan only
- `--scope repo|cwd|all`
- `--limit 200`
- `--since 30d` (or ISO date like `2026-01-01`)
- `--template "#{moduleOrRepo} - {primaryTask|caveman|title|truncate:28}"`
- `--no-model` never call a model
- `--all` include already-named sessions (overwrite)

## Template placeholders

Supported placeholders (all are optional in templates):

- `{moduleOrRepo}` fallback module slug (from `{moduleName}`, else `packages/<name>`, else `{repo}`)
- `{moduleName}` model-derived module name (if configured)
- `{primaryTask}` model-derived or heuristic task phrase (kept short; caveman-style by default)
- `{repo}` repo folder name
- `{branch}` best-effort git branch (blank if unavailable)
- `{ticket}` extracted `ABC-123` or `#123`
- `{taskType}` `feat|fix|refactor|docs|test|chore`
- `{created}` `{modified}` dates (`YYYY-MM-DD`)
- `{messages}` message count
- `{id8}` short session id

Modifiers:
- `|lower |upper |title |kebab |snake |sanitize |caveman |truncate:N |default:TEXT`

Escape braces:
- `{{` -> `{` and `}}` -> `}`

## Configuration

Merged global -> project:

- `~/.pi/agent/retune.json`
- `<repo>/.pi/retune.json`

Legacy names still supported:

- `~/.pi/agent/pi-retune.json`
- `<repo>/.pi/pi-retune.json`

Example: see `example.json`.
