@xynogen/pix-pretty 3.4.0 → 3.5.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xynogen/pix-pretty",
3
- "version": "3.4.0",
3
+ "version": "3.5.0",
4
4
  "description": "Enhanced tool output rendering with syntax highlighting, file icons, tree views, diff rendering, and FFF search",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -42,6 +42,7 @@
42
42
  "./test-utils": "./src/test-utils.ts",
43
43
  "./transient-error": "./src/transient-error.ts",
44
44
  "./chips": "./src/chips.ts",
45
+ "./command-card": "./src/command-card.ts",
45
46
  "./grammar-consent": "./src/grammar-consent.ts",
46
47
  "./tui": "./src/tui.ts"
47
48
  },
@@ -0,0 +1,68 @@
1
+ /**
2
+ * command-card.ts — the card frame for a slash command's result (/agent, /btw).
3
+ *
4
+ * Layout: status glyph, bold TITLE and muted `· meta`; an accent `▐` prompt row;
5
+ * a blank row; then the body the caller adds. selectedBg keeps it apart from the
6
+ * main thread. Each package owns its entry type and renderer; this owns the look.
7
+ */
8
+
9
+ import type { Theme } from "@earendil-works/pi-coding-agent";
10
+ import { Box, type Component, Markdown, Spacer, Text } from "@earendil-works/pi-tui";
11
+ import { solidBackground } from "./ansi.ts";
12
+ import { icon } from "./icon-catalog.ts";
13
+ import { transformMarkdown } from "./markdown-transform.ts";
14
+ import { dotJoin } from "./render-row.ts";
15
+ import { getMarkdownTheme } from "./tui.ts";
16
+
17
+ export type CommandCardStatus = "success" | "warning" | "error";
18
+
19
+ export interface CommandCardHeader {
20
+ status: CommandCardStatus;
21
+ /** Shown bold, e.g. "AGENT". */
22
+ title: string;
23
+ /** Joined with ` · `; falsy parts are dropped. */
24
+ meta?: ReadonlyArray<string | false | null | undefined>;
25
+ /** What the user asked; shown dim behind an accent bar. */
26
+ prompt?: string;
27
+ }
28
+
29
+ type CardTheme = Pick<Theme, "fg" | "bg" | "bold">;
30
+
31
+ const GLYPH = { success: "status.ok", warning: "status.warn", error: "status.error" } as const;
32
+
33
+ /** The card frame with its header rows. Callers add the body children. */
34
+ export function commandCard(theme: CardTheme, header: CommandCardHeader): Box {
35
+ // Directive output ends styles with a full reset; keep the card color behind it.
36
+ // Children pad themselves, not the Box: Markdown leaves image rows unpadded, and
37
+ // framed images (math, Mermaid) indent that row to match, as in the transcript.
38
+ const card = new Box(
39
+ 0,
40
+ 1,
41
+ solidBackground((text) => theme.bg("selectedBg", text)),
42
+ );
43
+ const meta = dotJoin(header.meta ?? []);
44
+ const glyph = theme.fg(header.status, icon(GLYPH[header.status]));
45
+ const tail = meta ? ` ${theme.fg("muted", `· ${meta}`)}` : "";
46
+ card.addChild(new Text(`${glyph} ${theme.bold(header.title)}${tail}`, 1, 0));
47
+ if (header.prompt) {
48
+ card.addChild(new Text(`${theme.fg("accent", "▐")} ${theme.fg("dim", header.prompt)}`, 1, 0));
49
+ }
50
+ card.addChild(new Spacer(1));
51
+ return card;
52
+ }
53
+
54
+ /** Card body as Markdown, through the same display pipeline as main replies. */
55
+ export function cardMarkdown(text: string, theme: Pick<Theme, "fg">): Component {
56
+ try {
57
+ return new Markdown(
58
+ text,
59
+ 1,
60
+ 0,
61
+ getMarkdownTheme(),
62
+ { color: (value) => theme.fg("customMessageText", value) },
63
+ { transform: transformMarkdown },
64
+ );
65
+ } catch {
66
+ return new Text(theme.fg("customMessageText", text), 1, 0);
67
+ }
68
+ }
package/src/render-row.ts CHANGED
@@ -80,7 +80,7 @@ export function widgetTitle(
80
80
  * Pass `paint` (e.g. `(s) => theme.fg("dim", s)`) to tint the separator to theme.
81
81
  */
82
82
  export function dotJoin(
83
- parts: Array<string | false | null | undefined>,
83
+ parts: ReadonlyArray<string | false | null | undefined>,
84
84
  paint?: RulePaint,
85
85
  ): string {
86
86
  const sep = paint ? paint(" · ") : " · ";
package/src/tui.ts CHANGED
@@ -30,6 +30,7 @@ export {
30
30
  Box,
31
31
  Container,
32
32
  decodeKittyPrintable,
33
+ deleteAllKittyImages,
33
34
  Editor,
34
35
  fuzzyFilter,
35
36
  getCapabilities,