Each role's prompt is now a separate markdown file with {{mustache}} placeholders,
loaded at module init and interpolated at runtime.
小橘 🍊(NEKO Team)
28 lines
1.0 KiB
TypeScript
28 lines
1.0 KiB
TypeScript
import { createCursorRole } from "@uncaged/nerve-workflow-utils";
|
|
import { readFileSync } from "node:fs";
|
|
import { join, dirname } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import { resolveDashScopeProvider, NERVE_ROOT, SENSES_DIR } from "../shared.js";
|
|
import { coderMetaSchema } from "../types.js";
|
|
import type { SenseMeta } from "../types.js";
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
const PROMPT = readFileSync(join(__dirname, "prompt.md"), "utf-8");
|
|
|
|
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) =>
|
|
PROMPT
|
|
.replace("{{threadId}}", threadId)
|
|
.replace("{{sensesDir}}", SENSES_DIR)
|
|
.replace("{{nerveRoot}}", NERVE_ROOT),
|
|
extract: { provider, schema: coderMetaSchema },
|
|
});
|
|
}
|