pi-bar 0.3.43 → 0.3.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -41,31 +41,52 @@ The footer adapts to terminal width without extra configuration:
41
41
 
42
42
  - **Model, thinking level, and context percentage take priority.**
43
43
  - Separators have two spaces on each side by default, for a roomier display.
44
- - Progress text shrinks first. If space is still tight, separator padding reduces to one space per side before compacting content. CWD then compacts from its preferred path to `parent/project`, then `project`; context window size is omitted when needed.
45
- - Extension badges stay in their published order. Badges that cannot fit are hidden whole, with `+N` showing how many are behind the overflow. Open `/bar status` to inspect their text and visibility by key.
44
+ - Progress text shrinks first. If space is still tight, separator padding reduces to one space per side before compacting content. CWD then compacts from its preferred path to `parent/project`, then `project`; context window size is omitted when needed. An enabled provider prefix can yield before the model name is clipped.
45
+ - Optional token totals, cost, and cache-hit ratio yield whole under width pressure, before overflowing extension badges. Numeric metrics are never shown partially.
46
+ - Extension badges stay in their published order. Badges that cannot fit are hidden whole, with `+N` showing how many are behind the overflow. Open `/bar badges` to inspect their text and visibility by key.
46
47
  - On very narrow terminals, progress and CWD yield to core information. If even the core cannot fit, the model name is truncated first. At extreme widths, not every value or overflow count can remain visible.
47
48
  - Widening the terminal restores the full display. Thinking and context retain their semantic colors throughout.
48
49
 
49
- Existing segment visibility settings still apply; CWD remains opt-in.
50
+ Existing visibility settings still apply. CWD, usage metrics, and the provider prefix are opt-in; the default footer is unchanged.
50
51
 
51
52
  ## Customization
52
53
 
53
- pi-bar works out of the box. Run `/bar` inside pi to choose which footer segments and extension statuses are shown:
54
+ **Start with `/bar`.** It opens all footer settings; you do not need to learn command groups.
54
55
 
55
56
  ```text
56
57
  /bar
57
58
  ```
58
59
 
59
- Toggle `Model`, `Thinking level`, `Context usage`, `Current directory`, `Progress update`, and `Extension statuses` between `shown` and `hidden`. If other extensions have published status badges, `/bar` also shows fine-grained `Status: <key>` rows plus a `New extension statuses` default. You can also use commands:
60
+ Type to find a setting, then press Enter/Space to change it. Changes save immediately; Esc closes the screen rather than undoing them.
61
+
62
+ Related settings stay together:
63
+ - **Model → Show provider:** model visibility and its optional provider prefix.
64
+ - **Progress update → Progress model:** progress visibility and a searchable model picker.
65
+ - **Extension badges → Choose badges:** overall badge visibility and a separate screen for individual badges. Badge lists do not crowd the main settings panel. Esc from that screen returns to settings.
66
+
67
+ For quick changes, Tab offers action-oriented commands with short explanations:
68
+
69
+ | Command | Purpose |
70
+ | --- | --- |
71
+ | `/bar settings` | Open all settings, just like `/bar`. |
72
+ | `/bar show <items>` | Show footer items. |
73
+ | `/bar hide <items>` | Hide footer items. |
74
+ | `/bar badges` | Choose badges published by other extensions. |
75
+ | `/bar provider [show\|hide]` | Show, hide, or inspect the provider prefix. |
76
+ | `/bar progress-model [auto\|provider/model]` | Choose or inspect the progress model. |
77
+ | `/bar help` | Show commands, examples, and current visibility settings. |
60
78
 
61
79
  ```text
62
- /bar segments list
63
- /bar segments only model context
64
- /bar segments hide progress
65
- /bar segments show thinking
80
+ /bar hide progress
81
+ /bar show cost tokens
82
+ /bar badges hide mcp
66
83
  ```
67
84
 
68
- Allowed segments are `model`, `thinking`, `context`, `cwd`, `progress`, and `extensions`. The `cwd` segment is off by default. The `progress` segment stays hidden until pi-bar has a current update. The `extensions` segment stays hidden when no extension has set a status.
85
+ Footer item names are `model`, `thinking`, `context`, `cache_hit_ratio`, `cost`, `tokens`, `cwd`, `progress`, and `extensions`. Use `/bar show all` or `/bar hide all` to change all footer items at once. `cwd`, `cache_hit_ratio`, `cost`, and `tokens` are off by default. Enabled items can still be invisible while waiting for data or when terminal space is tight.
86
+
87
+ Tab completes item names, badge keys, and configured progress-model IDs while preserving preceding arguments, including comma-separated lists such as `/bar show model,ca`.
88
+
89
+ **Existing commands still work:** `/bar config`, `/bar segments ...`, `/bar status ...`, and `/bar list` are compatibility aliases, not additional choices in the top-level menu. `/bar list` and `/bar segments list` only report enabled footer items. Advanced commands such as `/bar segments only model context` remain available.
69
90
 
