pi-bar 0.3.3 → 0.3.4
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 +6 -9
- package/extensions/status-footer.ts +135 -7
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
◈ claude-opus-4.7 ❯ ✦ think:med ❯ ◷ 2.6% / 1.0M ❯ ✧ plan:active
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-

|
|
13
13
|
|
|
14
14
|
## Why use it?
|
|
15
15
|
|
|
@@ -48,18 +48,15 @@ Allowed segments are `model`, `thinking`, `context`, and `extensions`. The `exte
|
|
|
48
48
|
### Configure extension statuses
|
|
49
49
|
|
|
50
50
|
pi-bar shows statuses set by other extensions with `ctx.ui.setStatus()`.
|
|
51
|
-
Use `/bar
|
|
51
|
+
Use `/bar` inside pi to open an interactive status-visibility picker.
|
|
52
52
|
|
|
53
53
|
```text
|
|
54
|
-
/bar
|
|
55
|
-
/bar status hide plan-mode
|
|
56
|
-
/bar status show plan-mode
|
|
57
|
-
/bar status only plan-mode,preset
|
|
58
|
-
/bar status none
|
|
59
|
-
/bar status all
|
|
54
|
+
/bar
|
|
60
55
|
```
|
|
61
56
|
|
|
62
|
-
|
|
57
|
+
Toggle each status key between `shown` and `hidden`. The `New statuses` row controls whether status keys discovered later are shown or hidden by default.
|
|
58
|
+
|
|
59
|
+
Status filter choices persist in the current session. Advanced command forms like `/bar status hide <key>` still work for scripting.
|
|
63
60
|
|
|
64
61
|
### Change context thresholds
|
|
65
62
|
|
|
@@ -16,8 +16,17 @@
|
|
|
16
16
|
* PI_BAR_ICONS=unicode|plain|emoji|nerdfont
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
import
|
|
20
|
-
|
|
19
|
+
import {
|
|
20
|
+
getSettingsListTheme,
|
|
21
|
+
type ExtensionAPI,
|
|
22
|
+
type ExtensionContext,
|
|
23
|
+
} from "@earendil-works/pi-coding-agent";
|
|
24
|
+
import {
|
|
25
|
+
Container,
|
|
26
|
+
type SettingItem,
|
|
27
|
+
SettingsList,
|
|
28
|
+
truncateToWidth,
|
|
29
|
+
} from "@earendil-works/pi-tui";
|
|
21
30
|
|
|
22
31
|
type SegmentName = "model" | "thinking" | "context" | "extensions";
|
|
23
32
|
type IconPreset = "unicode" | "plain" | "emoji" | "nerdfont";
|
|
@@ -241,6 +250,16 @@ function describeStatusFilter(filter: StatusFilter): string {
|
|
|
241
250
|
return hidden.length > 0 ? `showing all except: ${hidden.join(", ")}` : "showing all";
|
|
242
251
|
}
|
|
243
252
|
|
|
253
|
+
function getKnownStatusKeys(filter: StatusFilter, seenStatusKeys: Set<string>): string[] {
|
|
254
|
+
const keys = new Set(seenStatusKeys);
|
|
255
|
+
if (filter.mode === "only") {
|
|
256
|
+
for (const key of filter.shown) keys.add(key);
|
|
257
|
+
} else {
|
|
258
|
+
for (const key of filter.hidden) keys.add(key);
|
|
259
|
+
}
|
|
260
|
+
return Array.from(keys).sort();
|
|
261
|
+
}
|
|
262
|
+
|
|
244
263
|
export default function (pi: ExtensionAPI) {
|
|
245
264
|
let requestRender: (() => void) | undefined;
|
|
246
265
|
let statusFilter: StatusFilter = { mode: "all", hidden: new Set() };
|
|
@@ -255,19 +274,129 @@ export default function (pi: ExtensionAPI) {
|
|
|
255
274
|
}
|
|
256
275
|
statusFilter = restoredFilter ?? { mode: "all", hidden: new Set() };
|
|
257
276
|
};
|
|
277
|
+
const persistStatusFilter = () => {
|
|
278
|
+
pi.appendEntry(STATUS_FILTER_ENTRY_TYPE, serializeStatusFilter(statusFilter));
|
|
279
|
+
refresh();
|
|
280
|
+
};
|
|
281
|
+
const openStatusConfigurator = async (ctx: ExtensionContext) => {
|
|
282
|
+
const knownStatusKeys = getKnownStatusKeys(statusFilter, seenStatusKeys);
|
|
283
|
+
if (knownStatusKeys.length === 0) {
|
|
284
|
+
ctx.ui.notify(
|
|
285
|
+
"No extension statuses seen yet. Open /bar after another extension calls ctx.ui.setStatus().",
|
|
286
|
+
"info",
|
|
287
|
+
);
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
await ctx.ui.custom((tui, theme, _kb, done) => {
|
|
292
|
+
let futureShown = statusFilter.mode === "all";
|
|
293
|
+
const statusVisibility = new Map(
|
|
294
|
+
knownStatusKeys.map((key) => [key, shouldShowStatus(key, statusFilter)]),
|
|
295
|
+
);
|
|
296
|
+
const persistFromVisibility = () => {
|
|
297
|
+
if (futureShown) {
|
|
298
|
+
statusFilter = {
|
|
299
|
+
mode: "all",
|
|
300
|
+
hidden: new Set(
|
|
301
|
+
knownStatusKeys.filter((key) => !statusVisibility.get(key)),
|
|
302
|
+
),
|
|
303
|
+
};
|
|
304
|
+
} else {
|
|
305
|
+
statusFilter = {
|
|
306
|
+
mode: "only",
|
|
307
|
+
shown: new Set(
|
|
308
|
+
knownStatusKeys.filter((key) => statusVisibility.get(key)),
|
|
309
|
+
),
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
persistStatusFilter();
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
const items: SettingItem[] = [
|
|
316
|
+
{
|
|
317
|
+
id: "__future",
|
|
318
|
+
label: "New statuses",
|
|
319
|
+
description: "Default visibility for status keys discovered later",
|
|
320
|
+
currentValue: futureShown ? "shown" : "hidden",
|
|
321
|
+
values: ["shown", "hidden"],
|
|
322
|
+
},
|
|
323
|
+
...knownStatusKeys.map((key): SettingItem => ({
|
|
324
|
+
id: key,
|
|
325
|
+
label: key,
|
|
326
|
+
description: "Extension status visibility",
|
|
327
|
+
currentValue: statusVisibility.get(key) ? "shown" : "hidden",
|
|
328
|
+
values: ["shown", "hidden"],
|
|
329
|
+
})),
|
|
330
|
+
];
|
|
331
|
+
|
|
332
|
+
const container = new Container();
|
|
333
|
+
container.addChild(
|
|
334
|
+
new (class {
|
|
335
|
+
render(_width: number) {
|
|
336
|
+
return [
|
|
337
|
+
theme.fg("accent", theme.bold("pi-bar status visibility")),
|
|
338
|
+
theme.fg("dim", "Enter/Space toggles · Esc closes"),
|
|
339
|
+
"",
|
|
340
|
+
];
|
|
341
|
+
}
|
|
342
|
+
invalidate() {}
|
|
343
|
+
})(),
|
|
344
|
+
);
|
|
345
|
+
|
|
346
|
+
const settingsList = new SettingsList(
|
|
347
|
+
items,
|
|
348
|
+
Math.min(items.length + 2, 15),
|
|
349
|
+
getSettingsListTheme(),
|
|
350
|
+
(id, newValue) => {
|
|
351
|
+
if (id === "__future") {
|
|
352
|
+
futureShown = newValue === "shown";
|
|
353
|
+
} else {
|
|
354
|
+
statusVisibility.set(id, newValue === "shown");
|
|
355
|
+
}
|
|
356
|
+
persistFromVisibility();
|
|
357
|
+
},
|
|
358
|
+
() => done(undefined),
|
|
359
|
+
{ enableSearch: true },
|
|
360
|
+
);
|
|
361
|
+
|
|
362
|
+
container.addChild(settingsList);
|
|
363
|
+
|
|
364
|
+
return {
|
|
365
|
+
render(width: number) {
|
|
366
|
+
return container.render(width);
|
|
367
|
+
},
|
|
368
|
+
invalidate() {
|
|
369
|
+
container.invalidate();
|
|
370
|
+
},
|
|
371
|
+
handleInput(data: string) {
|
|
372
|
+
settingsList.handleInput?.(data);
|
|
373
|
+
tui.requestRender();
|
|
374
|
+
},
|
|
375
|
+
};
|
|
376
|
+
});
|
|
377
|
+
};
|
|
258
378
|
|
|
259
379
|
pi.registerCommand("bar", {
|
|
260
380
|
description: "Configure pi-bar footer status segments",
|
|
261
381
|
handler: async (args, ctx) => {
|
|
262
382
|
const [section, action, ...rest] = args.trim().split(/\s+/).filter(Boolean);
|
|
263
|
-
if (!section || section === "status" || section === "statuses") {
|
|
383
|
+
if (!section || ((section === "status" || section === "statuses") && !action)) {
|
|
384
|
+
await openStatusConfigurator(ctx);
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
if (section === "status" || section === "statuses") {
|
|
264
389
|
const keys = splitStatusKeys(rest.join(" "));
|
|
265
390
|
|
|
266
391
|
switch (action) {
|
|
267
|
-
case
|
|
392
|
+
case "config":
|
|
393
|
+
case "configure":
|
|
394
|
+
case "edit":
|
|
395
|
+
await openStatusConfigurator(ctx);
|
|
396
|
+
return;
|
|
268
397
|
case "list":
|
|
269
398
|
case "ls": {
|
|
270
|
-
const known =
|
|
399
|
+
const known = getKnownStatusKeys(statusFilter, seenStatusKeys);
|
|
271
400
|
ctx.ui.notify(
|
|
272
401
|
`pi-bar statuses: ${describeStatusFilter(statusFilter)}${known.length > 0 ? `; known: ${known.join(", ")}` : "; known: none yet"}`,
|
|
273
402
|
"info",
|
|
@@ -305,8 +434,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
305
434
|
return;
|
|
306
435
|
}
|
|
307
436
|
|
|
308
|
-
|
|
309
|
-
refresh();
|
|
437
|
+
persistStatusFilter();
|
|
310
438
|
ctx.ui.notify(`pi-bar statuses: ${describeStatusFilter(statusFilter)}`, "info");
|
|
311
439
|
return;
|
|
312
440
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-bar",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "Never accidentally run Opus on a typo. Pi footer/statusline showing active model, thinking level, context usage, and extension statuses.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -46,6 +46,6 @@
|
|
|
46
46
|
"extensions": [
|
|
47
47
|
"./extensions/status-footer.ts"
|
|
48
48
|
],
|
|
49
|
-
"image": "https://cdn.jsdelivr.net/npm/pi-bar@0.3.
|
|
49
|
+
"image": "https://cdn.jsdelivr.net/npm/pi-bar@0.3.4/assets/screenshot.png"
|
|
50
50
|
}
|
|
51
51
|
}
|