Files
ai4se-harness-suite/agents-workflow-engine/agents_workflow_engine/render_mermaid.py
ning-inspire 69cfaea7dc feat: 引入 agents-workflow-engine 与 5 个 SDD skill
新增 agents-workflow-engine:主会话按泳道图调度子 agent 到提测,
含 schema、preset、CLI、单测,并接入 verify.sh。

agile-team-sdd 新增 5 个模板:ba-write-prototype、ba-requirement-review、
dev-plan-review、dev-plan-amend、pm-start-iteration,已登记 catalog
并同步安装到 example-project;README/AGENTS.md 同步 skill 数量 21→26。

验证:./.agents/verify.sh 全绿(67 项,含 AWE 14 个单测)。
文档同步检查:已更新 README、AGENTS.md、agile-team-sdd/README.md 与 SKILL.md。
2026-11-19 10:05:10 +08:00

45 lines
1.6 KiB
Python

"""把解析后的图写成 Mermaid。扩展节点不输出。"""
from __future__ import annotations
def _shape(node: dict) -> str:
title = node.get("title") or node["id"]
if node.get("batch"):
title += " · 一批任务"
if node.get("repeatsBatch"):
title += " · 按批循环"
if node.get("sealed") and node.get("note"):
title += " / " + "、".join(node["note"])
node_id = node["id"]
kind = node.get("kind")
if kind == "action":
return "%s(%s)" % (node_id, title)
if kind == "gate":
return "%s[[%s]]" % (node_id, title)
if kind == "decision":
return "%s{%s}" % (node_id, title)
if kind == "human_input":
return "%s[/%s/]" % (node_id, title)
if kind == "end":
return "%s([%s])" % (node_id, title)
if kind == "entry":
return "%s{{%s}}" % (node_id, title)
return "%s[%s]" % (node_id, title)
def render(graph: dict) -> str:
lines = ["flowchart LR"]
titles = (("human", "人"), ("master", "graph-master"), ("subagent", "子 agent"))
for actor, title in titles:
lines.append(" subgraph %s [%s]" % (actor, title))
for node in graph.get("nodes") or []:
if node.get("actor") == actor:
lines.append(" " + _shape(node))
lines.append(" end")
for edge in graph.get("edges") or []:
arrow = "-.->" if edge.get("back") else "-->"
label = "|%s|" % edge["when"] if edge.get("when") else ""
lines.append(" %s %s%s %s" % (edge["from"], arrow, label, edge["to"]))
return "\n".join(lines) + "\n"