小橘 a469f30b42 refactor(workflow-generator): multi-file DIP + Role Factory + esbuild bundle
- Split 500-line monolith into roles/{planner,coder,tester,committer}/
- Each role: index.ts (build function) + prompt.ts (pure function)
- Use createCursorRole/createLlmRole/createHermesRole factories
- DIP: env vars read in index.ts, injected via build.ts
- esbuild bundle to dist/index.js (24kb)
- Moderator logic preserved: planner→coder→tester→committer with retries

Fixes xiaoju/nerve-workspace#3
2026-04-28 08:48:23 +00:00

40 lines
905 B
TypeScript

export type CoderPromptParams = {
workflowsDir: string;
wfName: string;
planMarkdown: string;
plannerStructured: object;
feedback: string;
nerveRoot: string;
};
export function coderPrompt({
workflowsDir,
wfName,
planMarkdown,
plannerStructured,
feedback,
nerveRoot,
}: CoderPromptParams): string {
return `Implement a Nerve workflow package under ${workflowsDir}/${wfName}/.
Planner output:
${planMarkdown}
Structured planner fields:
${JSON.stringify(plannerStructured, null, 2)}
${feedback}
Required files:
1) ${workflowsDir}/${wfName}/index.ts
2) ${workflowsDir}/${wfName}/package.json
3) ${workflowsDir}/${wfName}/tsconfig.json
4) update ${nerveRoot}/nerve.yaml with workflows.${wfName}
Rules:
- keep WorkflowDefinition<WorkflowMeta> pattern
- no dynamic import()
- use types (not interfaces)
- include retry-aware moderator routing
- write compile-ready TypeScript`;
}