小橘 fc2ca13dc3 refactor: remove buildSenseExamples, use @uncaged/nerve-skills for agent discovery
- Delete buildSenseExamples() (~25 lines of runtime file reading)
- Remove senseExamples from BuildSenseGeneratorDeps and BuildPlannerDeps
- Planner prompt now directs agent to read nerve-dev skill via npm package
- Clean up unused existsSync import

Closes xiaoju/nerve-workspace#2
2026-04-28 04:38:33 +00:00

51 lines
1.4 KiB
TypeScript

import { readFileSync } from "node:fs";
import { join } from "node:path";
import { spawnSafe } from "@uncaged/nerve-workflow-utils";
import { buildSenseGenerator } from "./build.js";
// --- Environment ---
const HOME = process.env.HOME ?? "/home/azureuser";
const NERVE_ROOT = join(HOME, ".uncaged-nerve");
const SENSES_DIR = join(NERVE_ROOT, "senses");
// --- Resolve provider ---
async function cfgGet(key: string): Promise<string | null> {
const result = await spawnSafe("cfg", ["get", key], {
cwd: NERVE_ROOT,
env: null,
timeoutMs: 10_000,
});
if (!result.ok) return null;
return result.value.stdout.trim() || null;
}
const apiKey = process.env.DASHSCOPE_API_KEY ?? (await cfgGet("DASHSCOPE_API_KEY"));
const baseUrl = process.env.DASHSCOPE_BASE_URL ?? (await cfgGet("DASHSCOPE_BASE_URL"));
const model = process.env.DASHSCOPE_MODEL ?? (await cfgGet("DASHSCOPE_MODEL")) ?? "qwen-plus";
if (!apiKey || !baseUrl) {
throw new Error("Set DASHSCOPE_API_KEY and DASHSCOPE_BASE_URL");
}
// --- Build context ---
function getNerveYaml(): string {
try {
return readFileSync(join(NERVE_ROOT, "nerve.yaml"), "utf-8");
} catch {
return "# nerve.yaml unavailable";
}
}
// --- Wire up ---
const workflow = buildSenseGenerator({
provider: { apiKey, baseUrl, model },
nerveRoot: NERVE_ROOT,
sensesDir: SENSES_DIR,
nerveYaml: getNerveYaml(),
});
export default workflow;