pi-squad 0.17.2 → 0.19.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.
- package/CHANGELOG.md +89 -0
- package/package.json +3 -1
- package/src/commands.ts +585 -0
- package/src/index.ts +14 -2013
- package/src/inline-input.ts +139 -0
- package/src/lifecycle.ts +164 -0
- package/src/panel-runtime.ts +157 -0
- package/src/planner.ts +2 -3
- package/src/protocol.ts +3 -47
- package/src/report.ts +40 -2
- package/src/runtime.ts +196 -0
- package/src/scheduler-runtime.ts +117 -0
- package/src/scheduler.ts +149 -135
- package/src/skills/squad-plan/SKILL.md +103 -0
- package/src/skills/squad-plan/validate-spec.mjs +65 -0
- package/src/skills/squad-supervisor/SKILL.md +1 -0
- package/src/start-squad.ts +176 -0
- package/src/store.ts +0 -43
- package/src/tools-registration.ts +626 -0
- package/src/types.ts +0 -26
- package/src/supervisor.ts +0 -142
package/src/supervisor.ts
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* supervisor.ts — On-demand planner agent calls for quality review,
|
|
3
|
-
* plan revision, and conflict resolution.
|
|
4
|
-
*
|
|
5
|
-
* Spawns a short-lived planner agent (one-shot, --mode json) for
|
|
6
|
-
* decisions that need LLM judgment rather than mechanical rules.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import type { Squad, SupervisorResult, Task } from "./types.js";
|
|
10
|
-
import * as store from "./store.js";
|
|
11
|
-
|
|
12
|
-
// ============================================================================
|
|
13
|
-
// Supervisor Calls
|
|
14
|
-
// ============================================================================
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Review a completed task's output.
|
|
18
|
-
* Returns approve/revise/escalate verdict.
|
|
19
|
-
*/
|
|
20
|
-
export async function reviewTaskCompletion(
|
|
21
|
-
squadId: string,
|
|
22
|
-
task: Task,
|
|
23
|
-
): Promise<SupervisorResult> {
|
|
24
|
-
const squad = store.loadSquad(squadId);
|
|
25
|
-
if (!squad) {
|
|
26
|
-
return { verdict: "approve", reason: "Squad not found, auto-approving" };
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const dependents = store
|
|
30
|
-
.loadAllTasks(squadId)
|
|
31
|
-
.filter((t) => t.depends.includes(task.id));
|
|
32
|
-
|
|
33
|
-
const prompt = `Review this completed task for the squad "${squad.goal}":
|
|
34
|
-
|
|
35
|
-
Task: ${task.title}
|
|
36
|
-
Description: ${task.description}
|
|
37
|
-
Agent: ${task.agent}
|
|
38
|
-
Output: ${task.output || "(no output)"}
|
|
39
|
-
|
|
40
|
-
Dependent tasks waiting on this:
|
|
41
|
-
${dependents.map((t) => `- ${t.title} (${t.agent})`).join("\n") || "(none)"}
|
|
42
|
-
|
|
43
|
-
Questions:
|
|
44
|
-
1. Does the output satisfy the task description?
|
|
45
|
-
2. Will dependent tasks have enough context from this output?
|
|
46
|
-
3. Any concerns before proceeding?
|
|
47
|
-
|
|
48
|
-
Respond with JSON only:
|
|
49
|
-
{"verdict":"approve"|"revise"|"escalate","reason":"...","feedback":"..."}`;
|
|
50
|
-
|
|
51
|
-
try {
|
|
52
|
-
// For now, auto-approve. Full implementation would spawn planner in json mode.
|
|
53
|
-
// This avoids blocking the scheduler on a review for MVP.
|
|
54
|
-
return { verdict: "approve", reason: "Auto-approved (supervisor review not yet enabled)" };
|
|
55
|
-
} catch (error) {
|
|
56
|
-
return {
|
|
57
|
-
verdict: "approve",
|
|
58
|
-
reason: `Supervisor error: ${(error as Error).message}. Auto-approving.`,
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Analyze a stuck agent and suggest next steps.
|
|
65
|
-
*/
|
|
66
|
-
export async function analyzeStuckAgent(
|
|
67
|
-
squadId: string,
|
|
68
|
-
taskId: string,
|
|
69
|
-
agentName: string,
|
|
70
|
-
): Promise<{ action: "retry" | "reassign" | "escalate"; reason: string; suggestion?: string }> {
|
|
71
|
-
const task = store.loadTask(squadId, taskId);
|
|
72
|
-
const messages = store.loadMessages(squadId, taskId);
|
|
73
|
-
|
|
74
|
-
// Simple heuristic for now — inspect the complete task history.
|
|
75
|
-
const errorMessages = messages.filter((m) => m.type === "error");
|
|
76
|
-
if (errorMessages.length >= 3) {
|
|
77
|
-
return {
|
|
78
|
-
action: "escalate",
|
|
79
|
-
reason: `Agent ${agentName} has ${errorMessages.length} errors on task ${taskId}`,
|
|
80
|
-
suggestion: "Check the error messages and consider a different approach",
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return {
|
|
85
|
-
action: "retry",
|
|
86
|
-
reason: `Agent ${agentName} appears stuck on ${taskId}, attempting retry`,
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Determine if a blocked agent's request warrants a new subtask.
|
|
92
|
-
*/
|
|
93
|
-
export async function analyzeBlockRequest(
|
|
94
|
-
squadId: string,
|
|
95
|
-
taskId: string,
|
|
96
|
-
agentName: string,
|
|
97
|
-
blockReason: string,
|
|
98
|
-
): Promise<{
|
|
99
|
-
action: "create_subtask" | "route_message" | "escalate";
|
|
100
|
-
subtask?: { title: string; agent: string; description: string };
|
|
101
|
-
targetAgent?: string;
|
|
102
|
-
message?: string;
|
|
103
|
-
}> {
|
|
104
|
-
// Simple pattern matching for common block reasons
|
|
105
|
-
const lower = blockReason.toLowerCase();
|
|
106
|
-
|
|
107
|
-
// If they mention a specific agent, route to them
|
|
108
|
-
const mentionMatch = lower.match(/@(\w+)/);
|
|
109
|
-
if (mentionMatch) {
|
|
110
|
-
const target = mentionMatch[1];
|
|
111
|
-
const projectCwd = store.loadSquad(squadId)?.cwd;
|
|
112
|
-
const agentDef = store.loadAgentDef(target, projectCwd);
|
|
113
|
-
if (agentDef) {
|
|
114
|
-
return {
|
|
115
|
-
action: "route_message",
|
|
116
|
-
targetAgent: target,
|
|
117
|
-
message: blockReason,
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// If they mention needing something built/created, suggest a subtask
|
|
123
|
-
if (
|
|
124
|
-
lower.includes("need") &&
|
|
125
|
-
(lower.includes("create") || lower.includes("build") || lower.includes("implement"))
|
|
126
|
-
) {
|
|
127
|
-
return {
|
|
128
|
-
action: "create_subtask",
|
|
129
|
-
subtask: {
|
|
130
|
-
title: `Support: ${blockReason}`,
|
|
131
|
-
agent: "fullstack",
|
|
132
|
-
description: `Created from block request by ${agentName} on task ${taskId}: ${blockReason}`,
|
|
133
|
-
},
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// Default: escalate to human
|
|
138
|
-
return {
|
|
139
|
-
action: "escalate",
|
|
140
|
-
message: `Agent ${agentName} blocked on ${taskId}: ${blockReason}`,
|
|
141
|
-
};
|
|
142
|
-
}
|