@ferris1225/pi-subagents 0.22.0 → 0.23.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.ts +68 -47
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ferris1225/pi-subagents",
3
- "version": "0.22.0",
3
+ "version": "0.23.0",
4
4
  "description": "Focused sub-agent delegation for pi: explore / worker / reviewer agents in isolated context, with proactive dispatch injection and per-agent model selection.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/index.ts CHANGED
@@ -776,54 +776,75 @@ export default function (pi: ExtensionAPI): void {
776
776
  }
777
777
  }, 1000);
778
778
  return {
779
- render(width: number): string[] {
780
- const runs = monitor.getRuns();
781
- if (runs.length === 0) return [];
782
- const now = Date.now();
783
- const lines: string[] = [];
784
- for (const r of runs) {
785
- const icon = statusIcon(r.status, theme);
786
- // Chain-internal runs (auto-fix worker/reviewer) indent under their parent
787
- // reviewer. For those, the relationLabel ("fix round 1") is more
788
- // distinguishing than the repeated worker/reviewer name.
789
- const head = r.groupId ? theme.fg("dim", " ↳ ") : " ";
790
- const name = r.groupId ? (r.relationLabel ?? r.agent) : r.agent;
791
- // Header row stays short: icon, run id, agent name — the task summary
792
- // (keys-only fragments: paths, symbols, quoted phrases) gets its own
793
- // line below with a full width budget, so parallel runs of the SAME
794
- // agent are still distinguishable at a glance.
795
- const title = formatTaskSummary(r.task, Math.max(16, Math.floor(width * 0.65)), true);
796
- const left = `${head}${icon} ${theme.fg("dim", `#${r.id}`)} ${theme.bold(name)}`;
797
-
798
- // Right side: full model ref (provider/model), token usage (in/out +
799
- // cache read/write), tool count, elapsed, and the soft activity-state
800
- // annotation (idle / long-running). Trailing the header with a single
801
- // " · " chain keeps the row compact (no center gap); compactLine
802
- // clips on overflow, never the right side on its own.
803
- const model = r.model ?? "?";
804
- const usage = formatUsageCompact(r.usage);
805
- const tools = r.toolCount ? `${r.toolCount} tool${r.toolCount === 1 ? "" : "s"}` : "";
806
- const elapsed = formatElapsed(r, now);
807
- const metaParts = [model, usage, tools, elapsed].filter(Boolean);
808
- // Running is conveyed by the icon + elapsed; spell out the label only for
809
- // the other states (ready / done / stopped) so they are unambiguous.
810
- if (r.status !== "running") metaParts.push(statusLabel(r.status));
811
- const state = deriveActivityState(r, now);
812
- if (state) metaParts.push(activityStateLabel(state));
813
- if (r.annotation) metaParts.push(r.annotation);
814
- const right = metaParts.length ? theme.fg("dim", ` · ${metaParts.join(" · ")}`) : "";
815
- lines.push(compactLine(left, right, width));
816
-
817
- // Task summary sits one indent below the header, on its own line.
818
- lines.push(rightAlign(`${head} ${theme.fg("accent", title)}`, "", width));
819
-
820
- // Current activity sits one indent below, only while the run is active.
821
- if (r.activity && (r.status === "running" || r.status === "queued")) {
822
- lines.push(rightAlign(`${head} ${theme.fg("dim", r.activity)}`, "", width));
779
+ render(width: number): string[] {
780
+ const runs = monitor.getRuns();
781
+ if (runs.length === 0) return [];
782
+ const now = Date.now();
783
+ const lines: string[] = [];
784
+ // Tree layout: each top-level agent is a root whose title/activity hang
785
+ // off it as branches; auto-fix chain runs (groupId) become child nodes
786
+ // under their parent root, with a "│" continuation while more siblings
787
+ // follow. Blank lines separate agent blocks so parallel runs don't blur
788
+ // into one wall of text.
789
+ const dim = (t: string): string => theme.fg("dim", t);
790
+ for (let idx = 0; idx < runs.length; idx++) {
791
+ const r = runs[idx];
792
+ const isChain = Boolean(r.groupId);
793
+ const chainContinues = isChain && runs[idx + 1]?.groupId === r.groupId;
794
+ const activity =
795
+ r.activity && (r.status === "running" || r.status === "queued") ? r.activity : undefined;
796
+ const hasActivity = activity !== undefined;
797
+ const icon = statusIcon(r.status, theme);
798
+ // Chain-internal runs (auto-fix worker/reviewer) are child nodes under
799
+ // their parent reviewer. Their relationLabel ("fix round 1") is more
800
+ // distinguishing than the repeated worker/reviewer name.
801
+ const name = isChain ? (r.relationLabel ?? r.agent) : r.agent;
802
+ // Header row stays short: icon, run id, agent name the task summary
803
+ // (keys-only fragments: paths, symbols, quoted phrases) gets its own
804
+ // line below with a full width budget, so parallel runs of the SAME
805
+ // agent are still distinguishable at a glance.
806
+ const title = formatTaskSummary(r.task, Math.max(16, Math.floor(width * 0.65)), true);
807
+ // Hierarchy: top-level agent names are the visual anchor (accent +
808
+ // bold); chain nodes and all metadata stay quiet, so the widget reads
809
+ // top-down: roots their branches the fine print.
810
+ if (!isChain && lines.length > 0) lines.push("");
811
+ const nodeBranch = isChain ? (chainContinues ? "├─ " : "└─ ") : "";
812
+ const left = `${dim(nodeBranch)}${icon} ${dim(`#${r.id}`)} ${isChain ? name : theme.fg("accent", theme.bold(name))}`;
813
+
814
+ // Right side: full model ref (provider/model), token usage (in/out +
815
+ // cache read/write), tool count, elapsed, and the soft activity-state
816
+ // annotation (idle / long-running). Trailing the header with a single
817
+ // " · " chain keeps the row compact (no center gap); compactLine
818
+ // clips on overflow, never the right side on its own.
819
+ const model = r.model ?? "?";
820
+ const usage = formatUsageCompact(r.usage);
821
+ const tools = r.toolCount ? `${r.toolCount} tool${r.toolCount === 1 ? "" : "s"}` : "";
822
+ const elapsed = formatElapsed(r, now);
823
+ const metaParts = [model, usage, tools, elapsed].filter(Boolean);
824
+ // Running is conveyed by the icon + elapsed; spell out the label only for
825
+ // the other states (ready / done / stopped) so they are unambiguous.
826
+ if (r.status !== "running") metaParts.push(statusLabel(r.status));
827
+ const state = deriveActivityState(r, now);
828
+ if (state) metaParts.push(activityStateLabel(state));
829
+ if (r.annotation) metaParts.push(r.annotation);
830
+ const right = metaParts.length ? dim(` · ${metaParts.join(" · ")}`) : "";
831
+ lines.push(compactLine(left, right, width));
832
+
833
+ // Branches hang off the node's content column; chain nodes that still
834
+ // have siblings carry a "│" continuation down to the last one.
835
+ const continuation = isChain ? (chainContinues ? "│ " : " ") : "";
836
+ // Task summary is the first branch; the summary itself is plain text —
837
+ // no accent, so it never competes with the agent name or pi's own UI.
838
+ lines.push(
839
+ rightAlign(`${continuation}${dim(hasActivity ? "├─ " : "└─ ")}${dim("title: ")}${theme.fg("text", title)}`, "", width),
840
+ );
841
+ // Current activity is the last branch, only while the run is active.
842
+ if (hasActivity) {
843
+ lines.push(rightAlign(`${continuation}${dim("└─ ")}${dim(activity)}`, "", width));
844
+ }
823
845
  }
824
- }
825
- return lines;
826
- },
846
+ return lines;
847
+ },
827
848
  invalidate() {},
828
849
  dispose() {
829
850
  unsub();