pi-agent-flow 0.2.6 → 0.2.8

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": "pi-agent-flow",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "description": "Flow-state delegation extension for Pi coding agent.",
5
5
  "type": "module",
6
6
  "main": "index.ts",
package/render-utils.ts CHANGED
@@ -101,7 +101,7 @@ function truncateAnsi(text: string, max: number): string {
101
101
  if (visibleLength(text) <= max) return text;
102
102
 
103
103
  const head = Math.ceil(max * 0.6);
104
- const tail = max - head - 3; // 3 = " ...".length
104
+ const tail = max - head - 5; // 5 = " ... ".length
105
105
 
106
106
  // Walk through the string, collecting raw chars until we've consumed
107
107
  // `count` visible characters. ANSI sequences are copied through without
@@ -153,7 +153,7 @@ function truncateAnsi(text: string, max: number): string {
153
153
 
154
154
  const tailRaw = takeVisibleFromEnd(text, tail);
155
155
 
156
- return headResult.raw + "\x1b[0m ... " + tailRaw;
156
+ return headResult.raw + " ... " + tailRaw;
157
157
  }
158
158
 
159
159
  export function truncateChars(text: string, max: number): string {
package/render.ts CHANGED
@@ -38,7 +38,7 @@ function formatFlowToolCall(toolName: string, args: Record<string, unknown>, fg:
38
38
 
39
39
  switch (toolName) {
40
40
  case "bash": {
41
- const cmd = (args.command as string) || "...";
41
+ const cmd = ((args.command as string) || "...").replace(/[\n\r\t]+/g, " ").replace(/ +/g, " ").trim();
42
42
  return fg("muted", "$ ") + fg("toolOutput", cmd);
43
43
  }
44
44
  case "read": {
@@ -193,12 +193,12 @@ function renderFlowExpanded(
193
193
 
194
194
  // Intent
195
195
  container.addChild(new Spacer(1));
196
- container.addChild(new Text(theme.fg("muted", "─── Intent ───"), 0, 0));
196
+ container.addChild(new Text(theme.fg("muted", "─── intent ───"), 0, 0));
197
197
  container.addChild(new Text(theme.fg("dim", r.intent), 0, 0));
198
198
 
199
199
  // Flow report (structured output)
200
200
  container.addChild(new Spacer(1));
201
- container.addChild(new Text(theme.fg("muted", "─── Report ───"), 0, 0));
201
+ container.addChild(new Text(theme.fg("muted", "─── report ───"), 0, 0));
202
202
  if (flowOutput) {
203
203
  container.addChild(new Markdown(flowOutput.trim(), 0, 0, mdTheme));
204
204
  } else {
@@ -210,7 +210,7 @@ function renderFlowExpanded(
210
210
  const toolTraces = renderToolTraces(displayItems, theme);
211
211
  if (toolTraces) {
212
212
  container.addChild(new Spacer(1));
213
- container.addChild(new Text(theme.fg("muted", "─── Tool Calls ───"), 0, 0));
213
+ container.addChild(new Text(theme.fg("muted", "─── tool calls ───"), 0, 0));
214
214
  container.addChild(new Text(toolTraces, 0, 0));
215
215
  }
216
216
 
@@ -232,27 +232,27 @@ function renderFlowCollapsed(
232
232
  let text = `${theme.fg("accent", theme.bold(typeName))} ${theme.fg("dim", "─")} ${theme.fg("dim", stats)}`;
233
233
  if (error && r.stopReason) text += ` ${theme.fg("error", `[${r.stopReason}]`)}`;
234
234
 
235
- // DIR: line (intent/objective)
235
+ // dir: line (intent/objective)
236
236
  if (r.intent) {
237
- text += `\n${theme.fg("dim", "├─ DIR:")} ${theme.fg("dim", truncateChars(r.intent, 50))}`;
237
+ text += `\n${theme.fg("dim", "├─ dir:")} ${theme.fg("dim", truncateChars(r.intent, 50))}`;
238
238
  }
239
239
 
240
- // EXE: line (last tool call)
240
+ // exe: line (last tool call)
241
241
  const lastTool = getLastToolCall(r.messages);
242
242
  if (lastTool) {
243
243
  const exeStr = formatFlowToolCall(lastTool.name, lastTool.args, theme.fg.bind(theme));
244
- text += `\n${theme.fg("dim", "├─ EXE:")} ${truncateChars(exeStr, 50)}`;
244
+ text += `\n${theme.fg("dim", "├─ exe:")} ${truncateChars(exeStr, 50)}`;
245
245
  }
246
246
 
247
- // LOG: line (last assistant text or streaming)
247
+ // log: line (last assistant text or streaming)
248
248
  if (flowOutput) {
249
- text += `\n${theme.fg("dim", "└─ LOG:")} ${theme.fg("dim", truncateChars(flowOutput, 50))}`;
249
+ text += `\n${theme.fg("dim", "└─ log:")} ${theme.fg("dim", truncateChars(flowOutput, 50))}`;
250
250
  } else if (streamingText) {
251
- text += `\n${theme.fg("dim", "└─ LOG:")} ${theme.fg("dim", tailText(streamingText, 50))}`;
251
+ text += `\n${theme.fg("dim", "└─ log:")} ${theme.fg("dim", tailText(streamingText, 50))}`;
252
252
  } else if (error && r.errorMessage) {
253
- text += `\n${theme.fg("dim", "└─ LOG:")} ${theme.fg("error", truncateChars(r.errorMessage, 50))}`;
253
+ text += `\n${theme.fg("dim", "└─ log:")} ${theme.fg("error", truncateChars(r.errorMessage, 50))}`;
254
254
  } else {
255
- text += `\n${theme.fg("dim", "└─ LOG:")} ${theme.fg("dim", "[n/a]")}`;
255
+ text += `\n${theme.fg("dim", "└─ log:")} ${theme.fg("dim", "[n/a]")}`;
256
256
  }
257
257
 
258
258
  return new Text(text, 0, 0);
@@ -323,7 +323,7 @@ function renderMultiFlowExpanded(
323
323
  const toolTraces = renderToolTraces(displayItems, theme);
324
324
  if (toolTraces) {
325
325
  container.addChild(new Spacer(1));
326
- container.addChild(new Text(theme.fg("muted", "─── Tool Calls ───"), 0, 0));
326
+ container.addChild(new Text(theme.fg("muted", "─── tool calls ───"), 0, 0));
327
327
  container.addChild(new Text(toolTraces, 0, 0));
328
328
  }
329
329
  }
@@ -367,26 +367,26 @@ function renderActivityPanel(
367
367
  // Continuation indent for sub-lines
368
368
  const indent = isLast ? " " : "│ ";
369
369
 
370
- // DIR: line (intent/objective)
370
+ // dir: line (intent/objective)
371
371
  if (r.intent) {
372
- container.addChild(new Text(`${theme.fg("dim", indent + "├─ DIR:")} ${theme.fg("dim", truncateChars(r.intent, 50))}`, 0, 0));
372
+ container.addChild(new Text(`${theme.fg("dim", indent + "├─ dir:")} ${theme.fg("dim", truncateChars(r.intent, 50))}`, 0, 0));
373
373
  }
374
374
 
375
- // EXE: line (last tool call)
375
+ // exe: line (last tool call)
376
376
  const lastTool = getLastToolCall(r.messages);
377
377
  if (lastTool) {
378
378
  const exeStr = formatFlowToolCall(lastTool.name, lastTool.args, theme.fg.bind(theme));
379
- container.addChild(new Text(`${theme.fg("dim", indent + "├─ EXE:")} ${truncateChars(exeStr, 50)}`, 0, 0));
379
+ container.addChild(new Text(`${theme.fg("dim", indent + "├─ exe:")} ${truncateChars(exeStr, 50)}`, 0, 0));
380
380
  }
381
381
 
382
- // LOG: line (last assistant text)
382
+ // log: line (last assistant text)
383
383
  const lastText = getLastAssistantText(r.messages);
384
384
  if (lastText) {
385
- container.addChild(new Text(`${theme.fg("dim", indent + "└─ LOG:")} ${theme.fg("dim", truncateChars(lastText, 50))}`, 0, 0));
385
+ container.addChild(new Text(`${theme.fg("dim", indent + "└─ log:")} ${theme.fg("dim", truncateChars(lastText, 50))}`, 0, 0));
386
386
  } else if (error && r.errorMessage) {
387
- container.addChild(new Text(`${theme.fg("dim", indent + "└─ LOG:")} ${theme.fg("error", truncateChars(r.errorMessage, 50))}`, 0, 0));
387
+ container.addChild(new Text(`${theme.fg("dim", indent + "└─ log:")} ${theme.fg("error", truncateChars(r.errorMessage, 50))}`, 0, 0));
388
388
  } else {
389
- container.addChild(new Text(`${theme.fg("dim", indent + "└─ LOG:")} ${theme.fg("dim", "[n/a]")}`, 0, 0));
389
+ container.addChild(new Text(`${theme.fg("dim", indent + "└─ log:")} ${theme.fg("dim", "[n/a]")}`, 0, 0));
390
390
  }
391
391
 
392
392
  // Add blank line separator between flows (with continuation pipe)