diff --git a/agents/zhuyuan-dev-agent/server.js b/agents/zhuyuan-dev-agent/server.js index 9e842b9..653cd91 100644 --- a/agents/zhuyuan-dev-agent/server.js +++ b/agents/zhuyuan-dev-agent/server.js @@ -26,30 +26,24 @@ const PLANS_DIR = path.join(__dirname, "plans"); if (!fs.existsSync(PLANS_DIR)) fs.mkdirSync(PLANS_DIR, { recursive: true }); 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) { if (!stepsText) return []; - const lines = stepsText.split("\n").filter(l => l.trim()); - const tasks = []; - let idx = 0; - for (const line of lines) { - const m = line.match(/^\s*(\d+)\.?\s+(.+)/); + var lines = stepsText.split("\n").filter(function(l) { return l.trim(); }); + var tasks = []; + var idx = 0; + for (var i = 0; i < lines.length; i++) { + var m = lines[i].match(/^\s*(\d+)\.?\s+(.+)/); if (m) { idx++; - const desc = m[2].trim(); - let action = "write_file"; - if (/安装|执行|运行|启动|重启|构建|编译/.test(desc)) action = "run_cmd"; - if (/API|接口|对接|请求|调用/.test(desc)) action = "call_api"; - if (/验证|测试|检查|确认|审核/.test(desc)) action = "check"; - tasks.push({ - id: planId + "-t" + idx, - action, - target: "", - description: desc, - context: "从Notion工单提取: " + (stepsText.slice(0, 200)) - }); + var desc = m[2].trim(); + var action = "write_file"; + var d = desc; + if (d.indexOf("API") !== -1 || d.indexOf("Notion") !== -1) action = "call_api"; + if (d.indexOf("curl") !== -1 || d.indexOf("npm") !== -1 || d.indexOf("git") !== -1) action = "run_cmd"; + tasks.push({ id: planId + "-t" + idx, action: 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; } \ No newline at end of file