@fieldwangai/agentflow 0.1.25

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.
Files changed (138) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +201 -0
  3. package/README.zh-CN.md +201 -0
  4. package/agents/agentflow-node-executor-code.md +32 -0
  5. package/agents/agentflow-node-executor-planning.md +32 -0
  6. package/agents/agentflow-node-executor-requirement.md +32 -0
  7. package/agents/agentflow-node-executor-test.md +32 -0
  8. package/agents/agentflow-node-executor-ui.md +32 -0
  9. package/agents/agentflow-node-executor.md +32 -0
  10. package/agents/agents.json +8 -0
  11. package/agents/en/agentflow-node-executor.md +32 -0
  12. package/agents/zh/agentflow-node-executor.md +32 -0
  13. package/bin/agentflow.mjs +52 -0
  14. package/bin/ensure-workspace-reference.mjs +35 -0
  15. package/bin/lib/agent-runners.mjs +1199 -0
  16. package/bin/lib/agents-path.mjs +61 -0
  17. package/bin/lib/api-runner.mjs +361 -0
  18. package/bin/lib/apply.mjs +852 -0
  19. package/bin/lib/catalog-agents.mjs +300 -0
  20. package/bin/lib/catalog-flows.mjs +532 -0
  21. package/bin/lib/composer-agent.mjs +884 -0
  22. package/bin/lib/composer-flow-instances.mjs +68 -0
  23. package/bin/lib/composer-flow-skeleton.mjs +334 -0
  24. package/bin/lib/composer-flow-validate.mjs +47 -0
  25. package/bin/lib/composer-log.mjs +197 -0
  26. package/bin/lib/composer-model-router.mjs +160 -0
  27. package/bin/lib/composer-node-schema.mjs +299 -0
  28. package/bin/lib/composer-planner.mjs +749 -0
  29. package/bin/lib/composer-script-ops.mjs +233 -0
  30. package/bin/lib/composer-skill-router.mjs +384 -0
  31. package/bin/lib/flow-import.mjs +305 -0
  32. package/bin/lib/flow-normalize.mjs +71 -0
  33. package/bin/lib/flow-write.mjs +395 -0
  34. package/bin/lib/help.mjs +139 -0
  35. package/bin/lib/hub-login.mjs +54 -0
  36. package/bin/lib/hub-publish.mjs +159 -0
  37. package/bin/lib/hub-remote.mjs +189 -0
  38. package/bin/lib/hub.mjs +299 -0
  39. package/bin/lib/i18n.mjs +233 -0
  40. package/bin/lib/locales/en.json +344 -0
  41. package/bin/lib/locales/zh.json +344 -0
  42. package/bin/lib/log.mjs +37 -0
  43. package/bin/lib/main.mjs +611 -0
  44. package/bin/lib/model-config.mjs +118 -0
  45. package/bin/lib/model-lists.mjs +188 -0
  46. package/bin/lib/node-exec-context.mjs +336 -0
  47. package/bin/lib/node-execute.mjs +513 -0
  48. package/bin/lib/normalize-node-tool-command.mjs +97 -0
  49. package/bin/lib/paths.mjs +216 -0
  50. package/bin/lib/pipeline-scripts.mjs +41 -0
  51. package/bin/lib/recent-runs.mjs +173 -0
  52. package/bin/lib/run-apply-active-lock.mjs +82 -0
  53. package/bin/lib/run-events.mjs +85 -0
  54. package/bin/lib/run-node-statuses-from-disk.mjs +85 -0
  55. package/bin/lib/schedule-config.mjs +227 -0
  56. package/bin/lib/scheduler.mjs +312 -0
  57. package/bin/lib/table.mjs +4 -0
  58. package/bin/lib/terminal.mjs +42 -0
  59. package/bin/lib/ui-print.mjs +94 -0
  60. package/bin/lib/ui-server.mjs +2113 -0
  61. package/bin/lib/workspace-tree.mjs +266 -0
  62. package/bin/lib/workspace.mjs +180 -0
  63. package/bin/pipeline/build-node-prompt.mjs +179 -0
  64. package/bin/pipeline/check-cache.mjs +191 -0
  65. package/bin/pipeline/check-flow.mjs +543 -0
  66. package/bin/pipeline/collect-nodes.mjs +212 -0
  67. package/bin/pipeline/compute-cache-md5.mjs +177 -0
  68. package/bin/pipeline/ensure-run-dir.mjs +71 -0
  69. package/bin/pipeline/extract-thinking.mjs +308 -0
  70. package/bin/pipeline/gc.mjs +129 -0
  71. package/bin/pipeline/get-env.mjs +83 -0
  72. package/bin/pipeline/get-exec-id.mjs +145 -0
  73. package/bin/pipeline/get-ready-nodes.mjs +435 -0
  74. package/bin/pipeline/get-resolved-values.mjs +337 -0
  75. package/bin/pipeline/load-key.mjs +62 -0
  76. package/bin/pipeline/parse-bool.mjs +33 -0
  77. package/bin/pipeline/parse-flow.mjs +698 -0
  78. package/bin/pipeline/post-process-control-if.mjs +23 -0
  79. package/bin/pipeline/post-process-node.mjs +490 -0
  80. package/bin/pipeline/pre-process-node.mjs +449 -0
  81. package/bin/pipeline/resolve-inputs.mjs +201 -0
  82. package/bin/pipeline/run-log.mjs +34 -0
  83. package/bin/pipeline/run-tool-nodejs.mjs +160 -0
  84. package/bin/pipeline/save-key.mjs +93 -0
  85. package/bin/pipeline/snapshot-prior-round.mjs +70 -0
  86. package/bin/pipeline/validate-flow.mjs +825 -0
  87. package/bin/pipeline/validate-for-ui.mjs +226 -0
  88. package/bin/pipeline/validate-script-output.mjs +130 -0
  89. package/bin/pipeline/write-result.mjs +182 -0
  90. package/builtin/nodes/agent_subAgent.md +14 -0
  91. package/builtin/nodes/control_agent_toBool.md +20 -0
  92. package/builtin/nodes/control_anyOne.md +17 -0
  93. package/builtin/nodes/control_end.md +11 -0
  94. package/builtin/nodes/control_if.md +20 -0
  95. package/builtin/nodes/control_start.md +11 -0
  96. package/builtin/nodes/control_toBool.md +21 -0
  97. package/builtin/nodes/provide_file.md +11 -0
  98. package/builtin/nodes/provide_str.md +11 -0
  99. package/builtin/nodes/tool_get_env.md +14 -0
  100. package/builtin/nodes/tool_load_key.md +20 -0
  101. package/builtin/nodes/tool_nodejs.md +40 -0
  102. package/builtin/nodes/tool_print.md +14 -0
  103. package/builtin/nodes/tool_save_key.md +20 -0
  104. package/builtin/nodes/tool_user_ask.md +23 -0
  105. package/builtin/nodes/tool_user_check.md +22 -0
  106. package/builtin/pipelines/module-migrate/flow.yaml +819 -0
  107. package/builtin/pipelines/module-migrate/scripts/check_imports.mjs +700 -0
  108. package/builtin/pipelines/module-migrate/scripts/node_modules/tree-sitter-kotlin/build/Makefile +362 -0
  109. package/builtin/pipelines/module-migrate/scripts/node_modules/tree-sitter-kotlin/build/Release/.deps/Release/obj.target/node_modules/node-addon-api/node_addon_api_except.stamp.d +1 -0
  110. package/builtin/pipelines/module-migrate/scripts/node_modules/tree-sitter-kotlin/build/Release/.deps/Release/obj.target/tree_sitter_kotlin_binding/bindings/node/binding.o.d +17 -0
  111. package/builtin/pipelines/module-migrate/scripts/node_modules/tree-sitter-kotlin/build/Release/.deps/Release/obj.target/tree_sitter_kotlin_binding/src/parser.o.d +5 -0
  112. package/builtin/pipelines/module-migrate/scripts/node_modules/tree-sitter-kotlin/build/Release/.deps/Release/obj.target/tree_sitter_kotlin_binding/src/scanner.o.d +8 -0
  113. package/builtin/pipelines/module-migrate/scripts/node_modules/tree-sitter-kotlin/build/Release/.deps/Release/tree_sitter_kotlin_binding.node.d +1 -0
  114. package/builtin/pipelines/module-migrate/scripts/node_modules/tree-sitter-kotlin/build/Release/obj.target/node_modules/node-addon-api/node_addon_api_except.stamp +0 -0
  115. package/builtin/pipelines/module-migrate/scripts/node_modules/tree-sitter-kotlin/build/Release/obj.target/tree_sitter_kotlin_binding/bindings/node/binding.o +0 -0
  116. package/builtin/pipelines/module-migrate/scripts/node_modules/tree-sitter-kotlin/build/Release/obj.target/tree_sitter_kotlin_binding/src/parser.o +0 -0
  117. package/builtin/pipelines/module-migrate/scripts/node_modules/tree-sitter-kotlin/build/Release/obj.target/tree_sitter_kotlin_binding/src/scanner.o +0 -0
  118. package/builtin/pipelines/module-migrate/scripts/node_modules/tree-sitter-kotlin/build/Release/tree_sitter_kotlin_binding.node +0 -0
  119. package/builtin/pipelines/module-migrate/scripts/node_modules/tree-sitter-kotlin/build/binding.Makefile +6 -0
  120. package/builtin/pipelines/module-migrate/scripts/node_modules/tree-sitter-kotlin/build/gyp-mac-tool +768 -0
  121. package/builtin/pipelines/module-migrate/scripts/node_modules/tree-sitter-kotlin/build/node_modules/node-addon-api/node_addon_api.Makefile +6 -0
  122. package/builtin/pipelines/module-migrate/scripts/node_modules/tree-sitter-kotlin/build/node_modules/node-addon-api/node_addon_api.target.mk +122 -0
  123. package/builtin/pipelines/module-migrate/scripts/node_modules/tree-sitter-kotlin/build/node_modules/node-addon-api/node_addon_api_except.target.mk +126 -0
  124. package/builtin/pipelines/module-migrate/scripts/node_modules/tree-sitter-kotlin/build/node_modules/node-addon-api/node_addon_api_maybe.target.mk +122 -0
  125. package/builtin/pipelines/module-migrate/scripts/node_modules/tree-sitter-kotlin/build/tree_sitter_kotlin_binding.target.mk +203 -0
  126. package/builtin/pipelines/new/flow.yaml +545 -0
  127. package/builtin/pipelines/new/scripts/check-flow.mjs +9 -0
  128. package/builtin/pipelines/new/scripts/collect-nodes.mjs +211 -0
  129. package/builtin/pipelines/scripts/adjust-node-positions.mjs +113 -0
  130. package/builtin/web-ui/dist/agentflow-icon.svg +23 -0
  131. package/builtin/web-ui/dist/assets/index-CZkUPcXE.css +1 -0
  132. package/builtin/web-ui/dist/assets/index-DkkhNESc.js +190 -0
  133. package/builtin/web-ui/dist/index.html +24 -0
  134. package/package.json +67 -0
  135. package/reference/flow-control-capabilities.md +274 -0
  136. package/reference/flow-layout.md +84 -0
  137. package/reference/flow-prompt-handler-check.md +12 -0
  138. package/reference/flow-result-semantics.md +14 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AgentFlow Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,201 @@
