- planner: { ready }, coder: { done }, tester: { passed }, committer: { success }
- planner/coder: createCursorRole, tester: createHermesRole
- committer: direct spawn, output to .log file
- moderator: coder loop (max 5), committer fail → coder
- bundle 24kb → 8.7kb
Fixes #5
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import { END } from "@uncaged/nerve-core";
|
|
import type { Moderator } from "@uncaged/nerve-core";
|
|
import type { PlannerMeta } from "./roles/planner/index.js";
|
|
import type { CoderMeta } from "./roles/coder/index.js";
|
|
import type { TesterMeta } from "./roles/tester/index.js";
|
|
import type { CommitterMeta } from "./roles/committer/index.js";
|
|
|
|
export type WorkflowMeta = {
|
|
planner: PlannerMeta;
|
|
coder: CoderMeta;
|
|
tester: TesterMeta;
|
|
committer: CommitterMeta;
|
|
};
|
|
|
|
const MAX_CODER_ITERATIONS = 5;
|
|
|
|
export const moderator: Moderator<WorkflowMeta> = (context) => {
|
|
if (context.steps.length === 0) return "planner";
|
|
|
|
const last = context.steps[context.steps.length - 1];
|
|
const coderCount = context.steps.filter((s) => s.role === "coder").length;
|
|
|
|
if (last.role === "planner") {
|
|
return last.meta.ready ? "coder" : END;
|
|
}
|
|
|
|
if (last.role === "coder") {
|
|
if (last.meta.done) return "tester";
|
|
return coderCount < MAX_CODER_ITERATIONS ? "coder" : END;
|
|
}
|
|
|
|
if (last.role === "tester") {
|
|
if (last.meta.passed) return "committer";
|
|
return coderCount < MAX_CODER_ITERATIONS ? "coder" : END;
|
|
}
|
|
|
|
if (last.role === "committer") {
|
|
if (last.meta.success) return END;
|
|
return coderCount < MAX_CODER_ITERATIONS ? "coder" : END;
|
|
}
|
|
|
|
return END;
|
|
};
|