@bacnh85/pi-subagent 0.1.0 → 0.1.1

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/index.ts +60 -0
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -149,6 +149,66 @@ export default function (pi: ExtensionAPI) {
149
149
  // Resolve bundled agents directory relative to this extension file
150
150
  const bundledAgentsDir = path.resolve(__dirname, "agents");
151
151
 
152
+ // /subagent command — list available agents
153
+ pi.registerCommand("subagent", {
154
+ description: "List available sub-agents, reload agent definitions, or show agent details",
155
+ handler: async (args, ctx) => {
156
+ const cmd = args.trim().toLowerCase();
157
+ const discovery = discoverAgents(ctx.cwd, "both", bundledAgentsDir);
158
+
159
+ if (cmd === "reload" || cmd === "refresh") {
160
+ invalidateAgentCache();
161
+ const fresh = discoverAgents(ctx.cwd, "both", bundledAgentsDir);
162
+ const list = formatAgentList(fresh.agents, 20);
163
+ const extra = list.remaining > 0 ? `\n ... +${list.remaining} more` : "";
164
+ const dirs = fresh.projectAgentsDir ? `project: ${fresh.projectAgentsDir}` : "no project agents dir";
165
+ pi.sendMessage({
166
+ customType: "pi-subagent",
167
+ content: `Agent definitions reloaded.\n\nAvailable agents (${fresh.agents.length}):\n ${list.text}${extra}\n\nDirectories searched:\n user: ${path.join(getAgentDir(), "agents")}\n ${dirs}\n bundled: ${bundledAgentsDir}`,
168
+ display: true,
169
+ });
170
+ ctx.ui.notify("Agent definitions reloaded", "info");
171
+ return;
172
+ }
173
+
174
+ if (cmd) {
175
+ // Show details for a specific agent
176
+ const agent = discovery.agents.find(
177
+ (a) => a.name.toLowerCase() === cmd,
178
+ );
179
+ if (!agent) {
180
+ ctx.ui.notify(`Unknown agent: "${args.trim()}". Use /subagent to list all.`, "error");
181
+ return;
182
+ }
183
+ pi.sendMessage({
184
+ customType: "pi-subagent",
185
+ content: [
186
+ `Agent: ${agent.name} (${agent.source})`,
187
+ `Description: ${agent.description}`,
188
+ `Model: ${agent.model || "inherits from parent"}`,
189
+ `Tools: ${agent.tools?.join(", ") || "all default"}`,
190
+ `Source file: ${agent.filePath}`,
191
+ "",
192
+ "--- System Prompt ---",
193
+ agent.systemPrompt,
194
+ ].join("\n"),
195
+ display: true,
196
+ });
197
+ return;
198
+ }
199
+
200
+ // List all agents
201
+ const list = formatAgentList(discovery.agents, 20);
202
+ const extra = list.remaining > 0 ? `\n ... +${list.remaining} more` : "";
203
+ const dirs = discovery.projectAgentsDir ? `\n project: ${discovery.projectAgentsDir}` : "";
204
+ pi.sendMessage({
205
+ customType: "pi-subagent",
206
+ content: `Available agents (${discovery.agents.length}):\n ${list.text}${extra}\n\nScopes searched:\n user: ${path.join(getAgentDir(), "agents")}${dirs}\n bundled: ${bundledAgentsDir}\n\nUse /subagent <name> for agent details, /subagent reload to refresh.`,
207
+ display: true,
208
+ });
209
+ },
210
+ });
211
+
152
212
  pi.registerTool({
153
213
  name: "subagent",
154
214
  label: "Subagent",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bacnh85/pi-subagent",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Minimal-overhead sub-agent extension for pi. Delegate tasks to specialized agents with isolated context using the pi SDK in-process.",
5
5
  "type": "module",
6
6
  "license": "MIT",