pi-agent-flow 0.4.2 → 0.4.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/render.ts +17 -17
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-agent-flow",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "Flow-state delegation extension for Pi coding agent.",
5
5
  "type": "module",
6
6
  "main": "index.ts",
package/render.ts CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  import * as os from "node:os";
9
9
  import { getMarkdownTheme } from "@mariozechner/pi-coding-agent";
10
- import { Container, Markdown, Spacer, Text } from "@mariozechner/pi-tui";
10
+ import { Container, Markdown, Spacer, Text, TruncatedText } from "@mariozechner/pi-tui";
11
11
  import { getFlowSummaryText } from "./runner-events.js";
12
12
  import {
13
13
  type DisplayItem,
@@ -22,7 +22,7 @@ import {
22
22
  isFlowError,
23
23
  isFlowSuccess,
24
24
  } from "./types.js";
25
- import { formatFixedTokens, formatCompactStats, formatFlowTypeName, truncateChars, tailText, getTruncationBudget } from "./render-utils.js";
25
+ import { formatFixedTokens, formatCompactStats, formatFlowTypeName } from "./render-utils.js";
26
26
 
27
27
  function shortenPath(p: string): string {
28
28
  const home = os.homedir();
@@ -231,29 +231,29 @@ function renderFlowCollapsed(
231
231
  const typeName = formatFlowTypeName(r.type);
232
232
  let header = `${theme.fg("accent", theme.bold(typeName))} ${theme.fg("dim", "─")} ${theme.fg("dim", stats)}`;
233
233
  if (error && r.stopReason) header += ` ${theme.fg("error", `[${r.stopReason}]`)}`;
234
- container.addChild(new Text(truncateChars(header, maxWidth), 0, 0));
234
+ container.addChild(new TruncatedText(header, 0, 0));
235
235
 
236
236
  // dir: line (intent/objective)
237
237
  if (r.intent) {
238
- container.addChild(new Text(`${theme.fg("dim", "├─ dir:")} ${theme.fg("dim", truncateChars(r.intent, getTruncationBudget(8)))}`, 0, 0));
238
+ container.addChild(new TruncatedText(`${theme.fg("dim", "├─ dir:")} ${theme.fg("dim", r.intent)}`, 0, 0));
239
239
  }
240
240
 
241
241
  // exe: line (last tool call)
242
242
  const lastTool = getLastToolCall(r.messages);
243
243
  if (lastTool) {
244
244
  const exeStr = formatFlowToolCall(lastTool.name, lastTool.args, theme.fg.bind(theme));
245
- container.addChild(new Text(`${theme.fg("dim", "├─ exe:")} ${truncateChars(exeStr, getTruncationBudget(8))}`, 0, 0));
245
+ container.addChild(new TruncatedText(`${theme.fg("dim", "├─ exe:")} ${exeStr}`, 0, 0));
246
246
  }
247
247
 
248
248
  // log: line (last assistant text or streaming)
249
249
  if (flowOutput) {
250
- container.addChild(new Text(`${theme.fg("dim", "└─ log:")} ${theme.fg("dim", truncateChars(flowOutput, getTruncationBudget(8)))}`, 0, 0));
250
+ container.addChild(new TruncatedText(`${theme.fg("dim", "└─ log:")} ${theme.fg("dim", flowOutput)}`, 0, 0));
251
251
  } else if (streamingText) {
252
- container.addChild(new Text(`${theme.fg("dim", "└─ log:")} ${theme.fg("dim", tailText(streamingText, getTruncationBudget(8)))}`, 0, 0));
252
+ container.addChild(new TruncatedText(`${theme.fg("dim", "└─ log:")} ${theme.fg("dim", streamingText)}`, 0, 0));
253
253
  } else if (error && r.errorMessage) {
254
- container.addChild(new Text(`${theme.fg("dim", "└─ log:")} ${theme.fg("error", truncateChars(r.errorMessage, getTruncationBudget(8)))}`, 0, 0));
254
+ container.addChild(new TruncatedText(`${theme.fg("dim", "└─ log:")} ${theme.fg("error", r.errorMessage)}`, 0, 0));
255
255
  } else {
256
- container.addChild(new Text(`${theme.fg("dim", "└─ log:")} ${theme.fg("dim", "[n/a]")}`, 0, 0));
256
+ container.addChild(new TruncatedText(`${theme.fg("dim", "└─ log:")} ${theme.fg("dim", "[n/a]")}`, 0, 0));
257
257
  }
258
258
 
259
259
  return container;
@@ -364,40 +364,40 @@ function renderActivityPanel(
364
364
  if (error && r.stopReason) {
365
365
  headerLine += ` ${theme.fg("error", `[${r.stopReason}]`)}`;
366
366
  }
367
- container.addChild(new Text(truncateChars(headerLine, maxWidth), 0, 0));
367
+ container.addChild(new TruncatedText(headerLine, 0, 0));
368
368
 
369
369
  // Continuation indent for sub-lines
370
370
  const indent = isLast ? " " : "│ ";
371
371
 
372
372
  // dir: line (intent/objective)
373
373
  if (r.intent) {
374
- container.addChild(new Text(`${theme.fg("dim", indent + "├─ dir:")} ${theme.fg("dim", truncateChars(r.intent, getTruncationBudget(11)))}`, 0, 0));
374
+ container.addChild(new TruncatedText(`${theme.fg("dim", indent + "├─ dir:")} ${theme.fg("dim", r.intent)}`, 0, 0));
375
375
  }
376
376
 
377
377
  // exe: line (last tool call)
378
378
  const lastTool = getLastToolCall(r.messages);
379
379
  if (lastTool) {
380
380
  const exeStr = formatFlowToolCall(lastTool.name, lastTool.args, theme.fg.bind(theme));
381
- container.addChild(new Text(`${theme.fg("dim", indent + "├─ exe:")} ${truncateChars(exeStr, getTruncationBudget(11))}`, 0, 0));
381
+ container.addChild(new TruncatedText(`${theme.fg("dim", indent + "├─ exe:")} ${exeStr}`, 0, 0));
382
382
  }
383
383
 
384
384
  // log: line (last assistant text)
385
385
  const lastText = getLastAssistantText(r.messages);
386
386
  if (lastText) {
387
- container.addChild(new Text(`${theme.fg("dim", indent + "└─ log:")} ${theme.fg("dim", truncateChars(lastText, getTruncationBudget(11)))}`, 0, 0));
387
+ container.addChild(new TruncatedText(`${theme.fg("dim", indent + "└─ log:")} ${theme.fg("dim", lastText)}`, 0, 0));
388
388
  } else if (error && r.errorMessage) {
389
- container.addChild(new Text(`${theme.fg("dim", indent + "└─ log:")} ${theme.fg("error", truncateChars(r.errorMessage, getTruncationBudget(11)))}`, 0, 0));
389
+ container.addChild(new TruncatedText(`${theme.fg("dim", indent + "└─ log:")} ${theme.fg("error", r.errorMessage)}`, 0, 0));
390
390
  } else {
391
- container.addChild(new Text(`${theme.fg("dim", indent + "└─ log:")} ${theme.fg("dim", "[n/a]")}`, 0, 0));
391
+ container.addChild(new TruncatedText(`${theme.fg("dim", indent + "└─ log:")} ${theme.fg("dim", "[n/a]")}`, 0, 0));
392
392
  }
393
393
 
394
394
  // Add blank line separator between flows (with continuation pipe)
395
395
  if (!isLast) {
396
- container.addChild(new Text(theme.fg("dim", "│"), 0, 0));
396
+ container.addChild(new TruncatedText(theme.fg("dim", "│"), 0, 0));
397
397
  }
398
398
  }
399
399
 
400
- container.addChild(new Text(theme.fg("muted", "(Ctrl+O to expand tool traces)"), 0, 0));
400
+ container.addChild(new TruncatedText(theme.fg("muted", "(Ctrl+O to expand tool traces)"), 0, 0));
401
401
 
402
402
  return container;
403
403
  }