@ryan_nookpi/pi-extension-subagent 0.4.1 → 0.4.2

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/commands.ts CHANGED
@@ -63,7 +63,12 @@ import { buildMainContextText, makeSubagentSessionFile, wrapTaskWithMainContext
63
63
  import { formatStarterPackNotice, offerStarterPackIfEmpty } from "./starter-pack.js";
64
64
  import { type SubagentStore, truncateText, updateRunFromResult } from "./store.js";
65
65
  import { createSubagentToolExecute } from "./tool-execute.js";
66
- import { renderSubagentToolCall, renderSubagentToolResult } from "./tool-render.js";
66
+ import {
67
+ renderListAgentsCall,
68
+ renderListAgentsResult,
69
+ renderSubagentToolCall,
70
+ renderSubagentToolResult,
71
+ } from "./tool-render.js";
67
72
  import type { CommandRunState, SingleResult, SubagentDetails } from "./types.js";
68
73
  import { ListAgentsParams, SubagentParams } from "./types.js";
69
74
  import { updateCommandRunsWidget, type WidgetRenderCtx } from "./widget.js";
@@ -927,6 +932,8 @@ export function registerAll(pi: ExtensionAPI, store: SubagentStore): SubagentReg
927
932
  description:
928
933
  "List available subagent definitions (name, source, model, thinking, tools, description). Useful before planning delegation.",
929
934
  parameters: ListAgentsParams,
935
+ renderCall: renderListAgentsCall,
936
+ renderResult: renderListAgentsResult,
930
937
  execute: async (_toolCallId, _params: Record<string, any>, _signal, _onUpdate, ctx) => {
931
938
  const starterPack = await offerStarterPackIfEmpty(ctx);
932
939
  const discovery = starterPack.discovery;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ryan_nookpi/pi-extension-subagent",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Asynchronous subagent delegation for pi with run, batch, chain, and continuation workflows.",
5
5
  "license": "MIT",
6
6
  "repository": {
package/tool-render.ts CHANGED
@@ -27,10 +27,12 @@ type ToolRenderResult = {
27
27
  type ToolRenderArgs = { command?: unknown };
28
28
  type ToolCallRenderContext = { expanded: boolean };
29
29
  type CompactBlock = { agent: string; task: string };
30
+ type ListAgentsDetails = { agents?: Array<{ name?: unknown }> };
30
31
 
31
32
  const COMPACT_TASK_PREVIEW_WIDTH = 72;
32
33
  const COMPACT_AGENT_WIDTH = 20;
33
34
  const COMPACT_MAX_ITEMS = 3;
35
+ const COMPACT_AGENT_LIST_COUNT = 3;
34
36
 
35
37
  function normalizeTaskPreview(task: string): string {
36
38
  return truncateText(task.replace(/\s+/g, " ").trim(), COMPACT_TASK_PREVIEW_WIDTH);
@@ -110,6 +112,11 @@ function renderCompactLaunch(command: unknown): string | null {
110
112
  return ` run · ${params.agent} · ${contextLabel}\n ${task}`;
111
113
  }
112
114
 
115
+ function getToolResultText(result: ToolRenderResult): string {
116
+ const raw = result.content[0];
117
+ return (raw?.type === "text" ? raw.text : undefined) ?? "(no output)";
118
+ }
119
+
113
120
  function renderDisplayItems(items: DisplayItem[], expanded: boolean, theme: RenderTheme, limit?: number): string {
114
121
  const toShow = limit ? items.slice(-limit) : items;
115
122
  const skipped = limit && items.length > limit ? items.length - limit : 0;
@@ -128,6 +135,38 @@ function renderDisplayItems(items: DisplayItem[], expanded: boolean, theme: Rend
128
135
 
129
136
  // ─── renderCall ──────────────────────────────────────────────────────────────
130
137
 
138
+ export function renderListAgentsCall(_args: unknown, theme: RenderTheme) {
139
+ return new Text(theme.fg("toolTitle", theme.bold("list-agents")), 0, 0);
140
+ }
141
+
142
+ export function renderListAgentsResult(
143
+ result: ToolRenderResult,
144
+ { expanded }: { expanded: boolean },
145
+ theme: RenderTheme,
146
+ ) {
147
+ const fullText = getToolResultText(result);
148
+ if (expanded) return new Text(theme.fg("toolOutput", fullText), 0, 0);
149
+
150
+ const details = result.details as ListAgentsDetails | undefined;
151
+ const names = details?.agents
152
+ ?.map((agent) => (typeof agent.name === "string" ? truncateText(agent.name, COMPACT_AGENT_WIDTH) : ""))
153
+ .filter(Boolean);
154
+ if (!names) return new Text(theme.fg("toolOutput", fullText.split("\n")[0] ?? fullText), 0, 0);
155
+ if (names.length === 0) return new Text(theme.fg("muted", "○ no agents"), 0, 0);
156
+
157
+ const visibleNames = names.slice(0, COMPACT_AGENT_LIST_COUNT);
158
+ const hiddenCount = names.length - visibleNames.length;
159
+ const hiddenSuffix = hiddenCount > 0 ? `, +${hiddenCount}` : "";
160
+ return new Text(
161
+ theme.fg(
162
+ "toolOutput",
163
+ `✓ ${names.length} agent${names.length === 1 ? "" : "s"} · ${visibleNames.join(", ")}${hiddenSuffix}`,
164
+ ),
165
+ 0,
166
+ 0,
167
+ );
168
+ }
169
+
131
170
  export function renderSubagentToolCall(
132
171
  args: ToolRenderArgs,
133
172
  theme: RenderTheme,