2026-04-28 02:38:07 +00:00

31 lines
1.1 KiB
TypeScript

import { createCursorRole } from "@uncaged/nerve-workflow-utils";
import { resolveDashScopeProvider, NERVE_ROOT, SENSES_DIR } from "../shared.js";
import { coderMetaSchema } from "../types.js";
import type { SenseMeta } from "../types.js";
export async function buildCoderRole() {
const provider = await resolveDashScopeProvider();
if (provider === null) {
throw new Error("Cannot create coder: set DASHSCOPE_API_KEY and DASHSCOPE_BASE_URL");
}
return createCursorRole<SenseMeta["coder"]>({
cwd: NERVE_ROOT,
mode: "default",
prompt: async (threadId) =>
`Read the workflow thread for the planner's sense design: \`nerve thread ${threadId}\`
Implement the sense. Create exactly:
1. The sense directory under ${SENSES_DIR}/<sense-name>/
2. index.js — export async function compute(db, _peers), import schema from "./schema.ts"
3. schema.ts — drizzle-orm/sqlite-core
4. migrations/0001_init.sql — must match schema.ts
5. Update ${NERVE_ROOT}/nerve.yaml — add sense config + reflex entry
Follow the patterns from existing senses. Create all files now.`,
extract: {
provider,
schema: coderMetaSchema,
},
});
}