@arhen/pi-core-subagent 1.0.8 → 1.0.9
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/src/index.ts +16 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arhen/pi-core-subagent",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "pi extension: fast in-process subagents with single/parallel/chain, background runs, intercom and agent-to-agent mailbox. Leader defines agents inline.",
|
|
6
6
|
"license": "MIT",
|
package/src/index.ts
CHANGED
|
@@ -251,6 +251,10 @@ function compactLines(run: RunSnapshot): string[] {
|
|
|
251
251
|
* └─ ✓ reviewer · 6 tools · 44s
|
|
252
252
|
* Static icons (no animation); latest activity + tool count + runtime per agent.
|
|
253
253
|
*/
|
|
254
|
+
const WIDGET_MAX_RUNS = 3;
|
|
255
|
+
const WIDGET_MAX_TASKS_PER_RUN = 4;
|
|
256
|
+
const WIDGET_MAX_LINES = 10;
|
|
257
|
+
|
|
254
258
|
class SubagentsWidget implements Component {
|
|
255
259
|
constructor(
|
|
256
260
|
private readonly getRuns: () => RunSnapshot[],
|
|
@@ -265,17 +269,18 @@ class SubagentsWidget implements Component {
|
|
|
265
269
|
const runs = this.getRuns();
|
|
266
270
|
if (runs.length === 0) return [];
|
|
267
271
|
const lines: string[] = [];
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
if (
|
|
272
|
+
let renderedRuns = 0;
|
|
273
|
+
for (const run of runs.slice(0, WIDGET_MAX_RUNS)) {
|
|
274
|
+
if (run.tasks.length === 0) continue;
|
|
275
|
+
if (lines.length > 0) lines.push("");
|
|
271
276
|
const done = run.tasks.filter((t) => TERMINAL.includes(t.status)).length;
|
|
272
277
|
const active = !TERMINAL.includes(run.status);
|
|
273
278
|
const head = active ? "accent" : "dim";
|
|
274
279
|
lines.push(truncateToWidth(`${this.theme.fg(head, active ? "●" : "○")} ${this.theme.fg(head, `Subagents (${done}/${run.tasks.length})`)}`, width, "…"));
|
|
275
280
|
const allDone = TERMINAL.includes(run.status);
|
|
276
|
-
const visible = run.tasks.slice(0,
|
|
281
|
+
const visible = run.tasks.slice(0, WIDGET_MAX_TASKS_PER_RUN);
|
|
277
282
|
visible.forEach((task, i) => {
|
|
278
|
-
const last = i === visible.length - 1 && run.tasks.length <=
|
|
283
|
+
const last = i === visible.length - 1 && run.tasks.length <= WIDGET_MAX_TASKS_PER_RUN;
|
|
279
284
|
const conn = this.theme.fg("dim", last ? "└─" : "├─");
|
|
280
285
|
const activity =
|
|
281
286
|
!TERMINAL.includes(task.status) && task.lastActivity
|
|
@@ -287,8 +292,12 @@ class SubagentsWidget implements Component {
|
|
|
287
292
|
: `${statusIcon(task.status)} ${task.agent} · ${activity}${taskStatsWithUsage(task)} · ${taskTimer(task)}`;
|
|
288
293
|
lines.push(truncateToWidth(`${conn} ${line}`, width, "…"));
|
|
289
294
|
});
|
|
290
|
-
if (run.tasks.length >
|
|
291
|
-
|
|
295
|
+
if (run.tasks.length > WIDGET_MAX_TASKS_PER_RUN) lines.push(`${this.theme.fg("dim", "└─")} ${this.theme.fg("dim", `+${run.tasks.length - WIDGET_MAX_TASKS_PER_RUN} more tasks`)}`);
|
|
296
|
+
renderedRuns += 1;
|
|
297
|
+
if (lines.length >= WIDGET_MAX_LINES) break; // keep the editor visible
|
|
298
|
+
}
|
|
299
|
+
const hiddenRuns = runs.length - renderedRuns;
|
|
300
|
+
if (hiddenRuns > 0) lines.push(`${this.theme.fg("dim", "└─")} ${this.theme.fg("dim", `+${hiddenRuns} more run${hiddenRuns > 1 ? "s" : ""}`)}`);
|
|
292
301
|
return lines;
|
|
293
302
|
}
|
|
294
303
|
}
|