From bd89dcaff695a6f56dc86263675247bcbad7e2c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E6=A9=98?= Date: Tue, 28 Apr 2026 13:33:14 +0000 Subject: [PATCH] chore(workflow): auto-generated commit --- workflows/workflow-generator/build.ts | 2 ++ workflows/workflow-generator/moderator.ts | 9 ++++++- .../workflow-generator/roles/coder/prompt.ts | 4 +-- .../roles/planner/prompt.ts | 2 +- .../roles/reviewer/index.ts | 23 +++++++++++++++++ .../roles/reviewer/prompt.ts | 25 +++++++++++++++++++ 6 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 workflows/workflow-generator/roles/reviewer/index.ts create mode 100644 workflows/workflow-generator/roles/reviewer/prompt.ts diff --git a/workflows/workflow-generator/build.ts b/workflows/workflow-generator/build.ts index b96b6c1..320db26 100644 --- a/workflows/workflow-generator/build.ts +++ b/workflows/workflow-generator/build.ts @@ -3,6 +3,7 @@ import type { WorkflowDefinition } from "@uncaged/nerve-core"; import type { LlmProvider } from "@uncaged/nerve-workflow-utils"; import { buildPlannerRole } from "./roles/planner/index.js"; import { buildCoderRole } from "./roles/coder/index.js"; +import { buildReviewerRole } from "./roles/reviewer/index.js"; import { buildTesterRole } from "./roles/tester/index.js"; import { buildCommitterRole } from "./roles/committer/index.js"; import { moderator } from "./moderator.js"; @@ -22,6 +23,7 @@ export function buildWorkflowGenerator({ roles: { planner: buildPlannerRole({ provider, cwd: nerveRoot }), coder: buildCoderRole({ provider, cwd: nerveRoot }), + reviewer: buildReviewerRole({ provider, cwd: nerveRoot }), tester: buildTesterRole({ provider, nerveRoot }), committer: buildCommitterRole({ nerveRoot }), }, diff --git a/workflows/workflow-generator/moderator.ts b/workflows/workflow-generator/moderator.ts index 2f437a4..ee30801 100644 --- a/workflows/workflow-generator/moderator.ts +++ b/workflows/workflow-generator/moderator.ts @@ -2,12 +2,14 @@ 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 { ReviewerMeta } from "./roles/reviewer/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; + reviewer: ReviewerMeta; tester: TesterMeta; committer: CommitterMeta; }; @@ -25,7 +27,12 @@ export const moderator: Moderator = (context) => { } if (last.role === "coder") { - if (last.meta.done) return "tester"; + if (last.meta.done) return "reviewer"; + return coderCount < MAX_CODER_ITERATIONS ? "coder" : END; + } + + if (last.role === "reviewer") { + if (last.meta.approved) return "tester"; return coderCount < MAX_CODER_ITERATIONS ? "coder" : END; } diff --git a/workflows/workflow-generator/roles/coder/prompt.ts b/workflows/workflow-generator/roles/coder/prompt.ts index 84e65f1..527abf1 100644 --- a/workflows/workflow-generator/roles/coder/prompt.ts +++ b/workflows/workflow-generator/roles/coder/prompt.ts @@ -1,11 +1,11 @@ export function coderPrompt({ threadId }: { threadId: string }): string { - return `Read the workflow thread to get the planner's design and any tester/committer feedback: \`nerve thread ${threadId}\` + return `Read the workflow thread to get the planner's design and any reviewer/tester/committer feedback: \`nerve thread ${threadId}\` Read the nerve-dev skill for workflow file structure and conventions: \`cat node_modules/@uncaged/nerve-skills/nerve-dev/SKILL.md\` Also look at existing workflows in the \`workflows/\` directory for patterns. ## Your task -Implement the planner's design. This may be **creating a new workflow** or **modifying an existing one**. If there is tester or committer feedback in the thread, fix the issues they identified. +Implement the planner's design. This may be **creating a new workflow** or **modifying an existing one**. If there is reviewer, tester, or committer feedback in the thread, fix the issues they identified. ## Multi-step approach diff --git a/workflows/workflow-generator/roles/planner/prompt.ts b/workflows/workflow-generator/roles/planner/prompt.ts index 4cf4de0..13c6480 100644 --- a/workflows/workflow-generator/roles/planner/prompt.ts +++ b/workflows/workflow-generator/roles/planner/prompt.ts @@ -24,7 +24,7 @@ For **modifications to existing workflows**: - Workflow name (existing) - What changes are needed and why - Files to add/modify/delete -- Impact on moderator routing logic +- Impact on moderator routing logic (this workflow's typical order is planner → coder → reviewer → tester → committer) - Backward compatibility considerations (if any) If requirements are NOT clear, describe what is missing or ambiguous. diff --git a/workflows/workflow-generator/roles/reviewer/index.ts b/workflows/workflow-generator/roles/reviewer/index.ts new file mode 100644 index 0000000..e6fee58 --- /dev/null +++ b/workflows/workflow-generator/roles/reviewer/index.ts @@ -0,0 +1,23 @@ +import type { LlmProvider } from "@uncaged/nerve-workflow-utils"; +import { createCursorRole } from "@uncaged/nerve-workflow-utils"; +import { reviewerPrompt } from "./prompt.js"; +import { z } from "zod"; + +export const reviewerMetaSchema = z.object({ + approved: z.boolean().describe("true if the workflow matches the plan and is ready for tester validation"), +}); +export type ReviewerMeta = z.infer; + +export type BuildReviewerDeps = { + provider: LlmProvider; + cwd: string; +}; + +export function buildReviewerRole({ provider, cwd }: BuildReviewerDeps) { + return createCursorRole({ + cwd, + mode: "ask", + prompt: async (threadId) => reviewerPrompt({ threadId }), + extract: { provider, schema: reviewerMetaSchema }, + }); +} diff --git a/workflows/workflow-generator/roles/reviewer/prompt.ts b/workflows/workflow-generator/roles/reviewer/prompt.ts new file mode 100644 index 0000000..cdfede4 --- /dev/null +++ b/workflows/workflow-generator/roles/reviewer/prompt.ts @@ -0,0 +1,25 @@ +export function reviewerPrompt({ threadId }: { threadId: string }): string { + return `You are a **reviewer** for Nerve workflow generation. You run **after** the coder and **before** the tester. + +Read the workflow thread for the planner's design and any prior feedback: \`nerve thread ${threadId}\` +Read workflow conventions: \`cat node_modules/@uncaged/nerve-skills/nerve-dev/SKILL.md\` (from the repo root after \`cd\`). + +## Your job + +1. Identify the target workflow name and paths from the thread (e.g. \`workflows//\`). +2. Read the relevant files: \`moderator.ts\`, \`build.ts\`, \`index.ts\`, and each role under \`roles/\`. +3. Check that the implementation matches the planner's plan (roles, routing, meta types, no forbidden patterns like dynamic \`import()\`). +4. Do **not** run full build/test here — that is the tester's job. Flag obvious gaps (missing files, wrong exports, broken routing). + +If the work is **ready for the tester** to validate builds and config, set \`approved: true\`. +If the coder must fix issues first, set \`approved: false\` and explain briefly what is wrong. + +End with a JSON block: +\`\`\`json +{ "approved": true } +\`\`\` +or +\`\`\`json +{ "approved": false } +\`\`\``; +}