@narumitw/pi-subagents 3.0.1 → 3.1.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.
@@ -5,56 +5,54 @@ import { sanitizeTerminalText } from "./message-broker.js";
5
5
  export const COMPLETION_MESSAGE_TYPE = "pi-subagents-completion";
6
6
 
7
7
  function createCompletionBox(
8
- children: Component[],
9
- outputPad: number,
10
- background: (text: string) => string,
8
+ children: Component[],
9
+ outputPad: number,
10
+ background: (text: string) => string,
11
11
  ): Component {
12
- return {
13
- render(width) {
14
- if (width <= 0) return [];
15
- const maxPadding = Math.floor((width - 1) / 2);
16
- const box = new Box(Math.min(Math.max(0, outputPad), maxPadding), 1, background);
17
- for (const child of children) box.addChild(child);
18
- return box.render(width);
19
- },
20
- invalidate() {
21
- for (const child of children) child.invalidate();
22
- },
23
- };
12
+ return {
13
+ render(width) {
14
+ if (width <= 0) return [];
15
+ const maxPadding = Math.floor((width - 1) / 2);
16
+ const box = new Box(Math.min(Math.max(0, outputPad), maxPadding), 1, background);
17
+ for (const child of children) box.addChild(child);
18
+ return box.render(width);
19
+ },
20
+ invalidate() {
21
+ for (const child of children) child.invalidate();
22
+ },
23
+ };
24
24
  }
25
25
 
26
26
  export function registerCompletionRenderer(pi: ExtensionAPI): void {
27
- pi.registerMessageRenderer(COMPLETION_MESSAGE_TYPE, (message, options, theme) => {
28
- const children: Component[] = [
29
- new Text(theme.fg("customMessageLabel", theme.bold(`[${COMPLETION_MESSAGE_TYPE}]`)), 0, 0),
30
- new Spacer(1),
31
- ];
32
- if (!options.expanded) {
33
- children.push(
34
- new Text(
35
- theme.fg("customMessageText", "Subagent job completion (") +
36
- theme.fg("dim", keyText("app.tools.expand")) +
37
- theme.fg("customMessageText", " to expand)"),
38
- 0,
39
- 0,
40
- ),
41
- );
42
- } else {
43
- const content =
44
- typeof message.content === "string"
45
- ? message.content
46
- : message.content
47
- .filter((part) => part.type === "text")
48
- .map((part) => part.text)
49
- .join("\n");
50
- children.push(
51
- new Markdown(sanitizeTerminalText(content), 0, 0, getMarkdownTheme(), {
52
- color: (text) => theme.fg("customMessageText", text),
53
- }),
54
- );
55
- }
56
- return createCompletionBox(children, options.outputPad, (text) =>
57
- theme.bg("customMessageBg", text),
58
- );
59
- });
27
+ pi.registerMessageRenderer(COMPLETION_MESSAGE_TYPE, (message, options, theme) => {
28
+ const children: Component[] = [
29
+ new Text(theme.fg("customMessageLabel", theme.bold(`[${COMPLETION_MESSAGE_TYPE}]`)), 0, 0),
30
+ new Spacer(1),
31
+ ];
32
+ if (!options.expanded) {
33
+ children.push(
34
+ new Text(
35
+ theme.fg("customMessageText", "Subagent job completion (") +
36
+ theme.fg("dim", keyText("app.tools.expand")) +
37
+ theme.fg("customMessageText", " to expand)"),
38
+ 0,
39
+ 0,
40
+ ),
41
+ );
42
+ } else {
43
+ const content =
44
+ typeof message.content === "string"
45
+ ? message.content
46
+ : message.content
47
+ .filter((part) => part.type === "text")
48
+ .map((part) => part.text)
49
+ .join("\n");
50
+ children.push(
51
+ new Markdown(sanitizeTerminalText(content), 0, 0, getMarkdownTheme(), {
52
+ color: (text) => theme.fg("customMessageText", text),
53
+ }),
54
+ );
55
+ }
56
+ return createCompletionBox(children, options.outputPad, (text) => theme.bg("customMessageBg", text));
57
+ });
60
58
  }