From 6778ba5246731fb8392f1dc999300ee5e7d64959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E6=A9=98?= Date: Tue, 28 Apr 2026 11:02:25 +0000 Subject: [PATCH] refactor: clarify coder done semantics + allow multi-step iterations - done=true means all files created, build+lint pass - done=false means progress made, continue next iteration - Updated both sense-generator and workflow-generator coder prompts --- .../sense-generator/roles/coder/prompt.ts | 56 ++++++++----------- .../workflow-generator/roles/coder/prompt.ts | 45 +++++++++------ 2 files changed, 49 insertions(+), 52 deletions(-) diff --git a/workflows/sense-generator/roles/coder/prompt.ts b/workflows/sense-generator/roles/coder/prompt.ts index 33b3b2d..aa33cec 100644 --- a/workflows/sense-generator/roles/coder/prompt.ts +++ b/workflows/sense-generator/roles/coder/prompt.ts @@ -1,43 +1,31 @@ export function coderPrompt({ threadId }: { threadId: string }): string { - return `Read the workflow thread for the planner's sense design: \`nerve thread ${threadId}\` + return `Read the workflow thread for the planner's sense design and any tester feedback: \`nerve thread ${threadId}\` Read the nerve-dev skill for sense file structure and conventions: \`cat node_modules/@uncaged/nerve-skills/nerve-dev/SKILL.md\` -Implement the sense following the patterns from existing senses and the skill guide. +## Your task -File structure for each sense: -- \`senses//src/index.ts\` — TypeScript source with proper types; import schema as \`./schema.ts\` +Implement (or fix) the sense the planner designed. If there is tester feedback in the thread, fix the issues it identified. + +## Multi-step approach + +You do NOT need to finish everything in one pass. You may return \`done: false\` to continue in the next iteration. + +## File structure for each sense + +- \`senses//src/index.ts\` — TypeScript compute source; import schema as \`./schema.ts\` - \`senses//src/schema.ts\` — Drizzle schema (TypeScript) - \`senses//migrations/\` — Drizzle migration files (at sense root, not inside src/) -- \`senses//package.json\` — with esbuild build script (see below) +- \`senses//package.json\` — with esbuild build script - \`senses//index.js\` — bundled output generated by \`pnpm build\` (do NOT edit by hand) -package.json template for each sense: -\`\`\`json -{ - "name": "sense-", - "version": "0.0.1", - "private": true, - "type": "module", - "scripts": { - "build": "esbuild src/index.ts --bundle --platform=node --format=esm --outfile=index.js --packages=external" - }, - "devDependencies": { - "@types/node": "^22.0.0", - "esbuild": "^0.27.0", - "typescript": "^5.7.0" - }, - "pnpm": { - "onlyBuiltDependencies": ["esbuild"] - } -} -\`\`\` - -After creating all files, run inside the sense directory: -\`\`\` -pnpm install --no-cache && pnpm build -\`\`\` - -This generates the bundled \`index.js\` at the sense root that the daemon loads. - -Then update nerve.yaml and run any required migrations.`; +Look at existing senses for the package.json template and patterns. + +## When to return done: true + +Return \`done: true\` ONLY when ALL of the following are true: +- All required files are created +- \`pnpm install --no-cache && pnpm build\` succeeds (run it!) +- \`nerve.yaml\` is updated with the sense config + +Return \`done: false\` if you made progress but there is still work to do.`; } diff --git a/workflows/workflow-generator/roles/coder/prompt.ts b/workflows/workflow-generator/roles/coder/prompt.ts index 8cba488..643b155 100644 --- a/workflows/workflow-generator/roles/coder/prompt.ts +++ b/workflows/workflow-generator/roles/coder/prompt.ts @@ -1,35 +1,44 @@ export function coderPrompt({ threadId }: { threadId: string }): string { - return `Read the workflow thread to get the planner's design and any tester feedback: \`nerve thread ${threadId}\` + return `Read the workflow thread to get the planner's design and any 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. -Implement the workflow the planner designed. If there is tester feedback in the thread, fix the issues it identified. +## Your task + +Implement (or fix) the workflow the planner designed. If there is tester or committer feedback in the thread, fix the issues they identified. + +## Multi-step approach + +You do NOT need to finish everything in one pass. You may return \`done: false\` to continue in the next iteration. For example: +1. First pass: scaffold files and basic structure +2. Second pass: implement role logic +3. Third pass: fix build/lint errors + +## Required files for each workflow -Required files for each workflow: - \`workflows//index.ts\` — WorkflowDefinition default export +- \`workflows//build.ts\` — factory function +- \`workflows//moderator.ts\` — moderator + meta types +- \`workflows//roles//index.ts\` — role build function +- \`workflows//roles//prompt.ts\` — prompt pure function - \`workflows//package.json\` — with esbuild build script - \`workflows//tsconfig.json\` — TypeScript config - Update \`nerve.yaml\` with \`workflows.\` -Rules: +## Rules + - Keep the WorkflowDefinition pattern - No dynamic import() - Use types (not interfaces) -- Include retry-aware moderator routing +- Meta should be simple routing signals (single boolean per role) - Write compile-ready TypeScript -After creating all files, run inside the workflow directory: -\`\`\` -pnpm install --no-cache && pnpm build -\`\`\` +## When to return done: true -End your response with a JSON block: -\`\`\`json -{ "done": true } -\`\`\` -if build succeeded, or: -\`\`\`json -{ "done": false } -\`\`\` -if there were errors.`; +Return \`done: true\` ONLY when ALL of the following are true: +- All required files are created +- \`pnpm install --no-cache && pnpm build\` succeeds (run it!) +- No lint or type errors remain + +Return \`done: false\` if you made progress but there is still work to do, or if build/lint has errors you plan to fix in the next iteration.`; }