@ferris1225/pi-subagents 4.3.32 → 4.3.34
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 +36 -0
- package/README.md +94 -2
- package/index.ts +10 -1
- package/package.json +6 -1
- package/skills/workflow/SKILL.md +230 -0
- package/src/delegation/agents.ts +1 -0
- package/src/delegation/dispatch.ts +11 -115
- package/src/delegation/prompt.ts +1 -0
- package/src/lifecycle/dispatch-core.ts +142 -0
- package/src/lifecycle/runtime.ts +28 -0
- package/src/lifecycle/thread-lifecycle.ts +36 -19
- package/src/lifecycle/thread-shared.ts +7 -0
- package/src/lifecycle/tools.ts +82 -6
- package/src/presentation/monitor.ts +17 -1
- package/src/workflow/durable.ts +195 -0
- package/src/workflow/engine.ts +660 -0
- package/src/workflow/files.ts +217 -0
- package/src/workflow/plan.ts +340 -0
- package/src/workflow/state.ts +48 -0
- package/src/workflow/tool.ts +286 -0
- package/workflows/code-review.md +57 -0
- package/workflows/migration.md +52 -0
- package/workflows/research.md +47 -0
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The subagent_workflow tool: declare a dependency graph of sub-agent phases
|
|
3
|
+
* once and let the runtime dispatch dependents as prerequisites settle.
|
|
4
|
+
*
|
|
5
|
+
* The graph is validated before anything starts (see plan.ts), so an invalid
|
|
6
|
+
* plan costs zero child processes. A valid plan returns a launch receipt
|
|
7
|
+
* immediately; one completion message summarises the whole graph.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { ExtensionAPI, ExtensionContext, Theme } from "@earendil-works/pi-coding-agent";
|
|
11
|
+
import { Text } from "@earendil-works/pi-tui";
|
|
12
|
+
import { Type } from "typebox";
|
|
13
|
+
import { isWriteCapableAgent, loadBuiltinAgents } from "../delegation/agents.ts";
|
|
14
|
+
import { defaultIsolationMode, IsolationSchema, PhaseIdSchema, ScopeSchema } from "../delegation/dispatch.ts";
|
|
15
|
+
import { loadConfig } from "../configuration/config.ts";
|
|
16
|
+
import { resolveSubagentConcurrency } from "../execution/background.ts";
|
|
17
|
+
import type { SubagentRuntime } from "../lifecycle/runtime.ts";
|
|
18
|
+
import type { DispatchCore } from "../lifecycle/dispatch-core.ts";
|
|
19
|
+
import { projectResultsRoot } from "../lifecycle/thread-shared.ts";
|
|
20
|
+
import { formatTaskSummary, monitor } from "../presentation/monitor.ts";
|
|
21
|
+
import { pruneWorkflowRecords } from "./durable.ts";
|
|
22
|
+
import {
|
|
23
|
+
findOwnedPhases,
|
|
24
|
+
persistInterruptedWorkflows,
|
|
25
|
+
readRetainedWorkflows,
|
|
26
|
+
startWorkflow,
|
|
27
|
+
workflowStatus,
|
|
28
|
+
type WorkflowStatusView,
|
|
29
|
+
} from "./engine.ts";
|
|
30
|
+
import { resolveWorkflowDefinition } from "./files.ts";
|
|
31
|
+
import { compileWorkflow, WORKFLOW_NODE_ID_MAX_LENGTH, type WorkflowPlanInput } from "./plan.ts";
|
|
32
|
+
|
|
33
|
+
const WorkflowNodeSchema = Type.Object({
|
|
34
|
+
id: Type.String({
|
|
35
|
+
minLength: 1,
|
|
36
|
+
maxLength: WORKFLOW_NODE_ID_MAX_LENGTH,
|
|
37
|
+
pattern: "^[A-Za-z][A-Za-z0-9._-]*$",
|
|
38
|
+
description: "Stable node id. Dependents name it in dependsOn and in result placeholders.",
|
|
39
|
+
}),
|
|
40
|
+
agent: Type.String({ minLength: 1, description: "Name of an enabled agent." }),
|
|
41
|
+
task: Type.String({
|
|
42
|
+
minLength: 1,
|
|
43
|
+
pattern: "\\S",
|
|
44
|
+
description:
|
|
45
|
+
"Self-contained brief. {{<dependency-id>}} interpolates an upstream node's answer; {{<id>.status}}, {{<id>.runId}} and {{<id>.error}} interpolate facts. Only declared dependencies may be referenced.",
|
|
46
|
+
}),
|
|
47
|
+
dependsOn: Type.Optional(
|
|
48
|
+
Type.Array(Type.String({ minLength: 1 }), {
|
|
49
|
+
description: "Node ids that must complete before this one starts. Omit for a node that starts immediately.",
|
|
50
|
+
}),
|
|
51
|
+
),
|
|
52
|
+
phaseId: PhaseIdSchema,
|
|
53
|
+
scope: ScopeSchema,
|
|
54
|
+
cwd: Type.Optional(Type.String({ description: "Working directory for this node; defaults to the caller cwd." })),
|
|
55
|
+
isolation: IsolationSchema,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const WorkflowParams = Type.Object({
|
|
59
|
+
name: Type.Optional(
|
|
60
|
+
Type.String({
|
|
61
|
+
maxLength: 60,
|
|
62
|
+
description: "Workflow name: shown in the widget and status, and the namespace for derived phase ids.",
|
|
63
|
+
}),
|
|
64
|
+
),
|
|
65
|
+
description: Type.Optional(Type.String({ description: "One line stating what the graph delivers." })),
|
|
66
|
+
nodes: Type.Optional(
|
|
67
|
+
Type.Array(WorkflowNodeSchema, { description: "Inline graph. Mutually exclusive with workflow/file." }),
|
|
68
|
+
),
|
|
69
|
+
workflow: Type.Optional(
|
|
70
|
+
Type.String({ description: "Name of a saved workflow under .pi/workflows/ or ~/.pi/agent/workflows/." }),
|
|
71
|
+
),
|
|
72
|
+
file: Type.Optional(
|
|
73
|
+
Type.String({ description: "Workflow definition file (JSON, or Markdown with a json fenced block)." }),
|
|
74
|
+
),
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
export interface WorkflowToolDetails {
|
|
78
|
+
workflow: WorkflowStatusView;
|
|
79
|
+
runIds: number[];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function launchReceipt(status: WorkflowStatusView): string {
|
|
83
|
+
const started = status.nodes.filter((node) => !node.waitingFor && node.state === "running").length;
|
|
84
|
+
const waiting = status.nodes.filter((node) => node.state === "pending").length;
|
|
85
|
+
const lines = [
|
|
86
|
+
"workflow #" + status.id + " " + status.name + " started · " + status.nodes.length + " node" + (status.nodes.length === 1 ? "" : "s") + " (" + started + " started, " + waiting + " waiting on dependencies)",
|
|
87
|
+
...(status.description ? [status.description] : []),
|
|
88
|
+
"",
|
|
89
|
+
"Nodes:",
|
|
90
|
+
...status.nodes.map((node) => {
|
|
91
|
+
const parts = ["- " + node.id + " (" + node.agent + ")"];
|
|
92
|
+
if (node.runId !== undefined) parts.push("run #" + node.runId);
|
|
93
|
+
else if (node.waitingFor) parts.push("waits for " + node.waitingFor.join(", "));
|
|
94
|
+
else parts.push(node.state);
|
|
95
|
+
return parts.join(" · ");
|
|
96
|
+
}),
|
|
97
|
+
"",
|
|
98
|
+
"The graph dispatches each dependent the moment its prerequisites settle, with no further dispatch from you. One summary arrives when the whole graph settles; continue disjoint work or end your turn, and do not poll. maxConcurrentAgents paces nodes, so a wide graph queues instead of refusing.",
|
|
99
|
+
];
|
|
100
|
+
return lines.join("\n");
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** Compact tool-card view: header plus node rows. */
|
|
104
|
+
function formatWorkflowStatusLines(status: WorkflowStatusView, theme: Theme, maxNodes: number): string[] {
|
|
105
|
+
const header =
|
|
106
|
+
theme.fg("toolTitle", theme.bold("workflow #" + status.id + " ")) +
|
|
107
|
+
theme.fg("accent", status.name) +
|
|
108
|
+
" " +
|
|
109
|
+
theme.fg("dim", status.state);
|
|
110
|
+
const lines = [header];
|
|
111
|
+
for (const node of status.nodes.slice(0, maxNodes)) {
|
|
112
|
+
const id = node.runId === undefined ? "—" : "#" + node.runId;
|
|
113
|
+
const detail = node.waitingFor
|
|
114
|
+
? "waits for " + node.waitingFor.join(", ")
|
|
115
|
+
: node.error
|
|
116
|
+
? "error: " + formatTaskSummary(node.error, 60, false)
|
|
117
|
+
: node.activity
|
|
118
|
+
? node.activity
|
|
119
|
+
: node.state;
|
|
120
|
+
lines.push(
|
|
121
|
+
" " + theme.fg("dim", id.padEnd(6)) + theme.fg("accent", node.id) + " " +
|
|
122
|
+
theme.fg("dim", "(" + node.agent + ") " + detail),
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
if (status.nodes.length > maxNodes) lines.push(theme.fg("dim", " … +" + (status.nodes.length - maxNodes) + " more nodes"));
|
|
126
|
+
return lines;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export function registerWorkflowTool(pi: ExtensionAPI, runtime: SubagentRuntime, core: DispatchCore): void {
|
|
130
|
+
// A graph the session ends under keeps its shape on disk for the next
|
|
131
|
+
// session's recovery notice.
|
|
132
|
+
runtime.shutdownHooks.push(() => persistInterruptedWorkflows(runtime));
|
|
133
|
+
|
|
134
|
+
pi.registerTool({
|
|
135
|
+
name: "subagent_workflow",
|
|
136
|
+
label: "Subagent Workflow",
|
|
137
|
+
description:
|
|
138
|
+
"Run a dependency graph of sub-agent phases: declare nodes with dependsOn, and the runtime dispatches each dependent as soon as its prerequisites settle and a process slot frees. Use it when a request has several phases with real ordering (map, then parallel changes, then a gate) and you would otherwise dispatch wave after wave by hand. One summary arrives when the graph settles. Nodes are ordinary one-shot runs; main still owns integration, the final gate, and release.",
|
|
139
|
+
exposure: "model-only",
|
|
140
|
+
executionMode: "sequential",
|
|
141
|
+
annotations: {
|
|
142
|
+
readOnlyHint: false,
|
|
143
|
+
destructiveHint: true,
|
|
144
|
+
idempotentHint: false,
|
|
145
|
+
openWorldHint: true,
|
|
146
|
+
},
|
|
147
|
+
parameters: WorkflowParams,
|
|
148
|
+
|
|
149
|
+
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
150
|
+
await runtime.durableRestore;
|
|
151
|
+
monitor.beginTurn();
|
|
152
|
+
const config = await loadConfig(runtime.configPath);
|
|
153
|
+
runtime.backgroundQueue.setConcurrency(resolveSubagentConcurrency());
|
|
154
|
+
// Both built-in roles are always available; the live tool metadata decides
|
|
155
|
+
// which of them is write-capable in this session.
|
|
156
|
+
const agents = loadBuiltinAgents();
|
|
157
|
+
const toolInfos = runtime.getToolInfos();
|
|
158
|
+
core.setEnvironment({ ctx, config, agents });
|
|
159
|
+
|
|
160
|
+
const hasInline = (params.nodes?.length ?? 0) > 0;
|
|
161
|
+
const hasReference = Boolean(params.workflow?.trim() || params.file?.trim());
|
|
162
|
+
if (hasInline === hasReference) {
|
|
163
|
+
throw new Error(
|
|
164
|
+
"Provide exactly one graph source: inline nodes, or a saved workflow/file. No nodes were started.",
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
let plan: WorkflowPlanInput = {
|
|
169
|
+
...(params.name ? { name: params.name } : {}),
|
|
170
|
+
...(params.description ? { description: params.description } : {}),
|
|
171
|
+
nodes: params.nodes ?? [],
|
|
172
|
+
};
|
|
173
|
+
let fallbackName = params.name ?? "workflow";
|
|
174
|
+
if (hasReference) {
|
|
175
|
+
const resolved = resolveWorkflowDefinition(
|
|
176
|
+
ctx.cwd,
|
|
177
|
+
{ ...(params.workflow ? { name: params.workflow } : {}), ...(params.file ? { path: params.file } : {}) },
|
|
178
|
+
{ projectTrusted: ctx.isProjectTrusted?.() === true },
|
|
179
|
+
);
|
|
180
|
+
if (resolved.error || !resolved.definition) {
|
|
181
|
+
throw new Error((resolved.error ?? "workflow definition could not be read") + ". No nodes were started.");
|
|
182
|
+
}
|
|
183
|
+
const definition = resolved.definition;
|
|
184
|
+
plan = {
|
|
185
|
+
name: definition.plan.name ?? definition.name,
|
|
186
|
+
...(definition.plan.description ?? params.description
|
|
187
|
+
? { description: definition.plan.description ?? params.description }
|
|
188
|
+
: {}),
|
|
189
|
+
nodes: definition.plan.nodes,
|
|
190
|
+
};
|
|
191
|
+
fallbackName = definition.name;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
let workflow;
|
|
195
|
+
try {
|
|
196
|
+
workflow = compileWorkflow(plan, ctx.cwd, agents.map((agent) => agent.name), { fallbackName });
|
|
197
|
+
} catch (error) {
|
|
198
|
+
throw new Error(
|
|
199
|
+
"Workflow rejected before any node started:\n" + (error instanceof Error ? error.message : String(error)),
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Re-using a phase another owner holds fails the first node and blocks the
|
|
204
|
+
// rest; reject the whole graph instead, with the owners named.
|
|
205
|
+
const owned = findOwnedPhases(runtime, workflow);
|
|
206
|
+
if (owned.length > 0) {
|
|
207
|
+
const lines = owned.map((owner) =>
|
|
208
|
+
"- node \"" + owner.nodeId + "\" → phase \"" + owner.phaseId + "\" is already owned by run #" + owner.runId +
|
|
209
|
+
" (" + owner.agent + ", " + owner.state + ")",
|
|
210
|
+
);
|
|
211
|
+
throw new Error(
|
|
212
|
+
"Workflow \"" + workflow.name + "\" was not started: " + owned.length + " of " + workflow.nodes.length +
|
|
213
|
+
" node" + (owned.length === 1 ? " reuses" : "s reuse") + " a phase this session already owns.\n" +
|
|
214
|
+
lines.join("\n") +
|
|
215
|
+
"\nRetire the owner with subagent_stop({ id: <run id> }) (destructive: it drops that run's retained session), give those nodes different ids or phaseIds, or run the graph under a different name. No nodes were started.",
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const handle = startWorkflow(
|
|
220
|
+
{
|
|
221
|
+
runtime,
|
|
222
|
+
startBackground: core.startBackground,
|
|
223
|
+
resolveIsolation: (agentName) => {
|
|
224
|
+
const agent = agents.find((candidate) => candidate.name === agentName);
|
|
225
|
+
return defaultIsolationMode(
|
|
226
|
+
"parallel",
|
|
227
|
+
agentName,
|
|
228
|
+
undefined,
|
|
229
|
+
agent ? isWriteCapableAgent(agent, toolInfos) : undefined,
|
|
230
|
+
);
|
|
231
|
+
},
|
|
232
|
+
resultsRoot: projectResultsRoot(runtime.configPath, ctx.cwd),
|
|
233
|
+
notify: (message, kind) => ctx.ui.notify(message, kind),
|
|
234
|
+
},
|
|
235
|
+
workflow,
|
|
236
|
+
);
|
|
237
|
+
const status = workflowStatus(handle.run);
|
|
238
|
+
return {
|
|
239
|
+
content: [{ type: "text", text: launchReceipt(status) }],
|
|
240
|
+
details: {
|
|
241
|
+
workflow: status,
|
|
242
|
+
runIds: status.nodes.flatMap((node) => (node.runId === undefined ? [] : [node.runId])),
|
|
243
|
+
} satisfies WorkflowToolDetails,
|
|
244
|
+
};
|
|
245
|
+
},
|
|
246
|
+
|
|
247
|
+
renderCall(args, theme) {
|
|
248
|
+
const count = args.nodes?.length ?? 0;
|
|
249
|
+
const label = args.name ?? args.workflow ?? args.file ?? "inline";
|
|
250
|
+
const graph = count > 0 ? " " + count + " nodes" : "";
|
|
251
|
+
return new Text(
|
|
252
|
+
theme.fg("toolTitle", theme.bold("subagent_workflow ")) + theme.fg("accent", label) + theme.fg("dim", graph),
|
|
253
|
+
0,
|
|
254
|
+
0,
|
|
255
|
+
);
|
|
256
|
+
},
|
|
257
|
+
|
|
258
|
+
renderResult(result, options, theme) {
|
|
259
|
+
const details = result.details as WorkflowToolDetails | undefined;
|
|
260
|
+
if (!details?.workflow) return new Text(theme.fg("dim", "(no output)"), 0, 0);
|
|
261
|
+
const status = details.workflow;
|
|
262
|
+
const lines = formatWorkflowStatusLines(status, theme, options.expanded ? status.nodes.length : 6);
|
|
263
|
+
return new Text(lines.join("\n"), 0, 0);
|
|
264
|
+
},
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/** Session start: drop stale graph records and tell the user what the previous
|
|
269
|
+
* session left unfinished. */
|
|
270
|
+
export async function restoreWorkflowState(runtime: SubagentRuntime, ctx: ExtensionContext): Promise<void> {
|
|
271
|
+
await pruneWorkflowRecords(runtime.configPath).catch(() => undefined);
|
|
272
|
+
const retained = await readRetainedWorkflows(runtime, ctx.cwd).catch(() => []);
|
|
273
|
+
if (retained.length === 0) return;
|
|
274
|
+
const summary = retained
|
|
275
|
+
.slice(0, 3)
|
|
276
|
+
.map((record) => {
|
|
277
|
+
const done = record.nodes.filter((node) => node.state === "completed").length;
|
|
278
|
+
return "#" + record.id + " " + record.name + " (" + done + "/" + record.nodes.length + " nodes completed)";
|
|
279
|
+
})
|
|
280
|
+
.join("; ");
|
|
281
|
+
ctx.ui.notify(
|
|
282
|
+
"pi-subagents: " + retained.length + " unfinished workflow" + (retained.length === 1 ? "" : "s") +
|
|
283
|
+
" retained — " + summary + ". Inspect with subagent_status; main finishes the work.",
|
|
284
|
+
"info",
|
|
285
|
+
);
|
|
286
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: code-review
|
|
3
|
+
description: Review a change with independent eyes, confirm each finding, and report what was verified.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Code review workflow
|
|
7
|
+
|
|
8
|
+
Two reviewers read the same change from different angles, a third agent then
|
|
9
|
+
tries to *disprove* every finding against the code, and the last node writes the
|
|
10
|
+
report the user keeps.
|
|
11
|
+
|
|
12
|
+
Copy this file to `.pi/workflows/code-review.md` in the repository you are
|
|
13
|
+
reviewing. Two things are yours to set before you run it:
|
|
14
|
+
|
|
15
|
+
- Replace the review target in the `map` brief with the branch, commit range, or
|
|
16
|
+
paths actually under review.
|
|
17
|
+
- Nothing else needs to change to start; the reviewers inherit the target from
|
|
18
|
+
`{{map}}`.
|
|
19
|
+
|
|
20
|
+
Run it with `subagent_workflow({ "workflow": "code-review" })`, or by path with
|
|
21
|
+
`file: ".pi/workflows/code-review.md"`.
|
|
22
|
+
|
|
23
|
+
```json
|
|
24
|
+
{
|
|
25
|
+
"nodes": [
|
|
26
|
+
{
|
|
27
|
+
"id": "map",
|
|
28
|
+
"agent": "scout",
|
|
29
|
+
"task": "Establish what changed and where it matters for a review of the working tree against HEAD. Report: the changed files, what each change is trying to do, the call sites and tests that depend on them, and the checks the repository defines (package.json scripts, CI config, README verification line). Cite path:line for everything. Do not review quality yet."
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"id": "correctness",
|
|
33
|
+
"agent": "artisan",
|
|
34
|
+
"task": "You are the correctness reviewer. Using this map:\n\n{{map}}\n\nRead the changed code yourself and report what is wrong: logic errors, unhandled cases, broken invariants, missing tests that would catch a real failure. For each finding give path:line, what breaks, and the concrete input or state that breaks it. Do not edit any file. Do not report style preferences.",
|
|
35
|
+
"dependsOn": ["map"]
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"id": "risk",
|
|
39
|
+
"agent": "artisan",
|
|
40
|
+
"task": "You are the risk reviewer, with a different lens from the correctness reviewer. Using this map:\n\n{{map}}\n\nLook for what this change breaks outside its own diff: migrations and backward compatibility, concurrency and ordering, error paths, resource lifetime, security and data loss, and behaviour other modules rely on. Give path:line for each risk and say how likely it is to bite. Do not edit any file.",
|
|
41
|
+
"dependsOn": ["map"]
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"id": "confirm",
|
|
45
|
+
"agent": "scout",
|
|
46
|
+
"task": "Two reviewers reported findings. Your job is to try to disprove them, not to agree.\n\nCorrectness findings:\n{{correctness}}\n\nRisk findings:\n{{risk}}\n\nFor each finding, read the cited code and decide: reproduced (state the evidence), wrong (say what the code actually does), or unverified (say what you could not check and why). Keep a finding only when the code supports it.",
|
|
47
|
+
"dependsOn": ["correctness", "risk"]
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"id": "report",
|
|
51
|
+
"agent": "artisan",
|
|
52
|
+
"task": "Write the review the user acts on, from the confirmed findings only:\n\n{{confirm}}\n\nStructure it as: a two-sentence verdict, then each confirmed finding as where / what / evidence / severity, then what was checked and how, then what the review did not cover. Say plainly which findings were confirmed and which stayed unverified. Do not edit code; this node produces the report only.",
|
|
53
|
+
"dependsOn": ["confirm"]
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
```
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: migration
|
|
3
|
+
description: Map a migration, plan it, change disjoint slices in parallel, then run the project gate.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Migration workflow
|
|
7
|
+
|
|
8
|
+
One node finds the ground truth, one plans, two independent slices are changed
|
|
9
|
+
at the same time, and one gate decides whether the migration is done.
|
|
10
|
+
|
|
11
|
+
The two `apply` nodes run concurrently, so they must touch disjoint paths:
|
|
12
|
+
replace the example `scope.paths` with the directories each slice owns. The
|
|
13
|
+
compile step rejects the graph if those scopes overlap without a dependency
|
|
14
|
+
between them.
|
|
15
|
+
|
|
16
|
+
```json
|
|
17
|
+
{
|
|
18
|
+
"nodes": [
|
|
19
|
+
{
|
|
20
|
+
"id": "map",
|
|
21
|
+
"agent": "scout",
|
|
22
|
+
"task": "Map the migration to <TARGET>: every module that must change, where the old API is used, the tests that cover it, and the project's verification commands. Cite path:line. Do not change anything."
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"id": "plan",
|
|
26
|
+
"agent": "artisan",
|
|
27
|
+
"task": "Plan the migration in slices that two agents can do concurrently without touching each other's files, in dependency order. For each slice: the paths it owns, the exact change, and the check that proves it.\n\n{{map}}",
|
|
28
|
+
"dependsOn": ["map"]
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"id": "apply-core",
|
|
32
|
+
"agent": "artisan",
|
|
33
|
+
"task": "Implement the core slice of this plan and nothing outside the paths you own. Run the checks that slice needs.\n\n{{plan}}",
|
|
34
|
+
"dependsOn": ["plan"],
|
|
35
|
+
"scope": { "paths": ["src/core"] }
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"id": "apply-adapters",
|
|
39
|
+
"agent": "artisan",
|
|
40
|
+
"task": "Implement the adapter slice of this plan and nothing outside the paths you own. Run the checks that slice needs.\n\n{{plan}}",
|
|
41
|
+
"dependsOn": ["plan"],
|
|
42
|
+
"scope": { "paths": ["src/adapters"] }
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"id": "gate",
|
|
46
|
+
"agent": "artisan",
|
|
47
|
+
"task": "Run the repository's own verification: install if needed, then the full test suite, typecheck, and build the project defines. Fix only what the migration broke, in the smallest correct way. Report each command with its result, and say plainly if something is still failing.\n\nCore slice:\n{{apply-core}}\n\nAdapter slice:\n{{apply-adapters}}",
|
|
48
|
+
"dependsOn": ["apply-core", "apply-adapters"]
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
```
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: research
|
|
3
|
+
description: Research a question from independent angles, synthesise the answer, then verify its factual claims.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Research workflow
|
|
7
|
+
|
|
8
|
+
Three researchers take different angles, a synthesis node turns them into one
|
|
9
|
+
answer, and a verification node checks the claims that would embarrass you if
|
|
10
|
+
they were wrong.
|
|
11
|
+
|
|
12
|
+
Set your question in the three researcher briefs (they run concurrently), then
|
|
13
|
+
run `subagent_workflow({ "workflow": "research" })`.
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
{
|
|
17
|
+
"nodes": [
|
|
18
|
+
{
|
|
19
|
+
"id": "primary",
|
|
20
|
+
"agent": "scout",
|
|
21
|
+
"task": "Research <QUESTION> from first-party sources only: official documentation, specifications, release notes, and the project's own repository. Record versions and dates. Cite every fact you state. Mark anything you could only find second-hand."
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"id": "practice",
|
|
25
|
+
"agent": "scout",
|
|
26
|
+
"task": "Research <QUESTION> from practice: issue threads, migration notes, benchmarks, and post-mortems that describe what actually happened when people used it. Separate reported experience from vendor claims and cite each source."
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"id": "codebase",
|
|
30
|
+
"agent": "scout",
|
|
31
|
+
"task": "Establish what this repository already does about <QUESTION>: the relevant modules, configuration, and tests, with path:line citations. State where the code disagrees with the documentation if you find such a place."
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"id": "synthesis",
|
|
35
|
+
"agent": "artisan",
|
|
36
|
+
"task": "Answer <QUESTION> from these three research passes. Reconcile disagreements explicitly instead of averaging them, and prefer first-party evidence over practice reports when they conflict.\n\nFirst-party:\n{{primary}}\n\nPractice:\n{{practice}}\n\nThis repository:\n{{codebase}}\n\nWrite: the answer, the evidence behind it, the open questions, and what would change the answer.",
|
|
37
|
+
"dependsOn": ["primary", "practice", "codebase"]
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"id": "verify",
|
|
41
|
+
"agent": "scout",
|
|
42
|
+
"task": "Check the decisive factual claims in this answer against their sources. Report only claims you could not confirm or that are stale, with what you found instead.\n\n{{synthesis}}",
|
|
43
|
+
"dependsOn": ["synthesis"]
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
```
|