# Mermaid 智能体流程图速查表

一个智能体的步骤，以及每一步属于哪一类。

## 一个流程块

流程是拥有内部步骤的块。end 关键字把它关掉。

```mermaid
agentflow-beta TB
  flow worker["Worker"]
    job["Do the job"]@{ shape: task }
  end
```

![一张智能体流程图，有一个叫 Worker 的分组，里面装着一个步骤 Do the job。](/diagrams/agentflow/flow.svg)

## 这是哪一类步骤

shape: 后面的词说明这一步是什么。input、task、tool、decision、action 和 refdoc 共六种。

```mermaid
agentflow-beta LR
  brief["Brief"]@{ shape: input }
  draft["Draft copy"]@{ shape: task }
  check["spell_check"]@{ shape: tool }
  guide["Style guide"]@{ shape: refdoc }
  ship["Publish"]@{ shape: action }
  ok["Ready?"]@{ shape: decision }
  brief --> draft --> check --> ship
  ok --> ship
```

![一张从左到右的智能体流程，共六步：一份需求、一份草稿、一个拼写检查工具、一份风格指南、一个发布动作和一个就绪判断。](/diagrams/agentflow/shapes.svg)

## 箭头的写法

带标签的箭头说明原因。十字表示重试，虚线指向要读的东西。

```mermaid
agentflow-beta TB
  check["Tests pass?"]@{ shape: decision }
  ship["Ship it"]@{ shape: action }
  fix["Fix the build"]@{ shape: task }
  logs["Build logs"]@{ shape: refdoc }
  check -- yes --> ship
  check -- no --> fix
  fix --x check
  fix -.- logs
```

![一个判断节点在问测试是否通过，通过时分支到 Ship it，不通过时分支到 Fix the build，并有一条虚线从修复节点指向一盒构建日志。](/diagrams/agentflow/arrows.svg)

## 嵌套流程

一个流程可以装别的流程。里面的那些是子智能体。

```mermaid
agentflow-beta TB
  flow team["Content Team"]
    flow researcher["Researcher"]
      gather["Gather sources"]@{ shape: task }
    end
    flow writer["Writer"]
      compose["Compose draft"]@{ shape: task }
    end
    researcher --> writer
  end
```

![一个叫 Content Team 的流程，里面装着两个流程 Researcher 和 Writer，两者之间有一个箭头，各自装着一个步骤。](/diagrams/agentflow/nested.svg)

## 在 Mernyx 里画出来

打开一个 .mmd 文件，在画布上挪一个节点，源码跟着走。macOS 原生，不经过浏览器。
