|
|
/**
|
|
|
* 生成 lab-eval-prompt.txt:便于在 Cursor 聊天中 @student-lab-ai-evaluation 后整段粘贴,
|
|
|
* 将助手返回的纯 JSON 手动保存为 lab-eval-ai.json(无需 CURSOR_API_KEY)。
|
|
|
*/
|
|
|
import fs from 'fs';
|
|
|
import path from 'path';
|
|
|
import { fileURLToPath } from 'url';
|
|
|
import { createRequire } from 'module';
|
|
|
|
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
|
const ROOT = path.join(__dirname, '..');
|
|
|
const require = createRequire(import.meta.url);
|
|
|
const { analyzeChatLogsFile } = require(path.join(ROOT, 'lib/analyzeChatLogs.js'));
|
|
|
const { resolveChatLogPath } = require(path.join(ROOT, 'lib/resolveChatLogPath.cjs'));
|
|
|
|
|
|
function readText(p) {
|
|
|
return fs.readFileSync(p, 'utf8');
|
|
|
}
|
|
|
|
|
|
function main() {
|
|
|
const chatPath = resolveChatLogPath(ROOT);
|
|
|
if (!fs.existsSync(chatPath)) {
|
|
|
console.error(`缺少聊天日志文件: ${chatPath}(可设置环境变量 CHAT_LOG_PATH)`);
|
|
|
process.exit(1);
|
|
|
}
|
|
|
|
|
|
const taskMd = readText(path.join(ROOT, 'config/lab-task-description.md'));
|
|
|
const dims = readText(path.join(ROOT, 'config/evaluation-dimensions.yaml'));
|
|
|
const skillPath = path.join(ROOT, '.cursor/skills/student-lab-ai-evaluation/SKILL.md');
|
|
|
const skill = fs.existsSync(skillPath) ? readText(skillPath) : '';
|
|
|
|
|
|
const heuristic = analyzeChatLogsFile(chatPath);
|
|
|
const heuristicStr = JSON.stringify(heuristic, null, 2);
|
|
|
|
|
|
const body = `【说明】在 Cursor 中引用技能 @student-lab-ai-evaluation,将下文从「--- 开始」到结尾整段复制给助手;要求助手只输出一个 JSON 对象(无 Markdown 围栏),保存为项目根目录 lab-eval-ai.json。
|
|
|
|
|
|
--- 开始 ---
|
|
|
|
|
|
你是课程助教。请严格遵守下列 SKILL 中的输出约束。
|
|
|
|
|
|
--- SKILL 开始 ---
|
|
|
${skill}
|
|
|
--- SKILL 结束 ---
|
|
|
|
|
|
--- 实训任务描述 ---
|
|
|
${taskMd}
|
|
|
|
|
|
--- 评价维度配置(YAML)---
|
|
|
${dims}
|
|
|
|
|
|
--- 启发式解析 JSON(来自 chat_logs)---
|
|
|
${heuristicStr}
|
|
|
|
|
|
--- 结束 ---
|
|
|
|
|
|
`;
|
|
|
|
|
|
const outPath = path.join(ROOT, 'lab-eval-prompt.txt');
|
|
|
fs.writeFileSync(outPath, body, 'utf8');
|
|
|
console.log('已生成', outPath);
|
|
|
console.log('下一步:在 Cursor 中 @student-lab-ai-evaluation,粘贴该文件全文;将模型返回的 JSON 存为 lab-eval-ai.json 后执行 npm start 刷新报告。');
|
|
|
}
|
|
|
|
|
|
main();
|