refactor: load subagents from user config (~/.pi/subagents/)
- Discover prompts from ~/.pi/subagents/*.md instead of bundled prompts/ - Only register the subagent tool when at least one subagent exists - Remove directory path from tool description (agents listed dynamically)
This commit is contained in:
13
index.ts
13
index.ts
@@ -38,21 +38,26 @@ export default function (pi: ExtensionAPI) {
|
||||
});
|
||||
}
|
||||
|
||||
const prompts = discoverPrompts();
|
||||
|
||||
// Skip Registration - Only register the tool if there's at least one subagent.
|
||||
if (prompts.length === 0) return;
|
||||
|
||||
pi.registerTool({
|
||||
name: "subagent",
|
||||
label: "Subagent",
|
||||
description:
|
||||
"Delegate a task to a prompt-defined subagent from this extension's prompts/ directory. " +
|
||||
`Available at startup: ${formatPromptList(discoverPrompts())}`,
|
||||
"Delegate a task to a prompt-defined subagent. " +
|
||||
`Available at startup: ${formatPromptList(prompts)}`,
|
||||
promptSnippet:
|
||||
"Delegate tasks to subagents by name. Subagent prompts live in prompts/*.md and define approved_tools/denied_tools.",
|
||||
"Delegate tasks to subagents by name. Subagent prompts define approved_tools/denied_tools.",
|
||||
parameters: SubagentParams,
|
||||
|
||||
async execute(_toolCallId, params, signal, onUpdate, ctx) {
|
||||
// Validate Agent
|
||||
const validation = validateAgent(
|
||||
params.agent,
|
||||
discoverPrompts(),
|
||||
prompts,
|
||||
pi.getActiveTools(),
|
||||
);
|
||||
if (!validation.ok) {
|
||||
|
||||
Reference in New Issue
Block a user