70
91
  You can also set startup defaults with environment variables before launching pi:
71
92
 
@@ -79,7 +100,7 @@ PI_BAR_SHOW=model,context pi
79
100
  Enable the optional `cwd` segment to distinguish projects and sessions:
80
101
 
81
102
  ```text
82
- /bar segments show cwd
103
+ /bar show cwd
83
104
  ```
84
105
 
85
106
  Or set startup segments with `PI_BAR_SHOW=model,thinking,context,cwd,progress,extensions`.
@@ -98,29 +119,91 @@ The cap must be an integer of at least 8; invalid values use 36. Very long direc
98
119
 
99
120
  This is Pi's session working directory (`ctx.cwd`), not a live shell directory: `cd` inside a tool command does not change it. Visibility persists through the existing `/bar` configuration.
100
121
 
122
+ ### Show the model provider
123
+
124
+ Provider prefixes are hidden by default. Enable `Show provider` in `/bar`, or use:
125
+
126
+ ```text
127
+ /bar provider show
128
+ /bar provider hide
129
+ /bar provider
130
+ ```
131
+
132
+ The last command reports the current setting. The choice persists as `showProvider` in `~/.pi/agent/pi-bar.json`; an absent setting means `false`.
133
+
134
+ ```text
135
+ claude-opus-4.7 # default
136
+ anthropic/claude-opus-4.7 # direct provider, enabled
137
+ openrouter/claude-opus-4.7 # routed provider, enabled
138
+ ```
139
+
140
+ The prefix uses the actual model provider, not a namespace embedded in the model ID. It stays inside the model segment: hiding `model` hides both. Under width pressure, the prefix yields before clipping the model name and returns when space is available.
141
+
142
+ ### Show cache, cost, and token metrics
143
+
144
+ Enable any of the optional metrics through `/bar` or the quick visibility commands:
145
+
146
+ ```text
147
+ /bar show cache_hit_ratio cost tokens
148
+ ```
149
+
150
+ ```text
151
+ claude-opus-4.7 ❯ think:med ❯ 2.6% / 1.0M ❯ CH:84% ❯ ≈$0.123 ❯ ↑12k ↓3k
152
+ ```
153
+
154
+ | Segment | Meaning |
155
+ | --- | --- |
156
+ | `cache_hit_ratio` | Latest active-branch assistant prompt's cache-read percentage: `cacheRead / (input + cacheRead + cacheWrite)`. Hidden when that response has no reported prompt usage. Colored green at 90% or higher, yellow from 50% up to 90%, and red below 50% (mostly cache misses). Restored on resume and `/tree`; tool, summary, and progress calls do not replace this value. |
157
+ | `cost` | Estimated dollar cost for recorded usage in the current session file. `≈` means an estimate, **not an invoice**. |
158
+ | `tokens` | Cumulative input (`↑`, including cache reads and writes) and output (`↓`, including reported reasoning tokens). These are usage totals, not current context size or tokens/sec. |
159
+
160
+ Cost and token totals include assistant responses, usage reported by tools, compaction/branch summaries, and pi-bar progress calls. They include all branches in the current session file, so `/tree` does not erase prior spend; `/new` starts fresh. Both stay hidden until usage is available. A zero-cost response with token usage still shows `≈$0.000`.
161
+
162
+ Progress usage is saved as numeric-only `pi-bar-progress-usage` custom entries, without prompts or response text. These entries survive reloads but are not sent to the main model. Older sessions may lack progress-call usage. Requests with no reported usage, including some failed/interrupted calls, cannot be counted.
163
+
164
+ Prices come from the usage estimates Pi/providers report. Subscription allowances, invoices, and missing/custom model pricing can differ; a reported zero is not a billing guarantee. Metrics make no additional model requests. Usage is aggregated at lifecycle events, not by scanning history on every footer render.
165
+
101
166
  ### Configure live progress updates
102
167
 
103
- pi-bar shows a short, plain-English description of what pi is working on right now. It refreshes as pi works and resets when you switch branches in the session tree, so stale updates never follow you across tasks. Hide `Progress update` in `/bar`, run `/bar segments hide progress`, or set `PI_BAR_SHOW` without `progress` to disable it.
168
+ pi-bar shows a short, plain-English description of what pi is working on right now. It refreshes as pi works and resets when you switch branches in the session tree, so stale updates never follow you across tasks. Hide `Progress update` in `/bar`, run `/bar hide progress`, or set `PI_BAR_SHOW` without `progress` to disable it.
104
169
 
