pi-polish 0.1.1 → 0.1.3

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
@@ -1,6 +1,6 @@
1
1
  # pi-polish
2
2
 
3
- Makes [pi](https://pi.dev)'s output look like Claude Code's: tool calls fold into short summary lines, and edits show as colored diffs.
3
+ Makes [Pi](https://pi.dev)'s output look like Claude Code's: tool calls fold into short summary lines, and edits show as colored diffs.
4
4
 
5
5
  <picture>
6
6
  <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/Pringled/pi-extensions/main/assets/images/pi-polish-dark.gif">
@@ -14,15 +14,15 @@ pi install npm:pi-polish
14
14
  ## Features
15
15
 
16
16
  - Shell commands, file reads and searches 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`). `ctrl+o` shows the full output.
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.
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
  - A dot on each tool row shows its status: orange while running, green when done, red if it failed.
19
- - An orange status line shows what pi is doing, how long it has been at it and how many tokens it has written.
20
- - `❯` marks your messages and `●` marks pi's replies.
21
- - A short instruction to the model to change files with pi's edit and write tools instead of shell commands like `sed -i`, so you see the changes as diffs.
19
+ - An orange status line shows what Pi is doing, how long it has been at it and how many tokens it has written.
20
+ - `❯` marks your messages and `●` marks Pi's replies.
21
+ - A short instruction to the model to change files with Pi's edit and write tools instead of shell commands like `sed -i`, so you see the changes as diffs.
22
22
 
23
23
  ## Compatibility
24
24
 
25
- pi-polish only changes how pi's built-in tools are drawn; the tools themselves run exactly as before. The chat styling (the markers and the status line) reaches into pi's internal UI, so a new pi release can break that part of the look until pi-polish is updated. Your sessions are never affected. Tested with pi 1.3.
25
+ pi-polish only changes how Pi's built-in tools are drawn; the tools themselves run exactly as before. The chat styling (the markers and the status line) reaches into Pi's internal UI, so a new Pi release can break that part of the look until pi-polish is updated. Your sessions are never affected. Tested with Pi 1.3.
26
26
 
27
27
  ## License
28
28
 
@@ -1,12 +1,13 @@
1
1
  import { AssistantMessageComponent, CustomEditor, type ExtensionAPI, UserMessageComponent } from "@earendil-works/pi-coding-agent";
2
- import { Markdown } from "@earendil-works/pi-tui";
2
+ import { Markdown, MouseRegion, Spacer, Text } from "@earendil-works/pi-tui";
3
3
 
4
4
  const PROMPT = "❯";
5
5
  const REPLY = "●";
6
6
  const ORANGE = "\x1b[38;2;217;119;87m";
7
7
  const DIM = "\x1b[2m";
8
8
  const RESET = "\x1b[0m";
9
- const SPINNER = ["·", "✢", "✳", "✶", "✻", "✽", "✻", "✶", "✳", "✢"].map((f) => `${ORANGE}${f}${RESET}`);
9
+ // ✱ rather than ✳, which Windows Terminal draws as a green emoji
10
+ const SPINNER = ["·", "✢", "✱", "✶", "✻", "✽", "✻", "✶", "✱", "✢"].map((f) => `${ORANGE}${f}${RESET}`);
10
11
  const LEADING_ESCAPES = /^((?:\x1b\[[0-9;]*m|\x1b\][^\x07]*\x07)*) {2}/;
11
12
  const OSC133_START = "\x1b]133;A\x07";
12
13
  const OSC133_END = "\x1b]133;B\x07\x1b]133;C\x07";
@@ -25,16 +26,20 @@ function patchOnce(proto: any, method: string, wrap: (original: (...args: any[])
25
26
 
26
27
  export default function (pi: ExtensionAPI) {
27
28
  try {
28
- // Drop hidden thinking blocks entirely instead of rendering a "Thinking..." line plus spacers
29
29
  patchOnce(AssistantMessageComponent.prototype, "updateContent", (original) =>
30
30
  function (this: any, message: any, ...rest: any[]) {
31
31
  // Two columns of padding so reply text lines up behind the ● marker, like tool rows
32
32
  this.outputPad = Math.max(this.outputPad ?? 1, 2);
33
- if (!this.hideThinkingBlock) original.call(this, message, ...rest);
34
- else {
35
- original.call(this, { ...message, content: message.content.filter((c: any) => c.type !== "thinking") }, ...rest);
36
- this.lastMessage = message;
37
- }
33
+ original.call(this, message, ...rest);
34
+ // Hidden thinking draws nothing instead of a "Thinking..." line plus spacers. Its rows stay in place,
35
+ // so extensions that read pi's layout, like pi-stereo-view, still match it
36
+ // A block collapsed by clicking it while thinking is shown keeps its line, so it can be clicked open again
37
+ const children: any[] = this.hideThinkingBlock ? (this.contentContainer?.children ?? []) : [];
38
+ children.forEach((child, i) => {
39
+ if (!(child instanceof MouseRegion) || !((child as any).child instanceof Text)) return;
40
+ const spacer = [children[i + 1], children[i - 1]].find((c) => c instanceof Spacer);
41
+ for (const row of [child, spacer]) if (row) row.render = () => [];
42
+ });
38
43
  // Text blocks are the Markdown children without a default style; thinking blocks carry one
39
44
  for (const child of this.contentContainer?.children ?? []) {
40
45
  if (!(child instanceof Markdown) || (child as any).defaultTextStyle !== undefined || (child as any)[patched]) continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-polish",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "license": "MIT",
5
5
  "author": "Thomas van Dongen",
6
6
  "type": "module",