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
This commit is contained in:
小橘 2026-04-28 11:02:25 +00:00
parent d638623456
commit 6778ba5246
2 changed files with 49 additions and 52 deletions

View File

@ -1,43 +1,31 @@
export function coderPrompt({ threadId }: { threadId: string }): string { 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\` 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: Implement (or fix) the sense the planner designed. If there is tester feedback in the thread, fix the issues it identified.
- \`senses/<name>/src/index.ts\` — TypeScript source with proper types; import schema as \`./schema.ts\`
## 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/<name>/src/index.ts\` — TypeScript compute source; import schema as \`./schema.ts\`
- \`senses/<name>/src/schema.ts\` — Drizzle schema (TypeScript) - \`senses/<name>/src/schema.ts\` — Drizzle schema (TypeScript)
- \`senses/<name>/migrations/\` — Drizzle migration files (at sense root, not inside src/) - \`senses/<name>/migrations/\` — Drizzle migration files (at sense root, not inside src/)
- \`senses/<name>/package.json\` — with esbuild build script (see below) - \`senses/<name>/package.json\` — with esbuild build script
- \`senses/<name>/index.js\` — bundled output generated by \`pnpm build\` (do NOT edit by hand) - \`senses/<name>/index.js\` — bundled output generated by \`pnpm build\` (do NOT edit by hand)
package.json template for each sense: Look at existing senses for the package.json template and patterns.
\`\`\`json
{ ## When to return done: true
"name": "sense-<name>",
"version": "0.0.1", Return \`done: true\` ONLY when ALL of the following are true:
"private": true, - All required files are created
"type": "module", - \`pnpm install --no-cache && pnpm build\` succeeds (run it!)
"scripts": { - \`nerve.yaml\` is updated with the sense config
"build": "esbuild src/index.ts --bundle --platform=node --format=esm --outfile=index.js --packages=external"
}, Return \`done: false\` if you made progress but there is still work to do.`;
"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.`;
} }

View File

@ -1,35 +1,44 @@
export function coderPrompt({ threadId }: { threadId: string }): string { 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\` 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. 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/<name>/index.ts\` — WorkflowDefinition default export - \`workflows/<name>/index.ts\` — WorkflowDefinition default export
- \`workflows/<name>/build.ts\` — factory function
- \`workflows/<name>/moderator.ts\` — moderator + meta types
- \`workflows/<name>/roles/<role>/index.ts\` — role build function
- \`workflows/<name>/roles/<role>/prompt.ts\` — prompt pure function
- \`workflows/<name>/package.json\` — with esbuild build script - \`workflows/<name>/package.json\` — with esbuild build script
- \`workflows/<name>/tsconfig.json\` — TypeScript config - \`workflows/<name>/tsconfig.json\` — TypeScript config
- Update \`nerve.yaml\` with \`workflows.<name>\` - Update \`nerve.yaml\` with \`workflows.<name>\`
Rules: ## Rules
- Keep the WorkflowDefinition<WorkflowMeta> pattern - Keep the WorkflowDefinition<WorkflowMeta> pattern
- No dynamic import() - No dynamic import()
- Use types (not interfaces) - Use types (not interfaces)
- Include retry-aware moderator routing - Meta should be simple routing signals (single boolean per role)
- Write compile-ready TypeScript - Write compile-ready TypeScript
After creating all files, run inside the workflow directory: ## When to return done: true
\`\`\`
pnpm install --no-cache && pnpm build
\`\`\`
End your response with a JSON block: Return \`done: true\` ONLY when ALL of the following are true:
\`\`\`json - All required files are created
{ "done": true } - \`pnpm install --no-cache && pnpm build\` succeeds (run it!)
\`\`\` - No lint or type errors remain
if build succeeded, or:
\`\`\`json 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.`;
{ "done": false }
\`\`\`
if there were errors.`;
} }