v5.3: 完整版含步骤解析器(纯ASCII) + recordExperience + modal审批

This commit is contained in:
bingshuo 2026-05-31 00:42:55 +08:00
parent 610628dadc
commit 94c90dd7c9

View File

@ -26,30 +26,24 @@ const PLANS_DIR = path.join(__dirname, "plans");
if (!fs.existsSync(PLANS_DIR)) fs.mkdirSync(PLANS_DIR, { recursive: true }); if (!fs.existsSync(PLANS_DIR)) fs.mkdirSync(PLANS_DIR, { recursive: true });
const START_TIME = new Date().toISOString(); const START_TIME = new Date().toISOString();
// ═══ 步骤解析器 v5.3 — 将 Notion steps 文本转为 task 对象 ═══ // v5.3: step parser - ASCII-only, no regex on Chinese chars
function parsePlanSteps(stepsText, planId) { function parsePlanSteps(stepsText, planId) {
if (!stepsText) return []; if (!stepsText) return [];
const lines = stepsText.split("\n").filter(l => l.trim()); var lines = stepsText.split("\n").filter(function(l) { return l.trim(); });
const tasks = []; var tasks = [];
let idx = 0; var idx = 0;
for (const line of lines) { for (var i = 0; i < lines.length; i++) {
const m = line.match(/^\s*(\d+)\.?\s+(.+)/); var m = lines[i].match(/^\s*(\d+)\.?\s+(.+)/);
if (m) { if (m) {
idx++; idx++;
const desc = m[2].trim(); var desc = m[2].trim();
let action = "write_file"; var action = "write_file";
if (/安装|执行|运行|启动|重启|构建|编译/.test(desc)) action = "run_cmd"; var d = desc;
if (/API|接口|对接|请求|调用/.test(desc)) action = "call_api"; if (d.indexOf("API") !== -1 || d.indexOf("Notion") !== -1) action = "call_api";
if (/验证|测试|检查|确认|审核/.test(desc)) action = "check"; if (d.indexOf("curl") !== -1 || d.indexOf("npm") !== -1 || d.indexOf("git") !== -1) action = "run_cmd";
tasks.push({ tasks.push({ id: planId + "-t" + idx, action: action, target: "", description: desc, context: "Notion:" + stepsText.slice(0, 200) });
id: planId + "-t" + idx,
action,
target: "",
description: desc,
context: "从Notion工单提取: " + (stepsText.slice(0, 200))
});
} }
} }
console.log("[StepParser] " + planId + " " + tasks.length + " tasks"); console.log("[StepParser] " + planId + " -> " + tasks.length + " tasks");
return tasks; return tasks;
} }