feat: taskId 深链会商按任务隔离草稿 + 第三步自动结构化流程图

- 深链 ?taskId=&goPath=*-A 透传 taskId 进会商,按 taskId 隔离存取草稿(一个 taskId 多条、可新建);
  后端新增 GET /api/roundtable-drafts/by-task/{id} 列表 + RoundtableJobRepository.status_map_by_drafts 富化。
- 第三步生成 md 报告后自动结构化输出流程图(仅 taskId 模式):有报告基于报告、无报告基于各席位交付,
  整段内联数据来源逐条抽取;层级优先用业务链总控提示词写明的层级,否则用 stages 的 goal。
- 流程图节点加 group(层级名)标签 + detail(条目名称+理由);强 prompt 压制 coordinatorPrompt 报告锚定,
  禁阶段编号节点;FLOW_STRUCTURE_RULE 精确画法(根=任务、每层每条成节点、按对应关系串分支、排除汇总段落)。
- flow-graph 解析容错:JSON.parse 失败退回正则逐字段抽取,兼容裸换行/尾逗号,避免节点被整体丢弃。
- 修:重开第二步后第三步基于新一轮分析重新生成(复位 step3 闸门 + 中断旧三流)。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
fengxiangdebaoziandClaude Opus 4.8 committed 2026-06-17 19:45:35 +08:00
1 parent e6a41dbc97
commit fca39eeaee
17 files changed
+472 -37

No files matched your search

@@ -77,6 +77,62 @@ test("extractFlowGraph:无 fence / 无完整节点返回 null", () => {
assert.equal(extractFlowGraph('```flow-json\n{"nodes":[{"id":"a"'), null);
});
test("extractFlowGraph:group 层级名解析(兼容 group/level)", () => {
const text = [
"```flow-json",
'{"nodes":[',
'{"id":"n1","label":"暑期文旅","type":"start","group":"任务"},',
'{"id":"n2","label":"情绪管理","type":"task","level":"目的","from":["n1"]}',
"]}",
"```",
].join("\n");
const g = extractFlowGraph(text);
assert.ok(g);
assert.equal(g.nodes[0].group, "任务");
assert.equal(g.nodes[1].group, "目的"); // level 别名也认
});
test("extractFlowGraph:容错——detail 含裸换行的非法 JSON 节点不被整个丢弃", () => {
// 模型常在 JSON 字符串里吐真实换行(非法 JSON):n2 的 detail 跨行,
// 旧逻辑会 JSON.parse 失败把 n2/n3 整个丢掉,只剩 n1(即「只出两个节点」bug)。
const text = [
"```flow-json",
'{"title":"T","nodes":[',
'{"id":"n1","label":"任务X","type":"start","group":"任务"},',
'{"id":"n2","label":"目的A","type":"task","group":"目的","detail":"名称:目的A',
'理由:跨了行的说明文字","from":["n1"]},',
'{"id":"n3","label":"行为体A","type":"role","group":"行为体","detail":"名称:行为体A;理由:单行说明","from":["n2"]}',
"]}",
"```",
].join("\n");
const g = extractFlowGraph(text);
assert.ok(g);
// 三个节点都救回来(含裸换行的 n2 不再丢失)。
assert.equal(g.nodes.length, 3);
assert.equal(g.nodes[1].group, "目的");
assert.ok((g.nodes[1].detail ?? "").includes("目的A"));
// 连线也按 from 串起来。
assert.deepEqual(g.edges, [
{ from: "n1", to: "n2" },
{ from: "n2", to: "n3" },
]);
});
test("extractFlowGraph:容错——尾逗号的非法 JSON 节点仍解析", () => {
const text = [
"```flow-json",
'{"nodes":[',
'{"id":"a","label":"A","type":"task","group":"目的",},', // 尾逗号 → JSON.parse 失败
'{"id":"b","label":"B","type":"task","from":["a"]}',
"]}",
"```",
].join("\n");
const g = extractFlowGraph(text);
assert.ok(g);
assert.equal(g.nodes.length, 2);
assert.equal(g.nodes[0].group, "目的");
});
test("extractFlowGraph:兼容独立 edges 数组(source/target 别名)", () => {
const text = [
"```flow-json",