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 +1 -1
- package/render-utils.ts +2 -2
- package/render.ts +22 -22
package/package.json
CHANGED
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 -
|
|
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 + "
|
|
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", "───
|
|
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", "───
|
|
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", "───
|
|
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
|
-
//
|
|
235
|
+
// dir: line (intent/objective)
|
|
236
236
|
if (r.intent) {
|
|
237
|
-
text += `\n${theme.fg("dim", "├─
|
|
237
|
+
text += `\n${theme.fg("dim", "├─ dir:")} ${theme.fg("dim", truncateChars(r.intent, 50))}`;
|
|
238
238
|
}
|
|
239
239
|
|
|
240
|
-
//
|
|
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", "├─
|
|
244
|
+
text += `\n${theme.fg("dim", "├─ exe:")} ${truncateChars(exeStr, 50)}`;
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
-
//
|
|
247
|
+
// log: line (last assistant text or streaming)
|
|
248
248
|
if (flowOutput) {
|
|
249
|
-
text += `\n${theme.fg("dim", "└─
|
|
249
|
+
text += `\n${theme.fg("dim", "└─ log:")} ${theme.fg("dim", truncateChars(flowOutput, 50))}`;
|
|
250
250
|
} else if (streamingText) {
|
|
251
|
-
text += `\n${theme.fg("dim", "└─
|
|
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", "└─
|
|
253
|
+
text += `\n${theme.fg("dim", "└─ log:")} ${theme.fg("error", truncateChars(r.errorMessage, 50))}`;
|
|
254
254
|
} else {
|
|
255
|
-
text += `\n${theme.fg("dim", "└─
|
|
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", "───
|
|
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
|
-
//
|
|
370
|
+
// dir: line (intent/objective)
|
|
371
371
|
if (r.intent) {
|
|
372
|
-
container.addChild(new Text(`${theme.fg("dim", indent + "├─
|
|
372
|
+
container.addChild(new Text(`${theme.fg("dim", indent + "├─ dir:")} ${theme.fg("dim", truncateChars(r.intent, 50))}`, 0, 0));
|
|
373
373
|
}
|
|
374
374
|
|
|
375
|
-
//
|
|
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 + "├─
|
|
379
|
+
container.addChild(new Text(`${theme.fg("dim", indent + "├─ exe:")} ${truncateChars(exeStr, 50)}`, 0, 0));
|
|
380
380
|
}
|
|
381
381
|
|
|
382
|
-
//
|
|
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 + "└─
|
|
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 + "└─
|
|
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 + "└─
|
|
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)
|