105
- Pick a specific model for the update by setting the env var or pi settings:
170
+ **Pick a model interactively:** open `/bar`, select `Progress model` directly below `Progress update`, and press Enter. Type a provider or model ID (for example `gpt`), then press Enter to select. Esc cancels without changing the preference. The picker shows models with configured Pi credentials and an `Auto` option; it does not validate keys or make model requests.
171
+
172
+ **Or use commands with Tab completion:**
173
+
174
+ ```text
175
+ /bar progress-model
176
+ /bar progress-model openai/gpt-4.1-mini
177
+ /bar progress-model auto
178
+ ```
179
+
180
+ The first command reports the effective preference. After `/bar progress-model `, Tab offers `auto` and models with configured Pi credentials. Search by provider or model fragment, such as `gpt` or `haiku`; completion inserts the full `provider/model` ID, including any nested namespace. Suggestions use the current local model catalog, without refreshing catalogs, resolving credentials, or making model requests. Unknown/unavailable model arguments leave the preference unchanged.
181
+
182
+ The choice saves as `progressModel` in `~/.pi/agent/pi-bar.json` (or `PI_BAR_CONFIG`) for all projects. It applies to subsequent progress updates without `/reload`, cancels pending old-model updates, and leaves your main chat model and credentials unchanged. Choosing a model does not enable a hidden progress segment.
183
+
184
+ `Auto` tries fast Codex models, then Anthropic Haiku. To use an OpenAI API key instead of a Codex subscription, choose an **`openai/...`** model explicitly, such as `openai/gpt-4.1-mini`. Progress uses that provider's normal Pi credentials; no separate pi-bar key is needed. Configured but revoked credentials can still fail.
185
+
186
+ You can also set a model before launching Pi:
106
187
 
107
188
  ```bash
108
- PI_BAR_PROGRESS_MODEL=anthropic/claude-haiku-4-5 pi
189
+ PI_BAR_PROGRESS_MODEL=openai/gpt-4.1-mini pi
109
190
  ```
110
191
 
111
- Or in pi settings: `bar.progressModel`. Otherwise pi-bar picks a fast model you are already authenticated with.
192
+ Preference order: `PI_BAR_PROGRESS_MODEL` → saved pi-bar `progressModel` → project Pi settings → global Pi settings → Auto. Within each Pi settings scope, `bar.progressModel` takes precedence over the legacy `progress.model` setting. A nonempty environment override makes both the picker and command read-only and suppresses model-value completion; unset it and restart Pi to choose another model. A saved `"auto"` explicitly enables automatic selection rather than falling back to Pi settings. Remove `progressModel` from the pi-bar config to use Pi settings again.
112
193
 
113
- ### Configure extension statuses
194
+ ### Configure extension badges
114
195
 
115
196
  Other pi extensions can publish small status badges. Pi-bar displays their text as written, without prepending internal keys: `setStatus("mcp", "MCP: 2/2 servers")` appears as `MCP: 2/2 servers`, not `mcp:MCP: 2/2 servers`. Extensions should publish self-describing text; pi-bar does not guess labels for bare values.
116
197
 
117
- Pi-bar strips embedded terminal colors and control sequences, and separates each badge with the same `❯` divider used by other footer segments. Keys remain available for filtering and identification in `/bar`; selecting a status row shows its current sanitized text. Run `/bar` or `/bar status` inside pi to inspect statuses or pick which ones to show:
198
+ Pi-bar strips embedded terminal colors and control sequences, and separates each badge with the same `❯` divider used by other footer segments. Keys remain available for filtering and identification. Open `/bar` → `Choose badges`, or use the shortcut:
118
199
 
119
200
  ```text
120
- /bar status
201
+ /bar badges
121
202
  ```
122
203
 
123
- Toggle each status between `shown` and `hidden`. The `New statuses` row controls the default for badges that appear later.
204
+ Each `Badge: <key>` row shows its current sanitized text when selected. Toggle badges between `shown` and `hidden`; the `New badges` row controls the default for badges discovered later without changing existing choices. An empty screen explains that extensions have not published badges yet, while still letting you set that default.
205
+
206
+ These choices do not enable a hidden `Extension badges` footer item. Use `/bar show extensions` to display the badge area. `/bar badges show <keys>` and `/bar badges hide <keys>` are command shortcuts; the older `/bar status ...` spellings also work.
124
207
 
125
208
  Your choices persist across pi sessions in `~/.pi/agent/pi-bar.json`. Override the path with `PI_BAR_CONFIG=/some/path.json`.
126
209
 
@@ -145,7 +228,7 @@ npm test
145
228
  npm run check
146
229
  ```
147
230
 
148
- Tests cover path formatting, display-ready statuses, responsive layout, terminal safety, ANSI/Unicode width limits, resize behavior, and segment/status visibility persistence. Test configuration mirrors Pi's `pi-ai/compat` loader alias; runtime dependencies remain optional peers supplied by Pi.
231
+ Tests cover path formatting, display-ready statuses, responsive layout, all 512 segment visibility combinations, terminal safety, ANSI/Unicode widths, provider settings, progress-model selection, menu navigation, command completion and legacy aliases, usage accounting, progress-call persistence, session/tree lifecycle, and config persistence. Test configuration mirrors Pi's `pi-ai/compat` loader alias; runtime dependencies remain optional peers supplied by Pi.
149
232
 
150
233
  ## Security note
151
234