pi-polish 0.1.9 → 0.1.10
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 +2 -1
- package/extensions/tools.ts +30 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,12 +17,13 @@ pi install npm:pi-polish
|
|
|
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.
|
|
20
|
+
- Tools from other extensions keep their own look, but without Pi's colored box: they sit under the same status dot as the other rows.
|
|
20
21
|
- `❯` marks your messages and `●` marks Pi's replies.
|
|
21
22
|
- 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
23
|
|
|
23
24
|
## Compatibility
|
|
24
25
|
|
|
25
|
-
pi-polish only changes how
|
|
26
|
+
pi-polish only changes how 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.4.
|
|
26
27
|
|
|
27
28
|
## License
|
|
28
29
|
|
package/extensions/tools.ts
CHANGED
|
@@ -670,9 +670,38 @@ export default function (pi: ExtensionAPI) {
|
|
|
670
670
|
return [`Wrote ${lineCount(lines.length)}`, lines.map((line, i) => `+${String(i + 1).padStart(width)} ${line}`)];
|
|
671
671
|
}),
|
|
672
672
|
};
|
|
673
|
+
// Other extensions' tools keep their own drawing, without pi's colored box: indented under the status dot like
|
|
674
|
+
// the rows above. Their renderer gets back its own component, not the wrapper, to reuse.
|
|
675
|
+
type Framed = Component & { inner: Component };
|
|
676
|
+
const frame = (inner: Component, mark: string): Framed => ({
|
|
677
|
+
inner,
|
|
678
|
+
invalidate: () => inner.invalidate(),
|
|
679
|
+
render: (width: number) => inner.render(Math.max(10, width - 2)).map((line, i) => (i === 0 ? mark : " ") + line),
|
|
680
|
+
});
|
|
681
|
+
const unframed = <C extends { lastComponent?: Component }>(context: C): C => ({ ...context, lastComponent: (context.lastComponent as Framed | undefined)?.inner });
|
|
682
|
+
const otherTool = (toolName: string, own: ToolRenderers): ToolRenderers => ({
|
|
683
|
+
renderShell: "self",
|
|
684
|
+
renderCall(args: any, theme, context) {
|
|
685
|
+
const mark = status(context) === "success" ? " " : dot(theme, context);
|
|
686
|
+
const first = Object.values(args ?? {}).find((v) => typeof v === "string") as string | undefined;
|
|
687
|
+
const fallback = () => new Text(theme.fg("toolTitle", theme.bold(toolName)) + (first ? theme.fg("dim", ` ${first.split("\n")[0]}`) : ""), 0, 0);
|
|
688
|
+
return frame(own.renderCall ? own.renderCall(args, theme, unframed(context)) : fallback(), mark);
|
|
689
|
+
},
|
|
690
|
+
renderResult(result, options, theme, context) {
|
|
691
|
+
if (own.renderResult) return frame(own.renderResult(result, options, theme, unframed(context)), " ");
|
|
692
|
+
const text = resultText(result as Result);
|
|
693
|
+
return options.expanded && text ? frame(new Text(expandedBody(theme, text), 0, 0), " ") : empty();
|
|
694
|
+
},
|
|
695
|
+
});
|
|
696
|
+
|
|
673
697
|
// Only the drawing changes: pi's own tools keep running, with their own schema and on/off state
|
|
674
698
|
pi.registerToolRenderer((toolName, next) => {
|
|
675
|
-
if (renderers[toolName]
|
|
699
|
+
if (renderers[toolName]) return renderers[toolName];
|
|
700
|
+
if (!kindOf(toolName)) {
|
|
701
|
+
const own = next();
|
|
702
|
+
// Tools that draw their own frame, like bg_run, already fit in
|
|
703
|
+
return own && own.renderShell !== "self" ? otherTool(toolName, own) : own;
|
|
704
|
+
}
|
|
676
705
|
const own = groupedTool(toolName);
|
|
677
706
|
if (kindOf(toolName) !== "mcp") return own;
|
|
678
707
|
// Expanded MCP results keep pi's own view, which shows images and limits long one-line JSON. It gets
|