Replace createCursorRole/createHermesRole with adapter + prompt + zod meta. Add shared compileRoleSpec, cursor ask adapter, nerve.yaml extract defaults. Refs #248 Made-with: Cursor
27 lines
979 B
TypeScript
27 lines
979 B
TypeScript
import type { LlmProvider } from "@uncaged/nerve-workflow-utils";
|
|
import { spawnSafe } from "@uncaged/nerve-workflow-utils";
|
|
|
|
export async function cfgGet(nerveRoot: string, key: string): Promise<string | null> {
|
|
const result = await spawnSafe("cfg", ["get", key], {
|
|
cwd: nerveRoot,
|
|
env: null,
|
|
timeoutMs: 10_000,
|
|
abortSignal: null,
|
|
});
|
|
if (!result.ok) {
|
|
return null;
|
|
}
|
|
const value = result.value.stdout.trim();
|
|
return value.length > 0 ? value : null;
|
|
}
|
|
|
|
export async function resolveDashScopeProvider(nerveRoot: string): Promise<LlmProvider | null> {
|
|
const apiKey = process.env.DASHSCOPE_API_KEY ?? (await cfgGet(nerveRoot, "DASHSCOPE_API_KEY"));
|
|
const baseUrl = process.env.DASHSCOPE_BASE_URL ?? (await cfgGet(nerveRoot, "DASHSCOPE_BASE_URL"));
|
|
const model = process.env.DASHSCOPE_MODEL ?? (await cfgGet(nerveRoot, "DASHSCOPE_MODEL")) ?? "qwen-plus";
|
|
if (!apiKey || !baseUrl) {
|
|
return null;
|
|
}
|
|
return { apiKey, baseUrl, model };
|
|
}
|