@ferris1225/pi-subagents 5.0.4 → 5.0.5
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 +28 -0
- package/README.md +67 -29
- package/index.ts +3 -1
- package/package.json +1 -1
- package/skills/workflow/SKILL.md +30 -22
- package/src/configuration/config.ts +14 -10
- package/src/configuration/models.ts +3 -8
- package/src/configuration/role-migration.ts +50 -0
- package/src/configuration/ui.ts +6 -10
- package/src/delegation/builtin-agents.ts +32 -16
- package/src/delegation/dispatch.ts +16 -18
- package/src/delegation/ownership.ts +98 -0
- package/src/delegation/prompt.ts +30 -18
- package/src/execution/cli-run.ts +1 -0
- package/src/execution/run-control.ts +2 -0
- package/src/isolation/worktree.ts +23 -6
- package/src/lifecycle/durable.ts +6 -1
- package/src/lifecycle/runtime.ts +8 -10
- package/src/lifecycle/thread-lifecycle.ts +35 -15
- package/src/lifecycle/thread-shared.ts +3 -1
- package/src/lifecycle/tools.ts +13 -2
- package/src/presentation/format.ts +1 -0
- package/src/presentation/widget.ts +3 -3
- package/src/workflow/durable.ts +18 -5
- package/src/workflow/engine.ts +12 -0
- package/src/workflow/files.ts +44 -3
- package/src/workflow/tool.ts +12 -5
- package/workflows/code-review.md +19 -37
- package/workflows/migration.md +2 -3
package/src/lifecycle/tools.ts
CHANGED
|
@@ -87,7 +87,7 @@ export function registerLookupTools(pi: ExtensionAPI, runtime: SubagentRuntime,
|
|
|
87
87
|
pi.registerTool({
|
|
88
88
|
name: "subagent_status",
|
|
89
89
|
label: "Subagent Status",
|
|
90
|
-
description: "
|
|
90
|
+
description: "Inspect run or workflow ownership, progress, and failures. An exact run id also returns its retained result so completed work can be reused. Omit id to list runs. Results arrive automatically; do not poll.",
|
|
91
91
|
exposure: "model-only",
|
|
92
92
|
executionMode: "parallel",
|
|
93
93
|
annotations: {
|
|
@@ -134,6 +134,7 @@ export function registerLookupTools(pi: ExtensionAPI, runtime: SubagentRuntime,
|
|
|
134
134
|
resultFile: result?.resultFile,
|
|
135
135
|
sessionDir: thread.retired ? undefined : thread.sessionDir ?? result?.sessionDir,
|
|
136
136
|
isolation: thread.isolation,
|
|
137
|
+
isolationNote: result?.isolationNote,
|
|
137
138
|
integrationStatus: live?.integrationStatus ?? result?.integrationStatus ?? thread.worktree?.state,
|
|
138
139
|
integrationError: result?.integrationError,
|
|
139
140
|
integrationWorktreePath: result?.integrationWorktreePath ?? (state === "interrupted" ? thread.worktree?.worktreePath : undefined),
|
|
@@ -145,6 +146,9 @@ export function registerLookupTools(pi: ExtensionAPI, runtime: SubagentRuntime,
|
|
|
145
146
|
: runs.map((run) => {
|
|
146
147
|
const wait = run.waitReason ? ` — ${runWaitLabel({ status: "queued", waitReason: run.waitReason })}` : "";
|
|
147
148
|
const lines = [`#${run.id} ${run.agent} · ${run.state} · ${formatDuration(run.elapsedMs)}${wait}`, ` task: ${run.taskSummary}`];
|
|
149
|
+
if (run.phaseId) lines.push(` phase: ${run.phaseId}`);
|
|
150
|
+
if (run.scope) lines.push(` scope: ${JSON.stringify(run.scope)}`);
|
|
151
|
+
if (run.isolationNote) lines.push(` isolation: ${run.isolationNote}`);
|
|
148
152
|
// The trail is the progress answer: what the run has been doing,
|
|
149
153
|
// newest last. It replaces pointing the parent at child session
|
|
150
154
|
// files, which it cannot usefully read mid-run.
|
|
@@ -176,7 +180,14 @@ export function registerLookupTools(pi: ExtensionAPI, runtime: SubagentRuntime,
|
|
|
176
180
|
...workflowRuns.map((run) => formatWorkflowStatus(run).join("\n")),
|
|
177
181
|
...retainedWorkflows.map((record) => formatRetainedWorkflow(record).join("\n")),
|
|
178
182
|
] : [];
|
|
179
|
-
const
|
|
183
|
+
const selected = params.id === undefined ? undefined : runtime.threads.get(params.id);
|
|
184
|
+
const retainedResult = selected ? runtime.settledRuns.get(selected.id) ?? selected.lastResult : undefined;
|
|
185
|
+
const evidence = retainedResult && retainedResult.exitCode !== -1
|
|
186
|
+
? retainedResult.resultFile
|
|
187
|
+
? `Read the retained result: ${retainedResult.resultFile}`
|
|
188
|
+
: formatCompletionBlock(retainedResult, DEFAULT_MAX_RESULT_LINES, { resultRoot: projectResultsRoot(runtime.configPath, selected!.cwd) })
|
|
189
|
+
: "";
|
|
190
|
+
const sections = [text, ...workflowSections, evidence].filter((section) => section.trim().length > 0);
|
|
180
191
|
const unknownWorkflow = workflowId !== undefined && workflowRuns.length === 0 && retainedWorkflows.length === 0;
|
|
181
192
|
return {
|
|
182
193
|
content: [{
|
|
@@ -113,6 +113,7 @@ export function formatCompletionBlock(
|
|
|
113
113
|
if (result.integrationError) lines.push(`Integration error: ${result.integrationError}`);
|
|
114
114
|
lines.push("");
|
|
115
115
|
}
|
|
116
|
+
if (result.isolationNote) lines.push(`Isolation: ${result.isolationNote}`, "");
|
|
116
117
|
if (!truncated) lines.push(text);
|
|
117
118
|
// Failed-tool diagnostics ride along only when the run itself failed: they
|
|
118
119
|
// explain the failure, while on a successful run a transient failed call
|
|
@@ -91,7 +91,7 @@ function renderBoard(groups: TaskGroup[], theme: Theme, width: number, overview?
|
|
|
91
91
|
selected.add(row);
|
|
92
92
|
used += cost;
|
|
93
93
|
}
|
|
94
|
-
//
|
|
94
|
+
// Keep graph status visible even when no actionable node rows remain.
|
|
95
95
|
for (const group of sorted) {
|
|
96
96
|
if (!group.rows.length && group.header && used < capacity) { included.add(group); used++; }
|
|
97
97
|
}
|
|
@@ -120,7 +120,7 @@ function workflowGroup(graph: WorkflowRun, runs: readonly RunView[], theme: Them
|
|
|
120
120
|
const count = (state: WorkflowNodeRun["state"]) => graph.nodes.filter((node) => node.state === state).length;
|
|
121
121
|
const completed = count("completed");
|
|
122
122
|
const progress = completed + "/" + graph.nodes.length + " completed";
|
|
123
|
-
const color = graph.state === "failed" ? "error" :
|
|
123
|
+
const color = graph.state === "failed" ? "error" : "accent";
|
|
124
124
|
const name = theme.fg(color, theme.bold("Workflow #" + graph.id + " · " + graph.name));
|
|
125
125
|
const parts = [progress, ...(["failed", "blocked", "pending"] as const).filter((state) => count(state))
|
|
126
126
|
.map((state) => count(state) + " " + (state === "pending" ? "waiting" : state))];
|
|
@@ -150,7 +150,7 @@ export function formatSubagentWidgetLines(
|
|
|
150
150
|
): string[] {
|
|
151
151
|
if (width <= 0) return [];
|
|
152
152
|
const graphIds = new Set(workflows.map((graph) => graph.id));
|
|
153
|
-
const visibleWorkflows = workflows.filter((graph) => graph.state !== "stopped");
|
|
153
|
+
const visibleWorkflows = workflows.filter((graph) => graph.state !== "stopped" && graph.state !== "completed");
|
|
154
154
|
const standalone = runs.filter((run) => (!run.workflow || !graphIds.has(run.workflow.workflowId)) && (isRunActiveStatus(run.status) || run.status === "failed"));
|
|
155
155
|
const groups = visibleWorkflows.map((graph) => workflowGroup(graph, runs, theme, width, now));
|
|
156
156
|
if (standalone.length) {
|
package/src/workflow/durable.ts
CHANGED
|
@@ -20,6 +20,7 @@ import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
|
20
20
|
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
21
21
|
import { getProjectRoot, getSubagentsRoot } from "../execution/spawn.ts";
|
|
22
22
|
import { PARKED_RECORD_MAX_AGE_MS } from "../lifecycle/durable.ts";
|
|
23
|
+
import { migrateStoredRecordRoles } from "../configuration/role-migration.ts";
|
|
23
24
|
|
|
24
25
|
export const WORKFLOWS_MANIFEST_FILE_NAME = "pi-subagents-workflows.json";
|
|
25
26
|
const WORKFLOWS_MANIFEST_VERSION = 1;
|
|
@@ -111,19 +112,26 @@ function normalizeRecord(value: unknown): WorkflowRecord | undefined {
|
|
|
111
112
|
};
|
|
112
113
|
}
|
|
113
114
|
|
|
114
|
-
async function
|
|
115
|
+
async function readManifest(path: string): Promise<{ records: WorkflowRecord[]; rolesMigrated: boolean }> {
|
|
115
116
|
try {
|
|
116
117
|
const parsed = JSON.parse(await readFile(path, "utf8")) as { records?: unknown };
|
|
117
|
-
if (!Array.isArray(parsed.records)) return [];
|
|
118
|
-
|
|
118
|
+
if (!Array.isArray(parsed.records)) return { records: [], rolesMigrated: false };
|
|
119
|
+
let rolesMigrated = false;
|
|
120
|
+
for (const record of parsed.records) rolesMigrated = migrateStoredRecordRoles(record) || rolesMigrated;
|
|
121
|
+
const records = parsed.records.flatMap((record) => {
|
|
119
122
|
const normalized = normalizeRecord(record);
|
|
120
123
|
return normalized ? [normalized] : [];
|
|
121
124
|
});
|
|
125
|
+
return { records, rolesMigrated };
|
|
122
126
|
} catch {
|
|
123
|
-
return [];
|
|
127
|
+
return { records: [], rolesMigrated: false };
|
|
124
128
|
}
|
|
125
129
|
}
|
|
126
130
|
|
|
131
|
+
async function readManifestRecords(path: string): Promise<WorkflowRecord[]> {
|
|
132
|
+
return (await readManifest(path)).records;
|
|
133
|
+
}
|
|
134
|
+
|
|
127
135
|
async function writeManifest(path: string, records: readonly WorkflowRecord[]): Promise<void> {
|
|
128
136
|
if (records.length === 0) {
|
|
129
137
|
await rm(path, { force: true });
|
|
@@ -167,7 +175,12 @@ export async function removeWorkflowRecord(configPath: string, workflowId: numbe
|
|
|
167
175
|
/** Records for one checkout, newest first. */
|
|
168
176
|
export async function readWorkflowRecords(configPath: string, cwd: string): Promise<WorkflowRecord[]> {
|
|
169
177
|
const path = getWorkflowsManifestPath(configPath, cwd);
|
|
170
|
-
const
|
|
178
|
+
const migrated = await withFileMutationQueue(path, async () => {
|
|
179
|
+
const manifest = await readManifest(path);
|
|
180
|
+
if (manifest.rolesMigrated) await writeManifest(path, manifest.records);
|
|
181
|
+
return manifest.records;
|
|
182
|
+
});
|
|
183
|
+
const records = migrated.filter(
|
|
171
184
|
(record) => process.platform === "win32"
|
|
172
185
|
? record.cwd.toLowerCase() === resolve(cwd).toLowerCase()
|
|
173
186
|
: record.cwd === resolve(cwd),
|
package/src/workflow/engine.ts
CHANGED
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
type WorkflowRecord,
|
|
32
32
|
} from "./durable.ts";
|
|
33
33
|
import type { WorkflowNodeRun, WorkflowRun, WorkflowRunState } from "./state.ts";
|
|
34
|
+
import type { PhaseScope } from "../delegation/phase-scope.ts";
|
|
34
35
|
|
|
35
36
|
/** Lines of one node's answer inlined into the graph summary. The complete text
|
|
36
37
|
* of every node is always written to a single workflow artifact, so nothing is
|
|
@@ -147,6 +148,7 @@ async function dispatchNode(ctx: RunContext, node: WorkflowNodeRun): Promise<voi
|
|
|
147
148
|
started = await ctx.startBackground(node.agent, task, node.cwd, node.isolation ?? ctx.resolveIsolation(node.agent), {
|
|
148
149
|
phaseId: node.phaseId,
|
|
149
150
|
scope: node.scope,
|
|
151
|
+
automaticIsolation: node.isolation === undefined,
|
|
150
152
|
deliveryRoute: "background",
|
|
151
153
|
quiet: true,
|
|
152
154
|
workflow: { workflowId: run.id, name: run.name, nodeId: node.id },
|
|
@@ -619,6 +621,10 @@ export interface WorkflowStatusView {
|
|
|
619
621
|
id: string;
|
|
620
622
|
agent: string;
|
|
621
623
|
state: WorkflowNodeRun["state"];
|
|
624
|
+
task: string;
|
|
625
|
+
phaseId: string;
|
|
626
|
+
scope?: PhaseScope;
|
|
627
|
+
cwd: string;
|
|
622
628
|
runId?: number;
|
|
623
629
|
waitingFor?: string[];
|
|
624
630
|
error?: string;
|
|
@@ -643,6 +649,10 @@ export function workflowStatus(run: WorkflowRun): WorkflowStatusView {
|
|
|
643
649
|
id: node.id,
|
|
644
650
|
agent: node.agent,
|
|
645
651
|
state: node.state,
|
|
652
|
+
task: formatTaskSummary(node.task, 160, false),
|
|
653
|
+
phaseId: node.phaseId,
|
|
654
|
+
scope: node.scope,
|
|
655
|
+
cwd: node.cwd,
|
|
646
656
|
...(node.runId !== undefined ? { runId: node.runId } : {}),
|
|
647
657
|
...(node.state === "pending" && node.dependsOn.length > 0 ? { waitingFor: [...node.dependsOn] } : {}),
|
|
648
658
|
...(node.error ? { error: node.error } : {}),
|
|
@@ -669,6 +679,8 @@ export function formatWorkflowStatus(run: WorkflowRun): string[] {
|
|
|
669
679
|
if (node.activity) parts.push(node.activity);
|
|
670
680
|
if (node.error) parts.push(`error: ${formatTaskSummary(node.error, 200, false)}`);
|
|
671
681
|
lines.push(` - ${parts.join(" · ")}`);
|
|
682
|
+
lines.push(` phase: ${node.phaseId} · task: ${node.task}`);
|
|
683
|
+
if (node.scope) lines.push(` scope: ${JSON.stringify(node.scope)}`);
|
|
672
684
|
}
|
|
673
685
|
return lines;
|
|
674
686
|
}
|
package/src/workflow/files.ts
CHANGED
|
@@ -16,9 +16,11 @@
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
import { type Dirent, existsSync, readdirSync, readFileSync, statSync } from "node:fs";
|
|
19
|
+
import { chmod, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
19
20
|
import { basename, dirname, join, resolve } from "node:path";
|
|
20
21
|
import { fileURLToPath } from "node:url";
|
|
21
|
-
import { CONFIG_DIR_NAME, getAgentDir, parseFrontmatter } from "@earendil-works/pi-coding-agent";
|
|
22
|
+
import { CONFIG_DIR_NAME, getAgentDir, parseFrontmatter, withFileMutationQueue } from "@earendil-works/pi-coding-agent";
|
|
23
|
+
import { migrateStoredAgentName, migrateStoredWorkflowRoles } from "../configuration/role-migration.ts";
|
|
22
24
|
import type { WorkflowPlanInput } from "./plan.ts";
|
|
23
25
|
|
|
24
26
|
/** Which workflow directories discovery reads. Same precedence as the templates
|
|
@@ -74,9 +76,10 @@ function asPlan(value: unknown, fallbackName: string): WorkflowPlanInput | undef
|
|
|
74
76
|
};
|
|
75
77
|
}
|
|
76
78
|
|
|
79
|
+
const JSON_FENCE = /^[ \t]*```json[ \t]*\r?\n([\s\S]*?)^[ \t]*```/mu;
|
|
80
|
+
|
|
77
81
|
function fencedJson(body: string): string | undefined {
|
|
78
|
-
|
|
79
|
-
return match?.[1];
|
|
82
|
+
return JSON_FENCE.exec(body)?.[1];
|
|
80
83
|
}
|
|
81
84
|
|
|
82
85
|
/** Read one definition file. Returns an error string instead of throwing so a
|
|
@@ -123,6 +126,44 @@ export function readWorkflowFile(
|
|
|
123
126
|
};
|
|
124
127
|
}
|
|
125
128
|
|
|
129
|
+
/** Migrate an already trusted, selected saved definition on disk. Discovery
|
|
130
|
+
* stays read-only; inline input is never translated into a different role. */
|
|
131
|
+
export async function migrateWorkflowDefinition(definition: WorkflowDefinition): Promise<WorkflowDefinition> {
|
|
132
|
+
if (definition.source === "builtin" || !definition.plan.nodes.some((node) =>
|
|
133
|
+
typeof node?.agent === "string" && migrateStoredAgentName(node.agent.trim()) !== node.agent.trim(),
|
|
134
|
+
)) return definition;
|
|
135
|
+
|
|
136
|
+
return withFileMutationQueue(definition.filePath, async () => {
|
|
137
|
+
const content = await readFile(definition.filePath, "utf8");
|
|
138
|
+
const isJson = /\.json$/iu.test(definition.filePath);
|
|
139
|
+
// parseFrontmatter normalizes newlines and trims the body; retain the raw
|
|
140
|
+
// prefix here so migration changes only the JSON block.
|
|
141
|
+
const bodyOffset = /^\uFEFF?---[\s\S]*?\r?\n---[^\r\n]*(?:\r?\n|$)/u.exec(content)?.[0].length ?? 0;
|
|
142
|
+
const body = content.slice(bodyOffset);
|
|
143
|
+
const json = isJson ? content : fencedJson(body);
|
|
144
|
+
if (json === undefined) throw new Error(`Cannot migrate workflow ${definition.filePath}: missing JSON block.`);
|
|
145
|
+
const parsed: unknown = JSON.parse(json);
|
|
146
|
+
if (migrateStoredWorkflowRoles(parsed)) {
|
|
147
|
+
const newline = content.includes("\r\n") ? "\r\n" : "\n";
|
|
148
|
+
const serialized = JSON.stringify(parsed, null, 2).replace(/\n/gu, newline) + newline;
|
|
149
|
+
const nextBody = body.replace(JSON_FENCE, (block, source: string) => block.replace(source, () => serialized));
|
|
150
|
+
const next = isJson ? serialized : content.slice(0, bodyOffset) + nextBody;
|
|
151
|
+
const temporary = `${definition.filePath}.${process.pid}.${Date.now()}.tmp`;
|
|
152
|
+
try {
|
|
153
|
+
const { mode } = await stat(definition.filePath);
|
|
154
|
+
await writeFile(temporary, next, { encoding: "utf8", mode });
|
|
155
|
+
await chmod(temporary, mode);
|
|
156
|
+
await rename(temporary, definition.filePath);
|
|
157
|
+
} finally {
|
|
158
|
+
await rm(temporary, { force: true }).catch(() => undefined);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
const current = readWorkflowFile(definition.filePath, definition.source);
|
|
162
|
+
if (!current.definition) throw new Error(current.error ?? `Cannot read migrated workflow ${definition.filePath}.`);
|
|
163
|
+
return current.definition;
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
|
|
126
167
|
function loadDefinitionsFromDir(dir: string, source: WorkflowSource): WorkflowDefinition[] {
|
|
127
168
|
if (!existsSync(dir)) return [];
|
|
128
169
|
let entries: Dirent[];
|
package/src/workflow/tool.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { Text } from "@earendil-works/pi-tui";
|
|
|
12
12
|
import { Type } from "typebox";
|
|
13
13
|
import { isWriteCapableAgent, loadBuiltinAgents } from "../delegation/agents.ts";
|
|
14
14
|
import { defaultIsolationMode, IsolationSchema, PhaseIdSchema, ScopeSchema } from "../delegation/dispatch.ts";
|
|
15
|
+
import { findRuntimeWriterConflict } from "../delegation/ownership.ts";
|
|
15
16
|
import { loadConfig } from "../configuration/config.ts";
|
|
16
17
|
import type { SubagentRuntime } from "../lifecycle/runtime.ts";
|
|
17
18
|
import type { DispatchCore } from "../lifecycle/dispatch-core.ts";
|
|
@@ -26,7 +27,7 @@ import {
|
|
|
26
27
|
workflowStatus,
|
|
27
28
|
type WorkflowStatusView,
|
|
28
29
|
} from "./engine.ts";
|
|
29
|
-
import { resolveWorkflowDefinition } from "./files.ts";
|
|
30
|
+
import { migrateWorkflowDefinition, resolveWorkflowDefinition } from "./files.ts";
|
|
30
31
|
import { compileWorkflow, WORKFLOW_NODE_ID_MAX_LENGTH, type WorkflowPlanInput } from "./plan.ts";
|
|
31
32
|
|
|
32
33
|
const WorkflowNodeSchema = Type.Object({
|
|
@@ -94,7 +95,7 @@ function launchReceipt(status: WorkflowStatusView): string {
|
|
|
94
95
|
return parts.join(" · ");
|
|
95
96
|
}),
|
|
96
97
|
"",
|
|
97
|
-
"
|
|
98
|
+
"Every node is owned by this graph, including nodes waiting on dependencies. Do not perform or redispatch their work in main or another agent. The graph dispatches dependents automatically and sends one summary; continue only disjoint work or end your turn, and do not poll.",
|
|
98
99
|
];
|
|
99
100
|
return lines.join("\n");
|
|
100
101
|
}
|
|
@@ -134,7 +135,7 @@ export function registerWorkflowTool(pi: ExtensionAPI, runtime: SubagentRuntime,
|
|
|
134
135
|
name: "subagent_workflow",
|
|
135
136
|
label: "Subagent Workflow",
|
|
136
137
|
description:
|
|
137
|
-
"Run a dependency graph
|
|
138
|
+
"Run a fixed dependency graph for substantial phases with known scopes. dependsOn starts a node after prerequisites finish and integrate. Pending nodes already own their work; main must not execute or redispatch it. Duplicate phases and external writer conflicts reject the graph before any child starts. Independent work without dependency edges uses subagent tasks. If a result must decide the next phase, dispatch it alone and decide in main. Omit isolation for automatic selection. One summary arrives after settlement; main checks outcomes, integrates, and releases.",
|
|
138
139
|
exposure: "model-only",
|
|
139
140
|
executionMode: "parallel",
|
|
140
141
|
annotations: {
|
|
@@ -178,7 +179,7 @@ export function registerWorkflowTool(pi: ExtensionAPI, runtime: SubagentRuntime,
|
|
|
178
179
|
if (resolved.error || !resolved.definition) {
|
|
179
180
|
throw new Error((resolved.error ?? "workflow definition could not be read") + ". No nodes were started.");
|
|
180
181
|
}
|
|
181
|
-
const definition = resolved.definition;
|
|
182
|
+
const definition = await migrateWorkflowDefinition(resolved.definition);
|
|
182
183
|
plan = {
|
|
183
184
|
name: params.name ?? definition.plan.name ?? definition.name,
|
|
184
185
|
...(params.description ?? definition.description
|
|
@@ -224,6 +225,13 @@ export function registerWorkflowTool(pi: ExtensionAPI, runtime: SubagentRuntime,
|
|
|
224
225
|
);
|
|
225
226
|
}
|
|
226
227
|
|
|
228
|
+
for (const node of workflow.nodes) {
|
|
229
|
+
const agent = agents.find((candidate) => candidate.name === node.agent)!;
|
|
230
|
+
if (!node.scope || !isWriteCapableAgent(agent, toolInfos)) continue;
|
|
231
|
+
const conflict = findRuntimeWriterConflict(runtime, node.scope);
|
|
232
|
+
if (conflict) throw new Error(`Workflow node "${node.id}" scope ${conflict.overlap.left} overlaps ${conflict.owner} scope ${conflict.overlap.right}. No nodes were started.`);
|
|
233
|
+
}
|
|
234
|
+
|
|
227
235
|
const handle = startWorkflow(
|
|
228
236
|
{
|
|
229
237
|
runtime,
|
|
@@ -231,7 +239,6 @@ export function registerWorkflowTool(pi: ExtensionAPI, runtime: SubagentRuntime,
|
|
|
231
239
|
resolveIsolation: (agentName) => {
|
|
232
240
|
const agent = agents.find((candidate) => candidate.name === agentName);
|
|
233
241
|
return defaultIsolationMode(
|
|
234
|
-
"parallel",
|
|
235
242
|
agentName,
|
|
236
243
|
undefined,
|
|
237
244
|
agent ? isWriteCapableAgent(agent, toolInfos) : undefined,
|
package/workflows/code-review.md
CHANGED
|
@@ -1,55 +1,37 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: code-review
|
|
3
|
-
description:
|
|
3
|
+
description: Inspect an implementation, then challenge only the reported findings.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Code review workflow
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
Use one `sentinel` run for an ordinary review. This two-node template is for a
|
|
9
|
+
substantial change where independent verification of findings earns another
|
|
10
|
+
session. The sentinel inspects the implementation; the skeptic checks its named
|
|
11
|
+
claims and returns the final review. They do not perform two general reviews.
|
|
12
12
|
|
|
13
|
-
Copy this file to `.pi/workflows/code-review.md`
|
|
14
|
-
|
|
13
|
+
Copy this file to `.pi/workflows/code-review.md` and replace `<TARGET>` with the
|
|
14
|
+
branch, commit range, or paths under review. Include any existing main research
|
|
15
|
+
and checks in the review brief so the sentinel can reuse them. If the first
|
|
16
|
+
result must decide whether a second phase is needed, dispatch only the sentinel
|
|
17
|
+
and make that decision in main.
|
|
15
18
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
- Nothing else needs to change to start; the reviewers inherit the target from
|
|
19
|
-
`{{map}}`.
|
|
20
|
-
|
|
21
|
-
Run it with `subagent_workflow({ "workflow": "code-review" })`, or by path with
|
|
22
|
-
`file: ".pi/workflows/code-review.md"`.
|
|
19
|
+
Run with `subagent_workflow({ workflow: "code-review" })`, or use an explicit
|
|
20
|
+
`file` path. Omit isolation overrides for these read-only reviews.
|
|
23
21
|
|
|
24
22
|
```json
|
|
25
23
|
{
|
|
26
24
|
"nodes": [
|
|
27
25
|
{
|
|
28
|
-
"id": "
|
|
29
|
-
"agent": "
|
|
30
|
-
"
|
|
31
|
-
"task": "Read git diff and git status to establish what changed for a review of the working tree against HEAD, including staged and untracked changes. Stay read-only; do not edit files, install dependencies, or change Git state. 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."
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
"id": "correctness",
|
|
35
|
-
"agent": "reviewer",
|
|
36
|
-
"isolation": "shared",
|
|
37
|
-
"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, the concrete input or state that breaks it, and the smallest change that fixes it. Do not edit any file. Do not report style preferences.",
|
|
38
|
-
"dependsOn": ["map"]
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
"id": "risk",
|
|
42
|
-
"agent": "reviewer",
|
|
43
|
-
"isolation": "shared",
|
|
44
|
-
"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.",
|
|
45
|
-
"dependsOn": ["map"]
|
|
26
|
+
"id": "review",
|
|
27
|
+
"agent": "sentinel",
|
|
28
|
+
"task": "Review <TARGET> against the stated requirements and relevant callers. Establish the diff once, then inspect correctness, regressions, compatibility, and concrete failure paths within that target. Reuse existing research and valid checks; run a focused reproduction only to resolve a suspected defect. Stay read-only and do not change Git state. Return confirmed actionable findings with path:line, trigger, consequence, evidence, and smallest fix; include checks and material gaps. State clearly if no confirmed findings were found."
|
|
46
29
|
},
|
|
47
30
|
{
|
|
48
|
-
"id": "
|
|
49
|
-
"agent": "
|
|
50
|
-
"
|
|
51
|
-
"task": "
|
|
52
|
-
"dependsOn": ["correctness", "risk"]
|
|
31
|
+
"id": "verify",
|
|
32
|
+
"agent": "skeptic",
|
|
33
|
+
"dependsOn": ["review"],
|
|
34
|
+
"task": "Test only the specific defect claims reported here:\n\n{{review}}\n\nTry to disprove each claim against its callers, invariants, or focused checks. Reuse valid evidence; do not repeat the general review. If there are no defect claims, report that and stop. Stay read-only and do not change Git state. Return the final review: surviving confirmed findings ordered by severity with trigger, consequence, evidence, and smallest fix; briefly state refuted or unresolved claims, checks, and remaining limits."
|
|
53
35
|
}
|
|
54
36
|
]
|
|
55
37
|
}
|
package/workflows/migration.md
CHANGED
|
@@ -12,8 +12,8 @@ Replace <TARGET>, <CONTRACT> (the shared interface contract or its file path),
|
|
|
12
12
|
both slice briefs, and every example scope before running. Each child needs the
|
|
13
13
|
contract in its own brief because it cannot see main's conversation.
|
|
14
14
|
Each slice owns its implementation and regression tests. Keep coupled changes
|
|
15
|
-
with one owner.
|
|
16
|
-
|
|
15
|
+
with one owner. Use sentinel for a separate implementation review or skeptic
|
|
16
|
+
for a named assumption the gate cannot test; main owns final integration and release.
|
|
17
17
|
|
|
18
18
|
```json
|
|
19
19
|
{
|
|
@@ -33,7 +33,6 @@ cover; main still owns final integration and release.
|
|
|
33
33
|
{
|
|
34
34
|
"id": "gate",
|
|
35
35
|
"agent": "artisan",
|
|
36
|
-
"isolation": "shared",
|
|
37
36
|
"task": "Challenge the integrated migration using the project's documented required checks. Interface contract: <CONTRACT>. Verify both slices meet their done conditions before proceeding; report missing prerequisites instead of guessing. Run the required commands; inspect cross-slice call sites for mismatches. Fix failures caused by this migration within its authorized scope. Report commands, results, and unverified risks.\n\nCore:\n{{apply-core}}\n\nAdapters:\n{{apply-adapters}}",
|
|
38
37
|
"dependsOn": ["apply-core", "apply-adapters"],
|
|
39
38
|
"scope": { "paths": ["src/core", "test/core", "src/adapters", "test/adapters"] }
|