pi-polish 0.1.7 → 0.1.8

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
@@ -13,7 +13,7 @@ pi install npm:pi-polish
13
13
 
14
14
  ## Features
15
15
 
16
- - Shell commands, file reads, searches and MCP tool calls in a row fold into one line that updates while they run (`Running 2 shell commands… · 5s`) and then sums them up (`Ran 3 shell commands, read 2 files` or `Called 2 MCP tools`). `ctrl+o` shows the full output.
16
+ - Shell commands, file reads, searches and MCP tool calls in a row fold into one line that updates while they run (`Running 2 shell commands… · 5s`, with the command and its latest output line below) and then sums them up (`Ran 3 shell commands, read 2 files` or `Called 2 MCP tools`). `ctrl+o` shows the full output.
17
17
  - Edits and new files show as diffs with syntax highlighting and the changed words marked, in colors that follow your Pi theme, dark or light.
18
18
  - Reads, searches, shell commands and MCP calls show a pulsing dot in your theme's accent color while they run, then turn into a quiet grey row once done, with a red dot if one failed. Edits and writes keep a green dot with their diff.
19
19
  - An orange status line shows what Pi is doing, how long it has been at it and how many tokens it has written. When Pi finishes, a dim line says how long it worked and when it was done.
@@ -7,7 +7,7 @@ import {
7
7
  type ExtensionAPI,
8
8
  type ToolRenderers,
9
9
  } from "@earendil-works/pi-coding-agent";
10
- import { type Component, Container, Text, truncateToWidth, visibleWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
10
+ import { type Component, Container, stripTerminalSequences, Text, truncateToWidth, visibleWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
11
11
  import { shortCommand } from "./command.ts";
12
12
  import bash from "@shikijs/langs/shellscript";
13
13
  import css from "@shikijs/langs/css";
@@ -76,6 +76,8 @@ interface Member {
76
76
  label: string;
77
77
  done: boolean;
78
78
  error: boolean;
79
+ // The latest output line of a running shell command
80
+ latest?: string;
79
81
  }
80
82
 
81
83
  interface Group {
@@ -434,6 +436,8 @@ function oneLine(lines: string[], suffix = ""): Component {
434
436
  }
435
437
 
436
438
  export default function (pi: ExtensionAPI) {
439
+ // Tells pi-background that its ctrl+b hint goes under the running command's row, drawn below
440
+ (globalThis as any)[Symbol.for("pi-polish.showsMoveHint")] = true;
437
441
  const cwd = process.cwd();
438
442
  const groupOf = new Map<string, Group>();
439
443
  const rowInvalidate = new Map<string, () => void>();
@@ -524,6 +528,18 @@ export default function (pi: ExtensionAPI) {
524
528
  tick(group);
525
529
  refresh(group);
526
530
  });
531
+ // Pi streams a running command's output; its row shows the latest line, as a terminal would, redrawn with the timer
532
+ pi.on("tool_execution_update", async (event) => {
533
+ const member = groupOf.get(event.toolCallId)?.members.find((m) => m.id === event.toolCallId);
534
+ if (!member || member.kind !== "bash") return;
535
+ const text = (event.partialResult?.content ?? []).map((c: any) => c.text ?? "").join("");
536
+ const latest = text
537
+ .split("\n")
538
+ .map((line: string) => (stripTerminalSequences(line).split("\r").filter((part) => part.trim()).at(-1) ?? "").replace(/[\x00-\x1f\x7f]/g, " ").trim())
539
+ .filter(Boolean)
540
+ .at(-1);
541
+ if (latest) member.latest = latest;
542
+ });
527
543
  pi.on("tool_execution_end", async (event) => {
528
544
  const group = groupOf.get(event.toolCallId);
529
545
  const member = group?.members.find((m) => m.id === event.toolCallId);
@@ -553,7 +569,10 @@ export default function (pi: ExtensionAPI) {
553
569
  // The dot pulses once a second while the group runs, in step with the seconds counter
554
570
  const pulse = secs % 2 ? "dim" : "accent";
555
571
  const head = theme.fg(pulse, `${MARK} `) + theme.fg("toolTitle", `${summary(group, true)}…`) + theme.fg("dim", ` · ${secs}s`) + failNote;
556
- return oneLine([head, theme.fg("dim", ` └ ${active.label}`)]);
572
+ const latest = active.latest ? [theme.fg("dim", ` ${active.latest}`)] : [];
573
+ // pi-background marks commands that ctrl+b can move to the background
574
+ const movable = (globalThis as any)[Symbol.for("pi-background.movable")]?.has(active.id) ? [theme.fg("dim", " (ctrl+b to run in background)")] : [];
575
+ return oneLine([head, theme.fg("dim", ` └ ${active.label}`), ...latest, ...movable]);
557
576
  }
558
577
  // Finished rows go quiet, like Claude Code's: dim text, with a red ● only when something failed
559
578
  const mark = failed ? theme.fg("error", `${MARK} `) : " ";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-polish",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "license": "MIT",
5
5
  "author": "Thomas van Dongen",
6
6
  "type": "module",