@fieldwangai/agentflow 0.1.28 → 0.1.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agents/agentflow-node-executor-code.md +3 -2
- package/agents/agentflow-node-executor-planning.md +3 -2
- package/agents/agentflow-node-executor-requirement.md +3 -2
- package/agents/agentflow-node-executor-test.md +3 -2
- package/agents/agentflow-node-executor-ui.md +3 -2
- package/agents/agentflow-node-executor.md +3 -2
- package/agents/en/agentflow-node-executor.md +3 -2
- package/agents/zh/agentflow-node-executor.md +3 -2
- package/bin/lib/agent-runners.mjs +38 -13
- package/bin/lib/api-runner.mjs +6 -3
- package/bin/lib/auth.mjs +240 -0
- package/bin/lib/catalog-agents.mjs +2 -2
- package/bin/lib/catalog-flows.mjs +192 -16
- package/bin/lib/composer-agent.mjs +21 -1
- package/bin/lib/composer-skill-router.mjs +10 -78
- package/bin/lib/flow-import.mjs +2 -2
- package/bin/lib/flow-write.mjs +20 -20
- package/bin/lib/help.mjs +2 -2
- package/bin/lib/locales/en.json +25 -1
- package/bin/lib/locales/zh.json +25 -1
- package/bin/lib/main.mjs +6 -1
- package/bin/lib/node-exec-context.mjs +5 -5
- package/bin/lib/node-execute.mjs +14 -9
- package/bin/lib/paths.mjs +64 -13
- package/bin/lib/recent-runs.mjs +2 -2
- package/bin/lib/run-node-statuses-from-disk.mjs +3 -3
- package/bin/lib/runtime-context.mjs +225 -0
- package/bin/lib/scheduler.mjs +41 -38
- package/bin/lib/skill-registry.mjs +145 -0
- package/bin/lib/ui-server.mjs +902 -57
- package/bin/lib/workspace-tree.mjs +4 -3
- package/bin/lib/workspace.mjs +9 -11
- package/bin/pipeline/build-node-prompt.mjs +29 -4
- package/bin/pipeline/get-exec-id.mjs +2 -2
- package/bin/pipeline/get-resolved-values.mjs +1 -0
- package/bin/pipeline/pre-process-node.mjs +306 -6
- package/bin/pipeline/validate-flow.mjs +2 -0
- package/builtin/nodes/agent_subAgent.md +7 -1
- package/builtin/nodes/control_cd_workspace.md +43 -0
- package/builtin/nodes/control_load_skills.md +48 -0
- package/builtin/nodes/display_ascii.md +17 -0
- package/builtin/nodes/display_markdown.md +17 -0
- package/builtin/nodes/display_mermaid.md +17 -0
- package/builtin/nodes/tool_git_checkout.md +54 -0
- package/builtin/nodes/tool_nodejs.md +8 -1
- package/builtin/nodes/tool_print.md +4 -1
- package/builtin/web-ui/dist/assets/index-NdVOJLL9.js +196 -0
- package/builtin/web-ui/dist/assets/index-naVI6LZj.css +1 -0
- package/builtin/web-ui/dist/index.html +2 -2
- package/package.json +2 -1
- package/skills/agentflow-flow-add-instances/SKILL.md +257 -0
- package/skills/agentflow-flow-edit-node-fields/SKILL.md +79 -0
- package/skills/agentflow-flow-recipes/SKILL.md +24 -0
- package/skills/agentflow-flow-recipes/references/recipes.md +63 -0
- package/skills/agentflow-flow-sync-ui/SKILL.md +59 -0
- package/skills/agentflow-node-reference/SKILL.md +25 -0
- package/skills/agentflow-node-reference/references/builtin-nodes.md +210 -0
- package/skills/agentflow-placeholder-reference/SKILL.md +24 -0
- package/skills/agentflow-placeholder-reference/references/placeholders.md +20 -0
- package/skills/agentflow-runtime-reference/SKILL.md +25 -0
- package/skills/agentflow-runtime-reference/references/runtime.md +64 -0
- package/builtin/web-ui/dist/assets/index-BeUBxIj1.js +0 -190
- package/builtin/web-ui/dist/assets/index-BzhdjOzb.css +0 -1
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agentflow-flow-add-instances
|
|
3
|
+
description: >-
|
|
4
|
+
向 AgentFlow 的 flow.yaml 新增实例:说明 instances/edges/ui 的 YAML 结构、
|
|
5
|
+
从内置定义拷贝 instance、设计连接点与内容;新增节点的 ui.nodePositions
|
|
6
|
+
默认放在画布视觉中心附近。不用于仅改已有节点文案或占位值。
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# AgentFlow:新增 instances
|
|
10
|
+
|
|
11
|
+
在 **向现有 flow 增加新节点(一个或多个)** 时使用本技能。
|
|
12
|
+
|
|
13
|
+
**路径说明**:`npx skills add` 后本文件不在 AgentFlow 仓库内;文中 `reference/`、`builtin/` 均相对 **AgentFlow 仓库根目录**,请在以该仓库为工作区时打开文件。
|
|
14
|
+
|
|
15
|
+
**权威参考**(仓库根):
|
|
16
|
+
|
|
17
|
+
- `reference/flow-control-capabilities.md` — handle、边、控制节点语义
|
|
18
|
+
- `reference/flow-layout.md` — 整体布局原则(本技能对「新增」默认用**中心落点**,再按需微调)
|
|
19
|
+
- `reference/flow-prompt-handler-check.md` — 增边后 USER_PROMPT 与 handler 一致
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## flow.yaml 顶层结构
|
|
24
|
+
|
|
25
|
+
```yaml
|
|
26
|
+
instances:
|
|
27
|
+
<instanceId>:
|
|
28
|
+
definitionId: <内置或已存在定义 id>
|
|
29
|
+
label: ...
|
|
30
|
+
role: ...
|
|
31
|
+
input: [ { type, name, value }, ... ]
|
|
32
|
+
output: [ { type, name, value }, ... ]
|
|
33
|
+
script: <可选,tool_nodejs 直接执行的命令,支持 ${} 占位符>
|
|
34
|
+
body: | ...
|
|
35
|
+
edges:
|
|
36
|
+
- source: <instanceId>
|
|
37
|
+
target: <instanceId>
|
|
38
|
+
sourceHandle: output-0
|
|
39
|
+
targetHandle: input-0
|
|
40
|
+
ui:
|
|
41
|
+
nodePositions:
|
|
42
|
+
<instanceId>:
|
|
43
|
+
x: <number>
|
|
44
|
+
'y': <number>
|
|
45
|
+
description: 可选
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
- **`instances`**:键为 **instanceId**(全图唯一),值为该次运行的节点实例;**不要**写 **`description`**(系统说明由 `definitionId` 对应节点 `.md` 的 frontmatter 提供)。
|
|
49
|
+
- **`script`**(仅 `tool_nodejs`):指定直接执行的命令,流水线将跳过 AI 直接运行 `run-tool-nodejs` 执行。支持 `${workspaceRoot}`、`${flowName}`、`${runDir}`、`${flowDir}` 及所有 input 槽位占位符,值自动 shell-quote。**引用 flow 自带脚本必须用 `${flowDir}/scripts/xxx.mjs`**(`${flowDir}` 指向 flow 当前所在目录,兼容 user/workspace/builtin 三种安装位置),**禁止**硬编码 `${workspaceRoot}/.workspace/agentflow/pipelines/${flowName}/scripts/...`(flow 安装到 `~/agentflow/pipelines/` 或 builtin 时会 Cannot find module)。脚本 stdout 须输出 `{"err_code":0,"message":{"result":"..."}}`。无 `script` 时回退到 AI 执行。
|
|
50
|
+
- **`edges`**:有向边;多输入/多输出必须写对 **`targetHandle` / `sourceHandle`**(见下表)。
|
|
51
|
+
- **`ui.nodePositions`**:编辑器坐标;**每个新 instanceId 必须新增一项**,否则画布会堆叠。
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## 节点类型选择(必读)
|
|
56
|
+
|
|
57
|
+
新增实例时,**首先判断该步骤应使用哪种节点类型**。核心原则:**能用 tool 节点确定性执行的,不要用 agent_subAgent。**
|
|
58
|
+
|
|
59
|
+
| 判断条件 | 推荐 definitionId | 说明 |
|
|
60
|
+
|----------|-------------------|------|
|
|
61
|
+
| 行为完全由输入决定,不需要 AI 推理 | **tool_nodejs** + `script` 字段 | 打印文本、运行已有脚本、文件操作、数据转换等 |
|
|
62
|
+
| 向用户输出醒目信息 | **tool_print** | 专用输出节点 |
|
|
63
|
+
| 需要 AI 理解上下文、做判断、生成内容 | **agent_subAgent** | 撰写文档、分析代码、理解语义后做决策 |
|
|
64
|
+
|
|
65
|
+
**tool_nodejs + script 示例**(打印文本):
|
|
66
|
+
|
|
67
|
+
```yaml
|
|
68
|
+
print_haha:
|
|
69
|
+
definitionId: tool_nodejs
|
|
70
|
+
label: 打印哈哈哈
|
|
71
|
+
script: node -e "console.log(${value})"
|
|
72
|
+
input:
|
|
73
|
+
- type: 节点
|
|
74
|
+
name: prev
|
|
75
|
+
value: ''
|
|
76
|
+
- type: 文本
|
|
77
|
+
name: value
|
|
78
|
+
value: ''
|
|
79
|
+
output:
|
|
80
|
+
- type: 节点
|
|
81
|
+
name: next
|
|
82
|
+
value: ''
|
|
83
|
+
- type: 文本
|
|
84
|
+
name: result
|
|
85
|
+
value: ''
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
- `script` 支持 `${}` 占位符引用 input 槽位,值自动 shell-quote。
|
|
89
|
+
- input/output 须与 `tool_nodejs` 节点定义一致(prev/next + result),可按需添加额外文本/文件槽位供 `script` 引用。
|
|
90
|
+
- **成败判定**:以脚本进程 **exit code** 为准(0 = success,非 0 = failed)。
|
|
91
|
+
- **stdout → result**:脚本 stdout 直接作为 result 槽位内容,纯文本即可(如 `console.log("hello")`)。无需输出 JSON。
|
|
92
|
+
- **JSON 兼容(可选)**:stdout 为 `{"err_code":0,"message":{"result":"..."}}` 时,err_code 覆盖 exit code;仅旧脚本或需要特殊成败语义时使用。
|
|
93
|
+
|
|
94
|
+
**常见误用**:用 `agent_subAgent` 做「打印一段文字」「执行一个已知命令」「跑一个已有脚本」—— 这些都应该用 `tool_nodejs` + `script`。
|
|
95
|
+
|
|
96
|
+
### tool_nodejs 的 `script` 与 `body` 区分(关键规则)
|
|
97
|
+
|
|
98
|
+
| 字段 | 作用 | 执行时行为 |
|
|
99
|
+
|------|------|-----------|
|
|
100
|
+
| `script` | **实际执行的 shell/node 命令** | 流水线直接 spawn 执行,stdout 作为 result |
|
|
101
|
+
| `body` | **纯文档说明**(可选) | 有 `script` 时完全忽略;无 `script` 时作为 AI 指令(兜底) |
|
|
102
|
+
|
|
103
|
+
**关键约束**:
|
|
104
|
+
1. **`tool_nodejs` 必须写 `script` 字段**,内容为完整可执行的命令或脚本,禁止用自然语言描述
|
|
105
|
+
2. `script` 中可通过 `${}` 引用 input 槽位和系统变量,值自动 shell-quote
|
|
106
|
+
3. **`script` 必须引用所有非 node 类型的 input 和 output 引脚**(硬性校验,validate-flow 会报错):
|
|
107
|
+
- 所有 input 引脚(type ≠ node)必须在 script 中出现 `${slotName}`,用于接收上游数据
|
|
108
|
+
- 所有 output 引脚(type ≠ node)必须在 script 中出现 `${slotName}`,系统将解析为 output 文件路径,脚本应直接 `fs.writeFileSync(path, value)` 写入
|
|
109
|
+
- **禁止使用 JSON stdout 封装**(`{"err_code":0,"message":{...}}`),直接写文件、用 exit code 决定成败
|
|
110
|
+
4. `body` 仅用于给人类阅读的注释说明,**不会被执行**
|
|
111
|
+
5. 如果无法写出完整可执行的 `script`(如需要 AI 理解/判断),**必须改用 `agent_subAgent`**
|
|
112
|
+
6. **禁止**在 `script` 中写自然语言,**禁止**在 `body` 中写期望被执行的代码逻辑
|
|
113
|
+
|
|
114
|
+
### tool_nodejs 复杂脚本示例
|
|
115
|
+
|
|
116
|
+
**多行脚本(API 调用 + 数据处理)**:
|
|
117
|
+
```yaml
|
|
118
|
+
fetch_api_data:
|
|
119
|
+
definitionId: tool_nodejs
|
|
120
|
+
label: 调用API获取数据
|
|
121
|
+
script: |
|
|
122
|
+
curl -s -H "Authorization: Bearer ${token}" "https://api.example.com/data" | node -e "
|
|
123
|
+
let d=''; process.stdin.on('data',c=>d+=c); process.stdin.on('end',()=>{
|
|
124
|
+
const res=JSON.parse(d);
|
|
125
|
+
const items=res.data.map(i=>({id:i.id,name:i.name}));
|
|
126
|
+
console.log(JSON.stringify(items,null,2));
|
|
127
|
+
});"
|
|
128
|
+
body: |
|
|
129
|
+
调用 Example API 获取数据列表并提取 id 和 name 字段
|
|
130
|
+
input:
|
|
131
|
+
- { type: 节点, name: prev, value: '' }
|
|
132
|
+
- { type: 文本, name: token, value: '' }
|
|
133
|
+
output:
|
|
134
|
+
- { type: 节点, name: next, value: '' }
|
|
135
|
+
- { type: 文本, name: result, value: '' }
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
**文件读写 + JSON 处理**:
|
|
139
|
+
```yaml
|
|
140
|
+
merge_json_files:
|
|
141
|
+
definitionId: tool_nodejs
|
|
142
|
+
label: 合并JSON
|
|
143
|
+
script: |
|
|
144
|
+
node -e "
|
|
145
|
+
const fs=require('fs');
|
|
146
|
+
const a=JSON.parse(fs.readFileSync(${fileA},'utf8'));
|
|
147
|
+
const b=JSON.parse(fs.readFileSync(${fileB},'utf8'));
|
|
148
|
+
console.log(JSON.stringify({...a,...b},null,2));
|
|
149
|
+
"
|
|
150
|
+
body: |
|
|
151
|
+
合并两个 JSON 文件的内容
|
|
152
|
+
input:
|
|
153
|
+
- { type: 节点, name: prev, value: '' }
|
|
154
|
+
- { type: 文件, name: fileA, value: '' }
|
|
155
|
+
- { type: 文件, name: fileB, value: '' }
|
|
156
|
+
output:
|
|
157
|
+
- { type: 节点, name: next, value: '' }
|
|
158
|
+
- { type: 文本, name: result, value: '' }
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
**错误示范**(禁止):
|
|
162
|
+
```yaml
|
|
163
|
+
# ❌ 错误:tool_nodejs 却没有 script,body 是自然语言
|
|
164
|
+
bad_node:
|
|
165
|
+
definitionId: tool_nodejs
|
|
166
|
+
label: 获取截图
|
|
167
|
+
body: |
|
|
168
|
+
调用 Figma REST API 获取整体 UI 截图
|
|
169
|
+
- 解析 figmaUrl 提取 fileKey
|
|
170
|
+
- 调用 GET /v1/images/:fileKey 获取截图
|
|
171
|
+
- 将截图保存到 ${result}
|
|
172
|
+
```
|
|
173
|
+
上例应改为:写出完整可执行的 `script`,或改用 `agent_subAgent`(由 AI 执行复杂操作)。
|
|
174
|
+
|
|
175
|
+
**节点单一职责**:**每个节点只做一件事,工作内容保持专注和专一。** 不要把多个无关操作塞进同一个 `body`。如果任务包含多个可独立完成的步骤,应拆分为多个节点通过边串联。例如"分析代码并生成测试"应拆为两个节点:节点 A 分析代码 → 节点 B 生成测试。拆分后可调试、可复用、可并行,AI 生成质量也更高。
|
|
176
|
+
|
|
177
|
+
详见 `reference/flow-control-capabilities.md` 第 6 节。
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## 新增 instance 的步骤
|
|
182
|
+
|
|
183
|
+
1. 从 **`builtin/pipelines/new/flow.yaml`** 或同仓库已有 flow 中,拷贝**同类** `definitionId` 的实例块作为模板,改 **`instanceId`**、`label`,按需改 `body` / `value`。
|
|
184
|
+
2. **不要**自造 `input`/`output` 的 **顺序、name、type**;须与节点类定义一致,否则 handle 索引会错。
|
|
185
|
+
3. **默认不连线**:仅新增 `instances` 和 `ui.nodePositions`,**不写 `edges`**,重点关注节点内容与连接点的正确性设计。
|
|
186
|
+
4. **仅当用户明确说「连线」「接到 X」「插入到 A 和 B 之间」等指令时**,才在 `edges` 中增加对应的边,并写 **`sourceHandle` / `targetHandle`**。
|
|
187
|
+
5. 在 **`ui.nodePositions`** 中为该 instanceId 写入坐标(见下一节「屏幕中间」)。
|
|
188
|
+
6. 每个 flow 仍只能有一个 **`control_start`**、一个 **`control_end`** 实例(勿重复新增入口/出口)。
|
|
189
|
+
|
|
190
|
+
**`control_toBool`**(本地确定性:parseBool 解析 true/1/yes/on → true,其余 → false,不调用 AI)和 **`control_agent_toBool`**(AI agent 语义判断,适用于不确定场景)的 prediction 输出文件内容必须仅为 **`true`** 或 **`false`**。
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## Handle 速查(新增边时必填)
|
|
195
|
+
|
|
196
|
+
| definitionId | 常用 output | 常用 input |
|
|
197
|
+
|--------------|-------------|------------|
|
|
198
|
+
| control_start | next → output-0 | — |
|
|
199
|
+
| control_end | — | prev → input-0 |
|
|
200
|
+
| control_if | next1(**TRUE**) → output-0, next2(**FALSE**) → output-1 | prev → input-0, prediction → input-1 |
|
|
201
|
+
| control_toBool | next → output-0, prediction → output-1 | prev → input-0, value → input-1 |
|
|
202
|
+
| control_agent_toBool | next → output-0, prediction → output-1 | prev → input-0, value → input-1 |
|
|
203
|
+
| control_anyOne | next → output-0 | prev1 → input-0, prev2 → input-1 |
|
|
204
|
+
| tool_load_key | next → output-0, result → output-1 | prev → input-0, key → input-1 |
|
|
205
|
+
| tool_save_key | next → output-0 | prev → input-0, key → input-1, value → input-2 |
|
|
206
|
+
| tool_get_env | value → output-0 | key → input-0 |
|
|
207
|
+
|
|
208
|
+
**ToBool → If**:`output-1` → `input-1`(prediction)。**If**:`output-0` = 真分支,`output-1` = 假分支。
|
|
209
|
+
|
|
210
|
+
更多见 `reference/flow-control-capabilities.md` 第 8 节。
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## 新增节点的 `ui.nodePositions`:放在屏幕中间
|
|
215
|
+
|
|
216
|
+
目标:新节点出现在画布**视区中心附近**,避免默认 (0,0) 挤在角落或与旧图重叠。
|
|
217
|
+
|
|
218
|
+
- **单个新节点**:使用中心基准,例如 **`x: 400`**、**`y: 300`**(可按项目里现有节点的 x/y 范围微调;若已有图,可取现有 `nodePositions` 的 **x、y 中位数** 作为中心再落点)。
|
|
219
|
+
- **多个新节点(主链/线性)**:主链节点从左到右排列,每个节点 **x 递增 280**,y 保持一致:
|
|
220
|
+
`x: 100 + i * 280`,`y: 300`。
|
|
221
|
+
- **分支节点**:分支的不同路径在 y 方向**错开 200**,例如 if 的两路分别 `y: 200` 和 `y: 400`。
|
|
222
|
+
- **并行节点**:并行的节点保持相同 x,y 方向每个错开 200。
|
|
223
|
+
- 后续若要融入主链/分支布局,再按 `reference/flow-layout.md` 做 x 递进、y 错开。
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## 连线(仅用户明确要求时)
|
|
228
|
+
|
|
229
|
+
**Fan-out / Fan-in 规则**:
|
|
230
|
+
- **一个 output 可连多个 input**(fan-out 允许)。
|
|
231
|
+
- **一个 input 只能有一条入边**(fan-in 禁止)。同一个 `target + targetHandle` 不得出现在多条 edge 中;若需替换连线,先删旧边再加新边。违反此规则会导致运行时只有一条边生效,其余静默丢失。
|
|
232
|
+
|
|
233
|
+
**中间插入**:删 `A → B`,改为 `A → N`(N 的 `input-0`)、`N → B`(保持原 handle 语义)。
|
|
234
|
+
**追加到 End**:删 `X → control_end`,改为 `X → Y → control_end`(常见 `output-0` / `input-0`)。
|
|
235
|
+
**If 分支**:增加 `control_toBool`(确定性)或 `control_agent_toBool`(AI 判断)+ `control_if`,prediction 边与两条分支出边按上表连接。
|
|
236
|
+
|
|
237
|
+
完整图示例:`builtin/pipelines/new/flow.yaml`。
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
## 保存后同步 Web UI
|
|
242
|
+
|
|
243
|
+
将 `flow.yaml` 写入磁盘后,在 **Web UI + Composer** 场景下应通知浏览器刷新画布,见 `skills/agentflow-flow-sync-ui/SKILL.md`。
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
## 安装(vercel-labs [skills](https://github.com/vercel-labs/skills))
|
|
248
|
+
|
|
249
|
+
在 AgentFlow 仓库根目录:
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
npx skills add ./skills --agent cursor --skill agentflow-flow-add-instances -y
|
|
253
|
+
# 或安装本包全部技能:
|
|
254
|
+
npx skills add ./skills --agent cursor -y
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
项目内默认 **`.agents/skills/`**;全局加 **`-g`** → **`~/.cursor/skills/`**。
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agentflow-flow-edit-node-fields
|
|
3
|
+
description: >-
|
|
4
|
+
仅修改 AgentFlow flow.yaml 中已有实例的允许字段(label、body、role、
|
|
5
|
+
input/output 的 value 等);禁止改 definitionId、instanceId、IO 结构与顺序、
|
|
6
|
+
不增删边与实例。用于改文案、占位符、角色标签而不破坏图拓扑与 handle。
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# AgentFlow:仅修改已有节点(白名单字段)
|
|
10
|
+
|
|
11
|
+
在 **不增加/删除节点与边、不改编译拓扑** 的前提下,修改一个或多个 **已有** `instances` 条目时使用本技能。
|
|
12
|
+
|
|
13
|
+
**路径说明**:`npx skills add` 后本文件不在 AgentFlow 仓库内;`reference/` 相对 **AgentFlow 仓库根目录**。
|
|
14
|
+
|
|
15
|
+
**权威参考**:`reference/flow-control-capabilities.md`(内置 description 语义)、`reference/flow-prompt-handler-check.md`(改 `body` 后与图一致)。
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## 允许修改的字段(白名单)
|
|
20
|
+
|
|
21
|
+
对每个已存在的 **`<instanceId>`** 块,**仅**可改下列内容:
|
|
22
|
+
|
|
23
|
+
| 字段 | 说明 |
|
|
24
|
+
|------|------|
|
|
25
|
+
| **`label`** | 画布显示名 |
|
|
26
|
+
| **`role`** | 角色分类字符串 |
|
|
27
|
+
| **`body`** | 节点用户区正文(agent 任务描述等);改后核对与边的数据流是否仍一致 |
|
|
28
|
+
| **`script`** | **仅限 `definitionId: tool_nodejs`**——实际执行的 shell/node 命令(`body` 有 script 时不执行)。必须写完整可执行命令,禁止写自然语言 |
|
|
29
|
+
| **`input[].value`** | 各输入槽的默认值 / 占位路径 / 字面量(**不改** 该项的 `type`、`name`) |
|
|
30
|
+
| **`output[].value`** | 各输出槽默认值(**不改** `type`、`name`) |
|
|
31
|
+
|
|
32
|
+
### tool_nodejs 特殊规则(关键)
|
|
33
|
+
|
|
34
|
+
`definitionId: tool_nodejs` 的节点**核心是 `script` 字段**,不是 `body`:
|
|
35
|
+
- **`script`**:流水线直接执行的命令代码,stdout 作为 result,exit code 决定成败
|
|
36
|
+
- **`body`**:有 `script` 时仅作为人类可读的注释说明,**不会被执行**
|
|
37
|
+
- **禁止** `tool_nodejs` 只有 `body` 没有 `script`——自然语言描述不会被执行,节点必定失败
|
|
38
|
+
- 如果无法写出完整可执行的 `script`,必须把 `definitionId` 改为 `agent_subAgent`(此变更不在本技能范围,需用 `agentflow-flow-add-instances` 技能)
|
|
39
|
+
|
|
40
|
+
**`instances.*.description`** 已废弃:不要在 flow.yaml 中写入;agent 系统说明以 **`definitionId` 对应节点定义 `.md`** 的 frontmatter **`description`** 为准。需要补充说明性文字时用 **`body`** 或 **`label`**。
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## 禁止修改(黑名单)
|
|
45
|
+
|
|
46
|
+
- **`definitionId`**:换类型会错 handle,须走「新增实例 + 删旧实例 + 改边」流程,**不在**本技能范围。
|
|
47
|
+
- **`instanceId` 键名**:改名必须同步改 **所有 `edges` 的 source/target** 与 **`ui.nodePositions` 键**,否则图断裂;**不在**本技能范围。
|
|
48
|
+
- **`input` / `output` 数组**:不得 **增删条目**、**改顺序**、**改 `name` / `type`**(会导致 `input-0` / `output-1` 与边不对应)。
|
|
49
|
+
- **`edges`**:不得增删改(含 `sourceHandle` / `targetHandle`)。
|
|
50
|
+
- **新增或删除整个 instance 块**:使用技能 **`agentflow-flow-add-instances`** 或其它流程。
|
|
51
|
+
- **`ui.nodePositions`**:本技能默认 **不** 改;仅当用户明确要求「只动坐标」时可单独改对应 instance 的 `x` / `y`,且 **不** 改其它字段。
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## 操作建议
|
|
56
|
+
|
|
57
|
+
1. 用搜索定位目标 **`instanceId`**,只改上表白名单字段。
|
|
58
|
+
2. 修改 **`body`** 或 **`value`** 后,若涉及「读哪些文件 / 写哪些结果」,对照 **`reference/flow-prompt-handler-check.md`**,确保仍与当前 **edges** 上的 handler 一致(本技能不改边,但若文案宣称的读写与图不符,应提示用户需另改图)。
|
|
59
|
+
3. 批量改多个节点时,对每个实例重复上述约束,**不要**顺带重构 YAML 结构。
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## 保存后同步 Web UI
|
|
64
|
+
|
|
65
|
+
将 `flow.yaml` 写入磁盘后,在 **Web UI + Composer** 场景下应通知浏览器刷新画布,见 `skills/agentflow-flow-sync-ui/SKILL.md`。
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## 安装(vercel-labs [skills](https://github.com/vercel-labs/skills))
|
|
70
|
+
|
|
71
|
+
在 AgentFlow 仓库根目录:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npx skills add ./skills --agent cursor --skill agentflow-flow-edit-node-fields -y
|
|
75
|
+
# 或安装本包全部技能:
|
|
76
|
+
npx skills add ./skills --agent cursor -y
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
项目内默认 **`.agents/skills/`**;全局加 **`-g`**。
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agentflow-flow-recipes
|
|
3
|
+
description: >-
|
|
4
|
+
AgentFlow 常见流程模板。用于新建 Git 项目分析、加载项目 skills、打印结果、
|
|
5
|
+
以及组合 Git Checkout → CD Workspace → Load Skills → Agent → Print 的标准流水线。
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# AgentFlow Flow Recipes
|
|
9
|
+
|
|
10
|
+
使用本技能处理这些问题:
|
|
11
|
+
|
|
12
|
+
- 用户要求“新建流水线拉仓库、cd 进去、让 agent 分析、print 结果”。
|
|
13
|
+
- 需要把 Git 项目作为工作区分析,并可加载项目自身 skills。
|
|
14
|
+
- 需要避免临场猜 slot/handle,按标准 recipe 搭图。
|
|
15
|
+
|
|
16
|
+
## 必读规则
|
|
17
|
+
|
|
18
|
+
- 读 [recipes.md](references/recipes.md)。
|
|
19
|
+
- Git 项目分析的标准链路是:`Start → Git Checkout → CD Workspace → Load Skills → Agent → Print → End`。
|
|
20
|
+
- `tool_print.content` 应接 agent 输出内容;没有接 content 时才 fallback 打印上游 result。
|
|
21
|
+
|
|
22
|
+
## Reference
|
|
23
|
+
|
|
24
|
+
- [Flow recipes](references/recipes.md)
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# AgentFlow Flow Recipes
|
|
2
|
+
|
|
3
|
+
## Git Project Analysis
|
|
4
|
+
|
|
5
|
+
Use when the user asks to clone/pull a repository, enter it, ask an agent what it does, and print the result.
|
|
6
|
+
|
|
7
|
+
Recommended graph:
|
|
8
|
+
|
|
9
|
+
```text
|
|
10
|
+
control_start
|
|
11
|
+
-> tool_git_checkout
|
|
12
|
+
-> control_cd_workspace
|
|
13
|
+
-> control_load_skills
|
|
14
|
+
-> agent_subAgent
|
|
15
|
+
-> tool_print
|
|
16
|
+
-> control_end
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Minimum required values:
|
|
20
|
+
|
|
21
|
+
- `tool_git_checkout.repoUrl`: repository URL.
|
|
22
|
+
- `tool_git_checkout.pullIfExists`: `true`.
|
|
23
|
+
- `tool_git_checkout.includeSubmodules`: `true` only when the user asks to pull submodules.
|
|
24
|
+
- `control_cd_workspace.target`: `.`.
|
|
25
|
+
- `control_load_skills.source`: `all` or `current-workspace`.
|
|
26
|
+
- `agent_subAgent.body`: ask the agent to inspect README, package/build files, source directories, and entry points.
|
|
27
|
+
- `tool_print.content`: connect from the agent output content.
|
|
28
|
+
|
|
29
|
+
Required context edges:
|
|
30
|
+
|
|
31
|
+
- Git Checkout `next` -> CD Workspace `prev`
|
|
32
|
+
- Git Checkout `workspaceContext` -> CD Workspace `workspaceContext`
|
|
33
|
+
- CD Workspace `next` -> Load Skills `prev`
|
|
34
|
+
- CD Workspace `workspaceContext` -> Load Skills `workspaceContext`
|
|
35
|
+
- Load Skills `next` -> Agent `prev`
|
|
36
|
+
- CD Workspace `workspaceContext` -> Agent `workspaceContext`
|
|
37
|
+
- Load Skills `skillsContext` -> Agent `skillsContext`
|
|
38
|
+
- Agent content output -> Print `content`
|
|
39
|
+
- Print `next` -> End `prev`
|
|
40
|
+
|
|
41
|
+
Notes:
|
|
42
|
+
|
|
43
|
+
- Do not connect `repoPath:file` to CD `target:text`.
|
|
44
|
+
- If the agent node has no custom file output slot, use its result body and let Print fallback, or add a text/file output slot intentionally.
|
|
45
|
+
- For private/internal Git repositories, local credentials must already work.
|
|
46
|
+
|
|
47
|
+
## Edit Current Flow
|
|
48
|
+
|
|
49
|
+
Use existing flow editing skills:
|
|
50
|
+
|
|
51
|
+
- New nodes/edges: `agentflow-flow-add-instances`
|
|
52
|
+
- Existing node text/value edits only: `agentflow-flow-edit-node-fields`
|
|
53
|
+
- After saving in UI Composer: `agentflow-flow-sync-ui`
|
|
54
|
+
|
|
55
|
+
## Print Result
|
|
56
|
+
|
|
57
|
+
Prefer explicit content:
|
|
58
|
+
|
|
59
|
+
```text
|
|
60
|
+
agent.output.summary -> tool_print.input.content
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Fallback behavior exists, but explicit content keeps the graph self-documenting.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agentflow-flow-sync-ui
|
|
3
|
+
description: >-
|
|
4
|
+
在 AgentFlow Web UI + Composer 场景下,将 flow.yaml 保存到磁盘后通知本地 UI 刷新画布;
|
|
5
|
+
使用 POST /api/flow-editor-sync(端口以 Composer 系统提示中的 URL 为准)。
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# AgentFlow:保存 flow.yaml 后同步 Web 画布
|
|
9
|
+
|
|
10
|
+
在 **已通过 Composer 编辑当前流水线**(系统提示里已注入 `flowId`、`flowSource`、UI 端口)且 **本机正在运行 `agentflow ui`** 时使用。
|
|
11
|
+
|
|
12
|
+
## 何时执行
|
|
13
|
+
|
|
14
|
+
每次对当前流水线的 **`flow.yaml` 做完增删改并已写入磁盘** 后执行 **一次**(含多次保存中的最后一次完成后)。
|
|
15
|
+
|
|
16
|
+
## 做什么
|
|
17
|
+
|
|
18
|
+
向本地 Web UI 发通知,让已打开该流水线的浏览器通过 SSE 重拉 `GET /api/flow`(与手动切换流水线效果一致,但保留 Composer 对话区)。
|
|
19
|
+
|
|
20
|
+
在终端执行(**必须与系统提示中的 `flowId`、`flowSource`、`端口` 一致**;以下占位符在 Composer 上下文中会给出**可复制的一行命令**):
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
curl -sS -X POST http://127.0.0.1:<PORT>/api/flow-editor-sync \
|
|
24
|
+
-H 'Content-Type: application/json' \
|
|
25
|
+
-d '{"flowId":"<flowId>","flowSource":"user"}'
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
`flowSource` 取值:
|
|
29
|
+
|
|
30
|
+
- `user`:用户目录 `~/agentflow/pipelines`(或 `AGENTFLOW_HOME`)下的该流水线
|
|
31
|
+
- `workspace`:当前项目下 `.workspace/agentflow/pipelines` 下的该流水线(仍会读取旧路径 `.cursor/agentflow/pipelines`)。同项目内 **nodes** 以 `.workspace/agentflow/nodes` 为主(可读 `.cursor/agentflow/nodes`);**models.json** 以 `.workspace/agentflow/models.json` 为主(可读 `.cursor` 下旧文件)。
|
|
32
|
+
- `builtin`:包内 `builtin/pipelines` 模板(只读;若实际写入的是工作区副本,须用 `workspace` 触发刷新)
|
|
33
|
+
|
|
34
|
+
## 等价的 Node one-liner(无 curl 时)
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
node -e "fetch('http://127.0.0.1:<PORT>/api/flow-editor-sync',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({flowId:'<flowId>',flowSource:'user'})}).then(r=>r.text()).then(console.log)"
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
(将 `<PORT>`、`<flowId>`、`flowSource` 换成实际值。)
|
|
41
|
+
|
|
42
|
+
## 注意
|
|
43
|
+
|
|
44
|
+
- 仅 **127.0.0.1** 本地 UI;未启动 UI 时请求会失败,可忽略(Composer 正常结束时前端仍会兜底重拉图一次)。
|
|
45
|
+
- 本操作**不**写入 YAML,只触发刷新;请勿用其代替保存文件。
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## 安装(vercel-labs [skills](https://github.com/vercel-labs/skills))
|
|
50
|
+
|
|
51
|
+
在 AgentFlow 仓库根目录:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npx skills add ./skills --agent cursor --skill agentflow-flow-sync-ui -y
|
|
55
|
+
# 或安装本包全部技能:
|
|
56
|
+
npx skills add ./skills --agent cursor -y
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
项目内默认 **`.agents/skills/`**;全局加 **`-g`** → **`~/.cursor/skills/`**。
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agentflow-node-reference
|
|
3
|
+
description: >-
|
|
4
|
+
AgentFlow 内置节点参考。用于选择节点类型、确认 builtin node 的 input/output 槽位、
|
|
5
|
+
判断 local-only/script/agent 执行方式,以及避免 handle 类型和顺序接错。
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# AgentFlow Node Reference
|
|
9
|
+
|
|
10
|
+
使用本技能处理这些问题:
|
|
11
|
+
|
|
12
|
+
- 选择 `agent_subAgent`、`tool_nodejs`、`tool_git_checkout`、`control_cd_workspace`、`tool_print` 等节点。
|
|
13
|
+
- 创建或修改 flow 时需要确认 input/output 名称、类型、顺序和 handle 索引。
|
|
14
|
+
- 判断节点是否 local-only,是否会调用 agent,是否需要 `script`。
|
|
15
|
+
|
|
16
|
+
## 必读规则
|
|
17
|
+
|
|
18
|
+
- 先读 [builtin-nodes.md](references/builtin-nodes.md),再改 `flow.yaml` 的 `definitionId`、`input`、`output` 或 `edges`。
|
|
19
|
+
- `input-N` / `output-N` 必须与节点定义中的槽位顺序一致。
|
|
20
|
+
- `tool_nodejs` 只有写了完整 `script` 才会确定性执行;自然语言任务用 `agent_subAgent`。
|
|
21
|
+
- local-only 节点由 AgentFlow runtime 执行,不会调用 agent。
|
|
22
|
+
|
|
23
|
+
## Reference
|
|
24
|
+
|
|
25
|
+
- [Builtin nodes reference](references/builtin-nodes.md)
|