# pi-tui-status-beautifier

Formats Pi extension status badges consistently, with an opt-in Pi 1.7 telemetry footer and priority badge folding on narrow panes.

[![npm version](https://img.shields.io/npm/v/pi-tui-status-beautifier?color=blue)](https://www.npmjs.com/package/pi-tui-status-beautifier)
[![Tests](https://img.shields.io/badge/Tests-24%2F24%20Pass-brightgreen)](extensions/)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)

**English** | [简体中文](./README_zh.md)

## Overview

Pi extensions write status text in different conventions — package prefixes, ANSI wrappers, brackets, and emojis — that wrap unevenly inside split terminal panes. `pi-tui-status-beautifier` normalizes extension names (`pi-anchor` → `anchor`, `pi-control-chrome` → `chrome`) without truncating away meaningful status words like `"error: port 3000 in use"` or `"tsserver ready"`.

- **Non-invasive default (`status-only`)**: keeps Pi's native footer untouched and only styles extension status items unless you explicitly enable the two-line footer.
- **Opt-in 2-line footer (`footer: on`)**: replaces `setFooter` with Pi 1.7 parity metrics (`~/path`, `sessionName`, `↑↓RW`, latest-turn `CH%`, `$cost`, `(sub)`, `?/<win>`, multi-provider prefix) on Line 1, plus greedy priority badge folding and a live 300ms spinner interval on Line 2.

## Visual Demo

![pi-tui-status-beautifier presets](assets/hero-en.svg)

```text
Before: [anchor: ⌖ 3]  [toolflow: 3 chained]  [pi-lingual: zh ⇄ en]  [subagent: working]
After:  anchor · ⌖ (3)  toolflow · ⌬ (3 chained)  lingual · ⇄ (zh ⇄ en)  subagent · ◐ (working)
```

4 font-safe presets (`claude` default, `stream`, `nord`, `glow`), plus `custom` (edited directly via JSON) and `off`.

## Install & Usage

```bash
pi install npm:pi-tui-status-beautifier
```

`/beautify` supports interactive Tab completions:

```text
/beautify                  # interactive preset + scope picker
/beautify info             # show current style, scope, and settings target
/beautify nord             # switch preset while keeping current scope
/beautify footer           # toggle the opt-in 2-line telemetry footer
/beautify stream full      # set preset and enable the 2-line footer
/beautify custom           # activate custom config, or open multi-line JSON editor
/beautify custom edit      # open ctx.ui.editor() directly to edit custom style JSON
/beautify off              # restore native Pi status/footer and remove config keys
```

Add `--local` (e.g. `/beautify claude --local`) to store overrides in `./.pi/settings.json` instead of `~/.pi/agent/settings.json`.

## Configuration & Architecture

Settings live under `"beautifier"` in `~/.pi/agent/settings.json` (or `./.pi/settings.json` when project-scoped):

```json
{
  "beautifier": {
    "style": "claude",
    "fullFooter": false
  }
}
```

- **Priority & folding**: unified severity classification (`error`, `warning`, `running` stay high priority) packs compact idle badges greedily alongside `(+N idle)` within `width - 2` using `@earendil-works/pi-tui` cell widths.
- **Retired config migration**: older saved names (`linear`, `minimal`, `powerline`, `glass`, `tokyo`, `matrix`, `openai`, `gemini`) migrate automatically when loaded from `settings.json`.
- **Clean revert**: `/beautify off` (or `default`) deletes `beautifier` from both local and global settings files and restores original status strings.
- **Ecosystem**: preserves `⌖` (`pi-anchor`), `⌬` (`toolflow`), and `⇄` (`pi-lingual`).

```bash
npm run check   # tsc --noEmit + eslint + 24 Vitest tests
```

MIT © [Jason](https://github.com/3ZEROS12)