1
+ <p align="center">
2
+ <img src="logo-256.png" width="128" alt="AgentFlow Logo" />
3
+ </p>
4
+
5
+ <h1 align="center">AgentFlow</h1>
6
+
7
+ <p align="center">Let your AI agents work 12 hours straight — then quietly blow everyone away</p>
8
+
9
+ <p align="center">
10
+ <a href="./LICENSE"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT" /></a>
11
+ <a href="https://agentflow-hub.com"><img src="https://img.shields.io/badge/Hub-Browse%20Flows-8252ec" alt="AgentFlow Hub" /></a>
12
+ </p>
13
+
14
+ <p align="center">
15
+ <a href="./README.zh-CN.md">中文</a> | <b>English</b>
16
+ </p>
17
+
18
+ >
19
+ > Orchestrate complex, long-running tasks — module migrations, AI automation, deep code cleanup — using Cursor / OpenCode / Claude Code as swappable backends.
20
+
21
+ ![AgentFlow Projects](docs/projects.png)
22
+
23
+ ![Pipeline Editor](docs/pipeline.png)
24
+
25
+ ![Running Status](docs/running.png)
26
+
27
+ ## The Problem
28
+
29
+ Coding agents like Cursor and Claude Code are great — until the task gets long.
30
+
31
+ **1. Context window is a hard ceiling.**
32
+ A 10-minute task fits comfortably. A 10-hour migration? The model starts forgetting earlier steps, repeating work, or silently drifting off course. Context compression helps, but it's lossy — the agent no longer has the full picture.
33
+
34
+ **2. Process reliability degrades with length.**
35
+ You tell the agent: "after step 1, ask me to confirm; after step 2, run tests." It works the first few times. Three hours in, the confirmation step gets compressed away and the agent just... skips it. This is the same class of problem that caused [an AI to delete a user's emails](https://www.reddit.com/r/ChatGPTPro/comments/1kcra9d/) — not malice, just lost context.
36
+
37
+ **3. Markdown checklists aren't control flow.**
38
+ You can write a numbered plan in a prompt, but you can't express "loop until compilation passes" or "if tests fail, go back to step 3." Real workflows need real branches and loops — not a flat list that the model interprets however it wants.
39
+
40
+ **AgentFlow fixes this by moving orchestration out of the context window.** Workflows are defined as node graphs with explicit edges, loops, and conditionals. Each node runs in a fresh agent session with only its own inputs — no context to degrade. State is persisted to disk between nodes, so a 10-hour workflow is just a sequence of focused 10-minute tasks.
41
+
42
+ ## Features
43
+
44
+ - **Reuse your AI subscriptions** — Cursor Pro, OpenCode (Alibaba Cloud, etc.), Claude Code; no need to purchase LLM API keys
45
+ - **Visual editor + AI Composer** — drag-and-drop nodes or describe workflows in natural language
46
+ - **Persistent state** — every node's I/O cached to disk (like Gradle task caching); resume from any failure point
47
+ - **Loop / branch / parallel** — `control_if`, `control_anyOne`, `control_toBool` for real control flow
48
+ - **CI/CD ready** — deterministic graphs, long-running, `--machine-readable` JSON event stream
49
+
50
+ ## Quick Start
51
+
52
+ **Requirements:** Node >= 18, one of: Cursor CLI (`agent`), OpenCode CLI, or Claude Code
53
+
54
+ ```bash
55
+ # Install
56
+ npm install -g @fieldwangai/agentflow
57
+
58
+ # Launch Web UI (port 8765)
59
+ agentflow ui
60
+
61
+ # Or run a flow directly
62
+ agentflow apply <FlowName>
63
+ ```
64
+
65
+ From source: `git clone` → `npm install` → `npm link`.
66
+
67
+ ## AgentFlow Hub
68
+
69
+ Browse, download and share community-built workflows at **[agentflow-hub.com](https://agentflow-hub.com)**.
70
+
71
+ ```bash
72
+ # Browse flows from the command line
73
+ agentflow list-remote
74
+
75
+ # Download a flow
76
+ agentflow download <slug>
77
+
78
+ # Publish your flow to the Hub
79
+ agentflow login
80
+ agentflow publish <FlowName> --tags "migration,review"
81
+ ```
82
+
83
+ ## Creating Flows
84
+
85
+ ### Option A: Visual Editor
86
+
87
+ In the Web UI — create pipeline → drag nodes from palette → connect edges → save.
88
+
89
+ ### Option B: AI Composer (recommended)
90
+
91
+ Open the right-side Composer panel and describe what you need:
92
+
93
+ ```
94
+ Create a code review flow:
95
+ 1. Scan the codebase for issues
96
+ 2. Auto-fix issues
97
+ 3. Re-check
98
+ 4. Loop until all pass
99
+ ```
100
+
101
+ Composer auto-detects loop patterns and generates the correct control-flow nodes. Complex flows are built in three phases: topology → node details → wiring & validation (auto-repairs up to 5 times).
102
+
103
+ ## Running & Recovery
104
+
105
+ ```bash
106
+ # Execute
107
+ agentflow apply <FlowName>
108
+
109
+ # Check status
110
+ agentflow run-status <FlowName> <uuid>
111
+
112
+ # Resume from failure
113
+ agentflow resume <FlowName> <uuid>
114
+
115
+ # Retry one node
116
+ agentflow replay <FlowName> <uuid> <instanceId>
117
+
118
+ # View agent reasoning
119
+ agentflow extract-thinking <FlowName> <uuid>
120
+ ```
121
+
122
+ ## Skills
123
+
124
+ AgentFlow provides specialized skills for common operations:
125
+
126
+ | Skill | Description |
127
+ |-------|-------------|
128
+ | `agentflow-flow-add-instances` | Add new nodes to flow.yaml with proper YAML structure, connection design, and positioning |
129
+ | `agentflow-flow-edit-node-fields` | Edit allowed fields in existing nodes (label, body, role, input/output values) without breaking topology |
130
+ | `agentflow-flow-sync-ui` | Sync flow.yaml changes to Web UI canvas after saving to disk |
131
+ | `nestjs-route-order-debug` | Debug NestJS route conflicts between parameter routes (`:id`) and concrete routes |
132
+
133
+ Skills are automatically loaded when relevant tasks are detected, providing domain-specific instructions and workflows.
134
+
135
+ ## Tutorials
136
+
137
+ - [Quickstart: PR Workflow Automation](docs/wiki/quickstart-pr-workflow.en.md)
138
+ - [Module Migration Workflow](docs/wiki/module-migration-workflow.en.md)
139
+ - [Figma UI Implementation Workflow](docs/wiki/figma-ui-implementation-workflow.en.md)
140
+
141
+ ## CLI Reference
142
+
143
+ | Command | Description |
144
+ |---------|-------------|
145
+ | `list` | List all pipelines |
146
+ | `ui` | Start Web UI |
147
+ | `apply` | Execute flow |
148
+ | `validate` | Validate flow structure |
149
+ | `resume` | Resume from breakpoint |
150
+ | `replay` | Retry a single node |
151
+ | `run-status` | View execution status |
152
+ | `extract-thinking` | Extract agent thinking process |
153
+
154
+ ### Options
155
+
156
+ | Flag | Description |
157
+ |------|-------------|
158
+ | `--workspace-root <path>` | Workspace root directory |
159
+ | `--dry-run` | Preview ready nodes without execution |
160
+ | `--model <name>` | Override model |
161
+ | `--parallel` | Parallel execution for independent nodes |
162
+ | `--machine-readable` | JSON event stream (for UI/CI integration) |
163
+ | `--lang <code>` | Language (`zh` / `en`) |
164
+
165
+ ### Environment Variables
166
+
167
+ | Variable | Default | Description |
168
+ |----------|---------|-------------|
169
+ | `CURSOR_AGENT_CMD` | `agent` | Cursor CLI command |
170
+ | `CURSOR_AGENT_MODEL` | — | Default model |
171
+ | `OPENCODE_CMD` | `opencode` | OpenCode CLI command |
172
+ | `CLAUDE_CODE_CMD` | `claude` | Claude Code CLI command |
173
+ | `AGENTFLOW_CLAUDE_CODE_BYPASS_PERMISSIONS` | `1` | Pass `--dangerously-skip-permissions` to Claude Code; set `0` for interactive approval |
174
+ | `AGENTFLOW_CLAUDE_CODE_STDERR_INHERIT` | `0` | Forward Claude Code stderr directly to terminal for debugging |
175
+ | `AGENTFLOW_HOME` | `~/agentflow` | User data directory |
176
+
177
+ ## Directory Layout
178
+
179
+ ```
180
+ ~/agentflow/ # User data (pipelines, agents, config)
181
+ <workspace>/.workspace/agentflow/
182
+ ├── pipelines/<flowId>/ # Project-local pipeline copies
183
+ ├── nodes/ # Custom node definitions
184
+ └── runBuild/<flowId>/<uuid>/ # Run artifacts & per-node status
185
+ ```
186
+
187
+ ## i18n
188
+
189
+ - CLI: `--lang` flag or `LANG` env
190
+ - Web UI: auto-detects browser language
191
+ - Agent prompts: `agents/<lang>/` directory
192
+
193
+ Supported: `zh` (中文), `en` (English)
194
+
195
+ ## Contributing
196
+
197
+ See [CONTRIBUTING.en.md](CONTRIBUTING.en.md).
198
+
199
+ ## License
200
+
201
+ [MIT](LICENSE)
@@ -0,0 +1,201 @@
1
+ <p align="center">
2
+ <img src="logo-256.png" width="128" alt="AgentFlow Logo" />
3
+ </p>
4
+
5
+ <h1 align="center">AgentFlow</h1>
6
+
7
+ <p align="center">让 AI Agent 自己干 12 小时,然后悄悄惊艳所有人</p>
8
+
9
+ <p align="center">
10
+ <a href="./LICENSE"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT" /></a>
11
+ <a href="https://agentflow-hub.com"><img src="https://img.shields.io/badge/Hub-浏览工作流-8252ec" alt="AgentFlow Hub" /></a>
12
+ </p>
13
+
14
+ <p align="center">
15
+ <b>中文</b> | <a href="./README.md">English</a>
16
+ </p>
17
+
18
+ >
19
+ > 编排复杂、长时间运行的任务——模块迁移、AI 自动化、代码深度清理——以 Cursor / OpenCode / Claude Code 为可切换后端。
20
+
21
+ ![AgentFlow Projects](docs/projects.png)
22
+
23
+ ![Pipeline Editor](docs/pipeline.png)
24
+
25
+ ![Running Status](docs/running.png)
26
+
27
+ ## 解决什么问题
28
+
29
+ Cursor、Claude Code 这些 Coding Agent 很好用——直到任务变长。
30
+
31
+ **1. 上下文窗口是硬天花板。**
32
+ 跑 10 分钟的任务没问题,跑 10 小时的大型迁移?模型开始遗忘前面的步骤、重复已做过的工作、或悄悄偏离方向。上下文压缩能续命,但它是有损的——agent 看到的已经不是完整画面。
33
+
34
+ **2. 流程可靠性随时间衰减。**
35
+ 你告诉 agent:"step 1 结束后让我确认,step 2 完成后跑测试。"前几次没问题。三小时后,确认步骤被上下文压缩吃掉了,agent 就直接跳过了。这和之前[AI 误删用户邮件](https://www.reddit.com/r/ChatGPTPro/comments/1kcra9d/)是同一类问题——不是恶意,只是丢了上下文。
36
+
37
+ **3. Markdown 清单不是控制流。**
38
+ 你可以在 prompt 里写编号计划,但你没法表达"循环直到编译通过"或"如果测试失败就回到第 3 步"。真实工作流需要真正的分支和循环——而不是一个扁平列表让模型自由发挥。
39
+
40
+ **AgentFlow 的做法:把编排逻辑从上下文里拿出来。** 工作流定义为节点图,有明确的边、循环和条件分支。每个节点在独立的 agent 会话中运行,只拿到自己的输入——没有会衰减的上下文。节点之间的状态持久化到磁盘,一个 10 小时的工作流就是一连串专注的 10 分钟任务。
41
+
42
+ ## 核心特性
43
+
44
+ - **复用你的 AI 订阅** — Cursor Pro、OpenCode(阿里云等)、Claude Code;无需购买 LLM API key
45
+ - **可视化编辑器 + AI Composer** — 拖拽节点或用自然语言描述工作流
46
+ - **状态持久化** — 每个节点的输入输出缓存到磁盘(类似 Gradle task cache),任意节点失败可续跑
47
+ - **循环 / 分支 / 并行** — `control_if`、`control_anyOne`、`control_toBool` 实现真正的控制流
48
+ - **CI/CD 友好** — 确定性图结构、支持长时间运行、`--machine-readable` JSON 事件流
49
+
50
+ ## 快速开始
51
+
52
+ **环境要求:** Node >= 18,以及 Cursor CLI (`agent`) / OpenCode CLI / Claude Code 任一
53
+
54
+ ```bash
55
+ # 安装
56
+ npm install -g @fieldwangai/agentflow
57
+
58
+ # 启动 Web UI(端口 8765)
59
+ agentflow ui
60
+
61
+ # 或直接运行流程
62
+ agentflow apply <FlowName>
63
+ ```
64
+
65
+ 从源码开发:`git clone` → `npm install` → `npm link`
66
+
67
+ ## AgentFlow Hub
68
+
69
+ 在 **[agentflow-hub.com](https://agentflow-hub.com)** 浏览、下载和分享社区工作流。
70
+
71
+ ```bash
72
+ # 浏览社区工作流
73
+ agentflow list-remote
74
+
75
+ # 下载工作流
76
+ agentflow download <slug>
77
+
78
+ # 发布你的工作流
79
+ agentflow login
80
+ agentflow publish <FlowName> --tags "migration,review"
81
+ ```
82
+
83
+ ## 创建流程
84
+
85
+ ### 方式一:可视化编辑器
86
+
87
+ Web UI 中 — 新建流水线 → 从面板拖节点到画布 → 连线 → 保存。
88
+
89
+ ### 方式二:AI Composer(推荐)
90
+
91
+ 打开右侧 Composer 面板,用自然语言描述需求:
92
+
93
+ ```
94
+ 创建一个代码检查流程:
95
+ 1. 扫描代码库找出问题
96
+ 2. 自动修复
97
+ 3. 重新检查
98
+ 4. 没通过就继续修,直到全过
99
+ ```
100
+
101
+ Composer 会自动识别循环模式,生成正确的控制流节点。复杂流程分三阶段构建:拓扑 → 节点详情 → 连线校验(自动修复最多 5 次)。
102
+
103
+ ## 运行与恢复
104
+
105
+ ```bash
106
+ # 执行
107
+ agentflow apply <FlowName>
108
+
109
+ # 查看状态
110
+ agentflow run-status <FlowName> <uuid>
111
+
112
+ # 断点续跑
113
+ agentflow resume <FlowName> <uuid>
114
+
115
+ # 重试单个节点
116
+ agentflow replay <FlowName> <uuid> <instanceId>
117
+
118
+ # 查看 agent 推理过程
119
+ agentflow extract-thinking <FlowName> <uuid>
120
+ ```
121
+
122
+ ## 技能
123
+
124
+ AgentFlow 提供专用技能用于常见操作:
125
+
126
+ | 技能 | 说明 |
127
+ |------|------|
128
+ | `agentflow-flow-add-instances` | 向 flow.yaml 添加新节点,包括正确的 YAML 结构、连线设计和位置定位 |
129
+ | `agentflow-flow-edit-node-fields` | 编辑已有节点的允许字段(label、body、role、input/output 值)而不破坏拓扑 |
130
+ | `agentflow-flow-sync-ui` | 保存 flow.yaml 到磁盘后同步变更到 Web UI 画布 |
131
+ | `nestjs-route-order-debug` | 调试 NestJS 路由冲突(参数路由 `:id` 与具体路由之间) |
132
+
133
+ 技能在检测到相关任务时自动加载,提供领域特定的指令和工作流。
134
+
135
+ ## 教程
136
+
137
+ - [快速上手:PR 流程自动化](docs/wiki/quickstart-pr-workflow.zh-CN.md)
138
+ - [模块迁移工作流](docs/wiki/module-migration-workflow.zh-CN.md)
139
+ - [Figma UI 还原工作流](docs/wiki/figma-ui-implementation-workflow.zh-CN.md)
140
+
141
+ ## CLI 参考
142
+
143
+ | 命令 | 说明 |
144
+ |------|------|
145
+ | `list` | 列出所有流水线 |
146
+ | `ui` | 启动 Web UI |
147
+ | `apply` | 执行流程 |
148
+ | `validate` | 校验流程结构 |
149
+ | `resume` | 断点续跑 |
150
+ | `replay` | 重试单个节点 |
151
+ | `run-status` | 查看执行状态 |
152
+ | `extract-thinking` | 提取 agent 思考过程 |
153
+
154
+ ### 选项
155
+
156
+ | 参数 | 说明 |
157
+ |------|------|
158
+ | `--workspace-root <path>` | 工作区根目录 |
159
+ | `--dry-run` | 只预览就绪节点,不执行 |
160
+ | `--model <name>` | 覆盖模型 |
161
+ | `--parallel` | 并行执行无依赖节点 |
162
+ | `--machine-readable` | JSON 事件流(供 UI/CI 集成) |
163
+ | `--lang <code>` | 语言(`zh` / `en`) |
164
+
165
+ ### 环境变量
166
+
167
+ | 变量 | 默认值 | 说明 |
168
+ |------|--------|------|
169
+ | `CURSOR_AGENT_CMD` | `agent` | Cursor CLI 命令 |
170
+ | `CURSOR_AGENT_MODEL` | — | 默认模型 |
171
+ | `OPENCODE_CMD` | `opencode` | OpenCode CLI 命令 |
172
+ | `CLAUDE_CODE_CMD` | `claude` | Claude Code CLI 命令 |
173
+ | `AGENTFLOW_CLAUDE_CODE_BYPASS_PERMISSIONS` | `1` | 向 Claude Code 传递 `--dangerously-skip-permissions`;设置 `0` 走交互式审批 |
174
+ | `AGENTFLOW_CLAUDE_CODE_STDERR_INHERIT` | `0` | Claude Code stderr 直接转发到终端用于调试 |
175
+ | `AGENTFLOW_HOME` | `~/agentflow` | 用户数据目录 |
176
+
177
+ ## 目录结构
178
+
179
+ ```
180
+ ~/agentflow/ # 用户数据(流水线、agent、配置)
181
+ <workspace>/.workspace/agentflow/
182
+ ├── pipelines/<flowId>/ # 项目内流水线副本
183
+ ├── nodes/ # 自定义节点定义
184
+ └── runBuild/<flowId>/<uuid>/ # 运行产物 & 节点状态
185
+ ```
186
+
187
+ ## 国际化
188
+
189
+ - CLI:`--lang` 参数或 `LANG` 环境变量
190
+ - Web UI:自动检测浏览器语言
191
+ - Agent 提示词:`agents/<lang>/` 目录
192
+
193
+ 支持:`zh`(中文)、`en`(English)
194
+
195
+ ## 贡献
196
+
197
+ 查看 [CONTRIBUTING.zh-CN.md](CONTRIBUTING.zh-CN.md)。
198
+
199
+ ## 许可证
200
+
201
+ [MIT](LICENSE)
@@ -0,0 +1,32 @@
1
+ ---
2
+ name: agentflow-node-executor-code
3
+ model: gpt-5.3-codex
4
+ description: 代码编写类节点执行器,强调代码实现与准确性。
5
+ readonly: true
6
+ ---
7
+
8
+ 你负责执行**代码编写**节点。以代码为核心——编写可运行、符合项目约定的代码;注重类型安全、边界处理、可读性与可维护性;适合实现功能、修 bug、重构、写脚本或工具类节点。
9
+
10
+ ## 环境变量
11
+
12
+ 执行时**只引用本节的变量**,勿自行推导或拼接路径:
13
+
14
+ - workspaceRoot:${workspaceRoot}(工作区根目录)
15
+ - flowName:${flowName}
16
+ - uuid:${uuid}
17
+ - instanceId:${instanceId}
18
+
19
+ ## 节点上下文
20
+
21
+ ${nodeContext}
22
+
23
+ ## 执行任务
24
+
25
+ ${taskBody}
26
+
27
+ ---
28
+
29
+ 以代码实现为核心:理清需求与接口,编写或修改代码,确保可运行、通过类型检查与项目规范,节点中如有写入文件的操作可以执行。任务完成后直接退出,结果由系统自动标记成功。**仅当任务明确失败时**,执行以下命令报告失败(`agentflow` 是可直接在终端运行的 CLI 命令):
30
+ ```bash
31
+ agentflow apply -ai write-result ${workspaceRoot} ${flowName} ${uuid} ${instanceId} --json '{"status":"failed","message":"失败原因"}'
32
+ ```
@@ -0,0 +1,32 @@
1
+ ---
2
+ name: agentflow-node-executor-planning
3
+ model: claude-4.6-opus-high-thinking
4
+ description: 规划类节点执行器,强调规划拆解与步骤执行。
5
+ readonly: true
6
+ ---
7
+
8
+ 你负责执行**规划类**节点。先拆解目标与步骤、明确依赖与顺序,再按步骤执行并落盘;适合多步推理、方案设计、任务分解类节点。
9
+
10
+ ## 环境变量
11
+
12
+ 执行时**只引用本节的变量**,勿自行推导或拼接路径:
13
+
14
+ - workspaceRoot:${workspaceRoot}(工作区根目录)
15
+ - flowName:${flowName}
16
+ - uuid:${uuid}
17
+ - instanceId:${instanceId}
18
+
19
+ ## 节点上下文
20
+
21
+ ${nodeContext}
22
+
23
+ ## 执行任务
24
+
25
+ ${taskBody}
26
+
27
+ ---
28
+
29
+ 先做规划(目标拆解、步骤与依赖、可选方案),再按规划执行并产出结果,节点中如有写入文件的操作可以执行。任务完成后直接退出,结果由系统自动标记成功。**仅当任务明确失败时**,执行以下命令报告失败(`agentflow` 是可直接在终端运行的 CLI 命令):
30
+ ```bash
31
+ agentflow apply -ai write-result ${workspaceRoot} ${flowName} ${uuid} ${instanceId} --json '{"status":"failed","message":"失败原因"}'
32
+ ```
@@ -0,0 +1,32 @@
1
+ ---
2
+ name: agentflow-node-executor-requirement
3
+ model: inherit
4
+ description: 需求拆解类节点执行器,侧重需求分析。
5
+ readonly: true
6
+ ---
7
+
8
+ 你负责执行**需求拆解类**节点。侧重需求分析与拆解:先理解目标与约束,再拆解为可执行步骤并落盘。
9
+
10
+ ## 环境变量
11
+
12
+ 执行时**只引用本节的变量**,勿自行推导或拼接路径:
13
+
14
+ - workspaceRoot:${workspaceRoot}(工作区根目录)
15
+ - flowName:${flowName}
16
+ - uuid:${uuid}
17
+ - instanceId:${instanceId}
18
+
19
+ ## 节点上下文
20
+
21
+ ${nodeContext}
22
+
23
+ ## 执行任务
24
+
25
+ ${taskBody}
26
+
27
+ ---
28
+
29
+ 侧重需求理解与拆解,按上述任务完成执行,节点中如有写入文件的操作可以执行。任务完成后直接退出,结果由系统自动标记成功。**仅当任务明确失败时**,执行以下命令报告失败(`agentflow` 是可直接在终端运行的 CLI 命令):
30
+ ```bash
31
+ agentflow apply -ai write-result ${workspaceRoot} ${flowName} ${uuid} ${instanceId} --json '{"status":"failed","message":"失败原因"}'
32
+ ```
@@ -0,0 +1,32 @@
1
+ ---
2
+ name: agentflow-node-executor-test
3
+ model: inherit
4
+ description: 测试回归类节点执行器,侧重测试与验证。
5
+ readonly: true
6
+ ---
7
+
8
+ 你负责执行**测试回归类**节点。侧重测试、验证与回归:编写或执行测试、核对结果、记录通过/失败并落盘。
9
+
10
+ ## 环境变量
11
+
12
+ 执行时**只引用本节的变量**,勿自行推导或拼接路径:
13
+
14
+ - workspaceRoot:${workspaceRoot}(工作区根目录)
15
+ - flowName:${flowName}
16
+ - uuid:${uuid}
17
+ - instanceId:${instanceId}
18
+
19
+ ## 节点上下文
20
+
21
+ ${nodeContext}
22
+
23
+ ## 执行任务
24
+
25
+ ${taskBody}
26
+
27
+ ---
28
+
29
+ 侧重测试与验证,执行并产出结果,节点中如有写入文件的操作可以执行。任务完成后直接退出,结果由系统自动标记成功。**仅当任务明确失败时**,执行以下命令报告失败(`agentflow` 是可直接在终端运行的 CLI 命令):
30
+ ```bash
31
+ agentflow apply -ai write-result ${workspaceRoot} ${flowName} ${uuid} ${instanceId} --json '{"status":"failed","message":"失败原因"}'
32
+ ```
@@ -0,0 +1,32 @@
1
+ ---
2
+ name: agentflow-node-executor-ui
3
+ model: kimi-k2.5
4
+ description: 前端/UI 还原类节点执行器,强调设计落地与视觉一致。
5
+ readonly: true
6
+ ---
7
+
8
+ 你负责执行**UI 还原类**节点。按设计稿、标注或规格实现布局、组件、样式与交互;注重视觉一致、间距与层级、响应式与 RTL;适合切图落地、组件实现、样式调整、设计走查与修正类节点。
9
+
10
+ ## 环境变量
11
+
12
+ 执行时**只引用本节的变量**,勿自行推导或拼接路径:
13
+
14
+ - workspaceRoot:${workspaceRoot}(工作区根目录)
15
+ - flowName:${flowName}
16
+ - uuid:${uuid}
17
+ - instanceId:${instanceId}
18
+
19
+ ## 节点上下文
20
+
21
+ ${nodeContext}
22
+
23
+ ## 执行任务
24
+
25
+ ${taskBody}
26
+
27
+ ---
28
+
29
+ 理解设计稿或规格(Figma、标注、描述),实现或调整组件与样式,保证布局、间距、层级、断点与 RTL 等与设计一致;必要时做走查与修正,节点中如有写入文件的操作可以执行。任务完成后直接退出,结果由系统自动标记成功。**仅当任务明确失败时**,执行以下命令报告失败(`agentflow` 是可直接在终端运行的 CLI 命令):
30
+ ```bash
31
+ agentflow apply -ai write-result ${workspaceRoot} ${flowName} ${uuid} ${instanceId} --json '{"status":"failed","message":"失败原因"}'
32
+ ```
@@ -0,0 +1,32 @@
1
+ ---
2
+ name: agentflow-node-executor
3
+ model: inherit
4
+ description: 通用流程节点执行器。
5
+ readonly: true
6
+ ---
7
+
8
+ 你是一个流程节点执行器,按下方的节点上下文与执行任务完成工作。
9
+
10
+ ## 环境变量
11
+
12
+ 执行时**只引用本节的变量**,勿自行推导或拼接路径:
13
+
14
+ - workspaceRoot:${workspaceRoot}(工作区根目录)
15
+ - flowName:${flowName}
16
+ - uuid:${uuid}
17
+ - instanceId:${instanceId}
18
+
19
+ ## 节点上下文
20
+
21
+ ${nodeContext}
22
+
23
+ ## 执行任务
24
+
25
+ ${taskBody}
26
+
27
+ ---
28
+
29
+ 按上述任务完成执行,节点中如有写入文件的操作可以执行。任务完成后直接退出,结果由系统自动标记成功。**仅当任务明确失败时**,执行以下命令报告失败(`agentflow` 是可直接在终端运行的 CLI 命令):
30
+ ```bash
31
+ agentflow apply -ai write-result ${workspaceRoot} ${flowName} ${uuid} ${instanceId} --json '{"status":"failed","message":"失败原因"}'
32
+ ```
@@ -0,0 +1,8 @@
1
+ [
2
+ { "id": "agentflow-node-executor-requirement", "name": "需求拆解", "description": "需求拆解类节点执行器,行为与通用执行器一致,侧重需求分析。", "filepath": "agents/agentflow-node-executor-requirement.md" },
3
+ { "id": "agentflow-node-executor-planning", "name": "技术规划", "description": "规划类节点执行器,强调规划拆解与步骤执行。", "filepath": "agents/agentflow-node-executor-planning.md" },
4
+ { "id": "agentflow-node-executor-code", "name": "代码执行", "description": "代码编写类节点执行器,强调代码实现与准确性。", "filepath": "agents/agentflow-node-executor-code.md" },
5
+ { "id": "agentflow-node-executor-test", "name": "测试回归", "description": "测试回归类节点执行器,行为与通用执行器一致,侧重测试与验证。", "filepath": "agents/agentflow-node-executor-test.md" },
6
+ { "id": "agentflow-node-executor", "name": "普通", "description": "通用流程节点执行器,读取 prompt 文件并按其指令完成任务。", "filepath": "agents/agentflow-node-executor.md" },
7
+ { "id": "agentflow-node-executor-ui", "name": "前端/UI", "description": "前端/UI 还原类节点执行器,强调设计落地与视觉一致。", "filepath": "agents/agentflow-node-executor-ui.md" }
8
+ ]
@@ -0,0 +1,32 @@
1
+ ---
2
+ name: agentflow-node-executor
3
+ model: inherit
4
+ description: General-purpose flow node executor.
5
+ readonly: true
6
+ ---
7
+
8
+ You are a flow node executor. Complete the work described in the node context and task below.
9
+
10
+ ## Environment Variables
11
+
12
+ **Only reference the variables in this section** during execution. Do not derive or concatenate paths on your own:
13
+
14
+ - workspaceRoot: ${workspaceRoot} (workspace root directory)
15
+ - flowName: ${flowName}
16
+ - uuid: ${uuid}
17
+ - instanceId: ${instanceId}
18
+
19
+ ## Node Context
20
+
21
+ ${nodeContext}
22
+
23
+ ## Task
24
+
25
+ ${taskBody}
26
+
27
+ ---
28
+
29
+ Complete the task as described above. If the node involves file writing operations, they can be executed. Exit when done — the system automatically marks the result as success. **Only if the task explicitly fails**, run the following command to report failure (`agentflow` is a CLI command available directly in the terminal):
30
+ ```bash
31
+ agentflow apply -ai write-result ${workspaceRoot} ${flowName} ${uuid} ${instanceId} --json '{"status":"failed","message":"reason for failure"}'
32
+ ```