pi-squad 0.6.1 → 0.6.3
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 +14 -1
- package/src/planner.ts +10 -2
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -105,6 +105,8 @@ export default function (pi: ExtensionAPI) {
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
// When NO squad is active, nudge the agent to consider using squad for complex tasks
|
|
108
|
+
const allAgents = store.loadAllAgentDefs(ctx.cwd).filter((a) => a.name !== "planner" && !a.disabled);
|
|
109
|
+
const agentList = allAgents.map((a) => `${a.name} (${a.role})`).join(", ");
|
|
108
110
|
const squadNudge = [
|
|
109
111
|
`<squad_hint>`,
|
|
110
112
|
`You have the "squad" tool available for multi-agent collaboration.`,
|
|
@@ -112,8 +114,9 @@ export default function (pi: ExtensionAPI) {
|
|
|
112
114
|
`would benefit from parallel execution, or is too large for a single agent context.`,
|
|
113
115
|
`The squad tool decomposes work into tasks, assigns specialist agents, and runs them in parallel.`,
|
|
114
116
|
`When in doubt about whether a task is complex enough, prefer using squad — it handles the coordination for you.`,
|
|
117
|
+
allAgents.length > 0 ? `Available agents: ${agentList}. When providing tasks, the "agent" field must be one of these names.` : ``,
|
|
115
118
|
`</squad_hint>`,
|
|
116
|
-
].join("\n");
|
|
119
|
+
].filter(Boolean).join("\n");
|
|
117
120
|
|
|
118
121
|
return {
|
|
119
122
|
systemPrompt: event.systemPrompt + "\n\n" + squadNudge,
|
|
@@ -1176,6 +1179,16 @@ async function startSquad(
|
|
|
1176
1179
|
depends: t.depends || [],
|
|
1177
1180
|
})),
|
|
1178
1181
|
};
|
|
1182
|
+
|
|
1183
|
+
// Validate agent names — remap unknown agents to fullstack
|
|
1184
|
+
for (const task of plan.tasks) {
|
|
1185
|
+
const agentDef = store.loadAgentDef(task.agent, cwd);
|
|
1186
|
+
if (!agentDef) {
|
|
1187
|
+
const original = task.agent;
|
|
1188
|
+
task.agent = "fullstack";
|
|
1189
|
+
task.description = `[Note: agent "${original}" not found, remapped to fullstack]\n\n${task.description}`;
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1179
1192
|
} else {
|
|
1180
1193
|
// Run planner to generate task breakdown
|
|
1181
1194
|
try {
|
package/src/planner.ts
CHANGED
|
@@ -65,7 +65,8 @@ export async function runPlanner(options: PlannerOptions): Promise<PlannerOutput
|
|
|
65
65
|
model: model || plannerDef?.model || undefined,
|
|
66
66
|
});
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
const agentNames = new Set(allAgents.map((a) => a.name));
|
|
69
|
+
return parsePlannerOutput(output, agentNames);
|
|
69
70
|
} finally {
|
|
70
71
|
try {
|
|
71
72
|
fs.unlinkSync(promptFile);
|
|
@@ -172,7 +173,7 @@ async function runPiJson(options: PiJsonOptions): Promise<string> {
|
|
|
172
173
|
// Output Parsing
|
|
173
174
|
// ============================================================================
|
|
174
175
|
|
|
175
|
-
function parsePlannerOutput(text: string): PlannerOutput {
|
|
176
|
+
function parsePlannerOutput(text: string, validAgents?: Set<string>): PlannerOutput {
|
|
176
177
|
// Try to extract JSON from the text (might be wrapped in markdown code blocks)
|
|
177
178
|
const jsonMatch = text.match(/```(?:json)?\s*\n?([\s\S]*?)\n?```/) || text.match(/(\{[\s\S]*\})/);
|
|
178
179
|
|
|
@@ -194,6 +195,13 @@ function parsePlannerOutput(text: string): PlannerOutput {
|
|
|
194
195
|
}
|
|
195
196
|
if (!task.depends) task.depends = [];
|
|
196
197
|
if (!task.description) task.description = "";
|
|
198
|
+
|
|
199
|
+
// Remap unknown agent names to fullstack (the generalist)
|
|
200
|
+
if (validAgents && !validAgents.has(task.agent)) {
|
|
201
|
+
const original = task.agent;
|
|
202
|
+
task.agent = "fullstack";
|
|
203
|
+
task.description = `[Note: planner assigned "${original}" which doesn't exist, remapped to fullstack]\n\n${task.description}`;
|
|
204
|
+
}
|
|
197
205
|
}
|
|
198
206
|
|
|
199
207
|
if (!parsed.agents) parsed.agents = {};
|