@afokapu/atdd-flow 0.3.11 → 0.3.13
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/seats.ts +17 -2
- package/src/tasks.ts +3 -1
package/package.json
CHANGED
package/src/seats.ts
CHANGED
|
@@ -162,6 +162,21 @@ export function resolveModelCommand(config: Desk, candidate: ModelCandidate) {
|
|
|
162
162
|
return { agent: resolveExecutable(config, candidate.executable), args: candidate.args ?? [] };
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
+
async function launchEligibleTasks(root: string, record: Seat) {
|
|
166
|
+
const tasks = await seatTasks(root, record.project, record.address);
|
|
167
|
+
const eligible = await Promise.all(tasks.map(async (entry) => {
|
|
168
|
+
if (entry.task.assignee !== record.address || entry.task.blocker) return undefined;
|
|
169
|
+
if (entry.task.status === "in_progress") return entry;
|
|
170
|
+
if (entry.task.status !== "todo") return undefined;
|
|
171
|
+
const dependencies = await Promise.all((entry.task.depends_on ?? []).map(async (id) => {
|
|
172
|
+
try { return (await readYaml<{ status?: string }>(paths(root).taskFile(record.project, id))).status === "done"; }
|
|
173
|
+
catch { return false; }
|
|
174
|
+
}));
|
|
175
|
+
return dependencies.every(Boolean) ? entry : undefined;
|
|
176
|
+
}));
|
|
177
|
+
return eligible.filter((entry): entry is NonNullable<typeof entry> => Boolean(entry));
|
|
178
|
+
}
|
|
179
|
+
|
|
165
180
|
async function chooseLaunchModel(root: string, config: Desk, record: Seat, portfolio: ModelPortfolio, select: (input: ModelSelectionInput) => Promise<ModelSelectionResponse> = selectModel) {
|
|
166
181
|
const candidates = availableModelCandidates(config, portfolio);
|
|
167
182
|
if (!candidates.length) throw new Error("No enabled model in models.yaml has an available executable.");
|
|
@@ -261,8 +276,8 @@ export async function launchPiRuntime(root: string, address: string, args: strin
|
|
|
261
276
|
const resume = args.includes("--resume");
|
|
262
277
|
const dryRun = args.includes("--dry-run");
|
|
263
278
|
if (args.some((argument) => !["--pane", pane, "--herdr-session", herdrSession, "--resume", "--dry-run"].includes(argument))) throw new Error("Use `pi runtime launch <seat> --pane <existing-pane> --herdr-session <session> [--resume] [--dry-run]`.");
|
|
264
|
-
const active =
|
|
265
|
-
if (!active.length) throw new Error(`${resolved} has no
|
|
279
|
+
const active = await launchEligibleTasks(root, record);
|
|
280
|
+
if (!active.length) throw new Error(`${resolved} has no launch-eligible task; refusing runtime launch.`);
|
|
266
281
|
const selection = await chooseLaunchModel(root, config, record, required(await modelPortfolio(root), "models.yaml for Pi runtime launch"), dependencies.select);
|
|
267
282
|
const model = resolveModelCommand(config, selection.candidate);
|
|
268
283
|
if (basename(model.agent) !== "pi") throw new Error(`Pi runtime launch requires a Pi candidate, received ${selection.candidate.id}.`);
|
package/src/tasks.ts
CHANGED
|
@@ -246,8 +246,10 @@ export async function unblock(root: string, projectName: string, id: string, arg
|
|
|
246
246
|
const task = await readTask(root, projectName, taskId(id));
|
|
247
247
|
const actor = await canonicalAddress(root, required(words(args, "--by"), "--by"));
|
|
248
248
|
if (actor !== task.coordinator) throw new Error(`Only ${task.coordinator} may unblock task ${id}.`);
|
|
249
|
-
if (task.status !== "in_progress") throw new Error(`Task ${id} can only be unblocked while in_progress.`);
|
|
249
|
+
if (task.status !== "todo" && task.status !== "in_progress") throw new Error(`Task ${id} can only be unblocked while todo or in_progress.`);
|
|
250
250
|
if (!task.blocker) throw new Error(`Task ${id} has no blocker to clear.`);
|
|
251
|
+
const waiting = await ready(root, projectName, task);
|
|
252
|
+
if (waiting.length) throw new Error(`Task ${id} is waiting on: ${waiting.join(", ")}.`);
|
|
251
253
|
const { assertDependentsMayUnblock } = await import("./ephemeral-resources");
|
|
252
254
|
await assertDependentsMayUnblock(root, { project: projectName, task: id });
|
|
253
255
|
delete task.blocker;
|