- 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
50 lines
942 B
TypeScript
50 lines
942 B
TypeScript
import type { LlmMessage } from "@uncaged/nerve-workflow-utils";
|
|
|
|
export type PlannerPromptParams = {
|
|
nerveAgentContext: string;
|
|
userPrompt: string;
|
|
nerveRoot: string;
|
|
workflowsDir: string;
|
|
senseGeneratorReference: string;
|
|
nerveYaml: string;
|
|
};
|
|
|
|
export function plannerPrompt({
|
|
nerveAgentContext,
|
|
userPrompt,
|
|
nerveRoot,
|
|
workflowsDir,
|
|
senseGeneratorReference,
|
|
nerveYaml,
|
|
}: PlannerPromptParams): LlmMessage[] {
|
|
const content = `Design a Nerve workflow plan from this request.
|
|
|
|
${nerveAgentContext}
|
|
|
|
User request:
|
|
${userPrompt}
|
|
|
|
Target root: ${nerveRoot}
|
|
Workflow dir root: ${workflowsDir}
|
|
|
|
Reference structure:
|
|
\`\`\`ts
|
|
${senseGeneratorReference.slice(0, 18_000)}
|
|
\`\`\`
|
|
|
|
Current nerve.yaml:
|
|
\`\`\`yaml
|
|
${nerveYaml}
|
|
\`\`\`
|
|
|
|
Produce a complete markdown plan that includes:
|
|
- workflow name
|
|
- roles list
|
|
- flow/transitions
|
|
- validation loops design
|
|
- external deps
|
|
- data flow`;
|
|
|
|
return [{ role: "user", content }];
|
|
}
|