pi-polish 0.1.10 → 0.1.11

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`, 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`). Click a row to see its commands and their full output, and click again to fold it; `ctrl+o` does this for every row.
16
+ - Shell commands, file reads, searches, MCP tool calls and codemode scripts 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`). Click a row to see its commands and their full output, and click again to fold it; `ctrl+o` does this for every row.
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.
@@ -57,8 +57,8 @@ const DIFF_PREVIEW_LINES = 16;
57
57
  const BG_RESET = "\x1b[49m";
58
58
  const FG_RESET = "\x1b[39m";
59
59
 
60
- type Kind = "bash" | "read" | "search" | "list" | "tools" | "mcp";
61
- const KIND_OF: Record<string, Kind> = { bash: "bash", read: "read", grep: "search", find: "search", ls: "list", tool_search: "tools" };
60
+ type Kind = "bash" | "read" | "search" | "list" | "tools" | "mcp" | "code";
61
+ const KIND_OF: Record<string, Kind> = { bash: "bash", read: "read", grep: "search", find: "search", ls: "list", tool_search: "tools", codemode: "code" };
62
62
  // Pi names MCP tools mcp__<server>__<tool>
63
63
  const kindOf = (toolName: string): Kind | undefined => KIND_OF[toolName] ?? (toolName.startsWith("mcp__") ? "mcp" : undefined);
64
64
  const VERBS: Record<Kind, [done: string, running: string, one: string, many: string]> = {
@@ -68,6 +68,7 @@ const VERBS: Record<Kind, [done: string, running: string, one: string, many: str
68
68
  list: ["Listed", "Listing", "directory", "directories"],
69
69
  tools: ["Ran", "Running", "tool search", "tool searches"],
70
70
  mcp: ["Called", "Calling", "MCP tool", "MCP tools"],
71
+ code: ["Ran", "Running", "codemode script", "codemode scripts"],
71
72
  };
72
73
 
73
74
  interface Member {
@@ -118,6 +119,11 @@ function label(toolName: string, args: any, cwd: string): string {
118
119
  return `Search tools "${args?.query ?? ""}"`;
119
120
  case "ls":
120
121
  return `List ${args?.path ? shortPath(args.path, cwd) : "."}`;
122
+ case "codemode": {
123
+ // The script's first line of code, which usually names the tool it calls
124
+ const first = String(args?.code ?? "").split("\n").map((l) => l.trim()).find(Boolean);
125
+ return `codemode${first ? ` ${first}` : ""}`;
126
+ }
121
127
  default: {
122
128
  // server/tool like pi's own MCP rows, with the first text argument, which is usually the query
123
129
  const [, server, ...tool] = toolName.split("__");
@@ -522,6 +528,8 @@ export default function (pi: ExtensionAPI) {
522
528
  if (msg.role === "assistant" && (msg.content ?? []).some((c: any) => c.type === "text" && c.text.trim())) current = undefined;
523
529
  });
524
530
  pi.on("tool_execution_start", async (event) => {
531
+ // Calls a codemode script makes show inside its own row, so they don't join or end a group
532
+ if (event.parentToolCallId) return;
525
533
  if (!kindOf(event.toolName)) {
526
534
  current = undefined;
527
535
  return;
@@ -608,9 +616,11 @@ export default function (pi: ExtensionAPI) {
608
616
  renderCall(args: any, theme, context) {
609
617
  const grouped = renderGrouped(context.toolCallId, theme, context);
610
618
  if (grouped) return grouped;
611
- // Expanded, a shell command shows in full, with its cd and every line; collapsed rows keep the short label
612
- const command = isOpen(context) && toolName === "bash" ? String(args?.command ?? "").trim().split("\n") : undefined;
613
- const text = command ? `$ ${command.slice(0, 60).join("\n")}${command.length > 60 ? `\n... ${command.length - 60} more lines` : ""}` : truncateToWidth(label(toolName, args, cwd), 400);
619
+ // Expanded, a shell command or a codemode script shows in full, with every line; collapsed rows keep the short label
620
+ const source = toolName === "bash" ? args?.command : toolName === "codemode" ? args?.code : undefined;
621
+ const lines = isOpen(context) && source !== undefined ? String(source ?? "").trim().split("\n") : undefined;
622
+ const prefix = toolName === "bash" ? "$ " : "codemode\n";
623
+ const text = lines ? `${prefix}${lines.slice(0, 60).join("\n")}${lines.length > 60 ? `\n... ${lines.length - 60} more lines` : ""}` : truncateToWidth(label(toolName, args, cwd), 400);
614
624
  // Finished rows are dim without a dot; running and failed ones keep it
615
625
  const done = status(context) === "success";
616
626
  const mark = done ? " " : dot(theme, context);
@@ -703,9 +713,10 @@ export default function (pi: ExtensionAPI) {
703
713
  return own && own.renderShell !== "self" ? otherTool(toolName, own) : own;
704
714
  }
705
715
  const own = groupedTool(toolName);
706
- if (kindOf(toolName) !== "mcp") return own;
707
- // Expanded MCP results keep pi's own view, which shows images and limits long one-line JSON. It gets
708
- // no lastComponent, since that may be the empty component drawn while the row was collapsed.
716
+ if (kindOf(toolName) !== "mcp" && kindOf(toolName) !== "code") return own;
717
+ // Expanded MCP and codemode results keep pi's own view, which shows images, limits long one-line JSON and
718
+ // lists a script's nested calls. It gets no lastComponent, since that may be the empty component drawn
719
+ // while the row was collapsed.
709
720
  const pis = next()?.renderResult;
710
721
  return {
711
722
  ...own,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-polish",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "license": "MIT",
5
5
  "author": "Thomas van Dongen",
6
6
  "type": "module",