@josephyan/qingflow-app-builder-mcp 1.0.9 → 1.1.1

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 (63) hide show
  1. package/README.md +4 -2
  2. package/npm/bin/qingflow-app-builder-mcp.mjs +31 -2
  3. package/npm/lib/runtime.mjs +43 -2
  4. package/package.json +1 -1
  5. package/pyproject.toml +2 -1
  6. package/skills/qingflow-app-builder/SKILL.md +135 -14
  7. package/skills/qingflow-app-builder/references/build-complete-system.md +428 -0
  8. package/skills/qingflow-app-builder/references/build-single-app.md +530 -0
  9. package/skills/qingflow-app-builder/references/create-app.md +43 -3
  10. package/skills/qingflow-app-builder/references/gotchas.md +47 -3
  11. package/skills/qingflow-app-builder/references/match-rules.md +114 -0
  12. package/skills/qingflow-app-builder/references/public-surface-sync.md +75 -0
  13. package/skills/qingflow-app-builder/references/tool-selection.md +25 -10
  14. package/skills/qingflow-app-builder/references/update-flow.md +29 -1
  15. package/skills/qingflow-app-builder/references/update-schema.md +6 -2
  16. package/skills/qingflow-app-builder/references/update-views.md +135 -6
  17. package/skills/qingflow-mcp-setup/SKILL.md +111 -0
  18. package/skills/qingflow-mcp-setup/agents/openai.yaml +4 -0
  19. package/skills/qingflow-mcp-setup/references/claude-desktop.md +34 -0
  20. package/skills/qingflow-mcp-setup/references/environments.md +61 -0
  21. package/skills/qingflow-mcp-setup/references/generic-stdio.md +31 -0
  22. package/skills/qingflow-mcp-setup/scripts/check_local_server.sh +38 -0
  23. package/skills/qingflow-workflow-builder/SKILL.md +96 -0
  24. package/skills/qingflow-workflow-builder/manifest.yaml +8 -0
  25. package/skills/qingflow-workflow-builder/references/01-overview.md +45 -0
  26. package/skills/qingflow-workflow-builder/references/02-update-mode.md +53 -0
  27. package/skills/qingflow-workflow-builder/references/03-flow-patterns.md +57 -0
  28. package/skills/qingflow-workflow-builder/references/04-stage1-business-modeling.md +131 -0
  29. package/skills/qingflow-workflow-builder/references/05-stage2-members-roles.md +29 -0
  30. package/skills/qingflow-workflow-builder/references/06-stage3-build-spec.md +165 -0
  31. package/skills/qingflow-workflow-builder/references/07-stage4-validate-spec.md +33 -0
  32. package/skills/qingflow-workflow-builder/references/08-stage5-apply-verify.md +51 -0
  33. package/skills/qingflow-workflow-builder/references/09-stage6-summary.md +88 -0
  34. package/skills/qingflow-workflow-builder/references/10-node-config-reference.md +93 -0
  35. package/skills/qingflow-workflow-builder/references/11-troubleshooting.md +15 -0
  36. package/skills/qingflow-workflow-builder/scripts/diff_flow_spec.py +275 -0
  37. package/skills/qingflow-workflow-builder/scripts/validate_flow_spec.py +605 -0
  38. package/src/qingflow_mcp/__init__.py +1 -1
  39. package/src/qingflow_mcp/backend_client.py +55 -1
  40. package/src/qingflow_mcp/builder_facade/models.py +532 -48
  41. package/src/qingflow_mcp/builder_facade/service.py +9194 -2384
  42. package/src/qingflow_mcp/builder_facade/workflow_spec.py +111 -0
  43. package/src/qingflow_mcp/cli/commands/app.py +3 -16
  44. package/src/qingflow_mcp/cli/commands/builder.py +354 -56
  45. package/src/qingflow_mcp/cli/commands/record.py +112 -6
  46. package/src/qingflow_mcp/cli/formatters.py +102 -2
  47. package/src/qingflow_mcp/cli/main.py +204 -3
  48. package/src/qingflow_mcp/public_surface.py +12 -9
  49. package/src/qingflow_mcp/response_trim.py +287 -22
  50. package/src/qingflow_mcp/server.py +29 -20
  51. package/src/qingflow_mcp/server_app_builder.py +108 -30
  52. package/src/qingflow_mcp/server_app_user.py +28 -23
  53. package/src/qingflow_mcp/solution/compiler/__init__.py +1 -3
  54. package/src/qingflow_mcp/solution/compiler/icon_utils.py +294 -0
  55. package/src/qingflow_mcp/solution/executor.py +3 -133
  56. package/src/qingflow_mcp/tools/ai_builder_tools.py +2617 -440
  57. package/src/qingflow_mcp/tools/app_tools.py +53 -8
  58. package/src/qingflow_mcp/tools/package_tools.py +16 -2
  59. package/src/qingflow_mcp/tools/record_tools.py +14283 -9162
  60. package/src/qingflow_mcp/tools/resource_read_tools.py +3 -0
  61. package/src/qingflow_mcp/tools/solution_tools.py +30 -2
  62. package/src/qingflow_mcp/tools/workflow_tools.py +3 -31
  63. package/src/qingflow_mcp/solution/compiler/workflow_compiler.py +0 -173
@@ -0,0 +1,34 @@
1
+ # Claude Desktop
2
+
3
+ Use this when the user wants to install Qingflow MCP in Claude Desktop.
4
+
5
+ ## Config snippet
6
+
7
+ ```json
8
+ {
9
+ "mcpServers": {
10
+ "qingflow": {
11
+ "command": "<ABSOLUTE_PATH_TO_REPO>/qingflow-support/mcp-server/qingflow-mcp",
12
+ "args": [],
13
+ "env": {
14
+ "QINGFLOW_MCP_DEFAULT_BASE_URL": "<QINGFLOW_BASE_URL>"
15
+ }
16
+ }
17
+ }
18
+ }
19
+ ```
20
+
21
+ ## Environment examples
22
+
23
+ - `prod` (default): set `QINGFLOW_MCP_DEFAULT_BASE_URL` to `https://qingflow.com/api`
24
+ - `test`: if needed, set `QINGFLOW_MCP_DEFAULT_BASE_URL` to the explicitly provided non-production backend
25
+
26
+ Keep separate snippets for `test` and `prod` so switching environments does not require editing values in-place under pressure.
27
+
28
+ ## Notes
29
+
30
+ - After updating the config, restart Claude Desktop
31
+ - Replace `<ABSOLUTE_PATH_TO_REPO>` with the real checkout path on the current machine
32
+ - If the server path changes, update the `command` field
33
+ - The server is local stdio MCP, so no remote URL is required
34
+ - Do not store Qingflow token in Claude Desktop config; pass it through `auth_use_token` inside the chat
@@ -0,0 +1,61 @@
1
+ # Environment Switching
2
+
3
+ Use this reference before any setup, authentication, or live validation flow.
4
+
5
+ ## Step 1: Resolve the active environment
6
+
7
+ Decide explicitly whether the user is targeting:
8
+
9
+ - `test`: for smoke tests, trial setup, DSL validation, mock data, and integration debugging
10
+ - `prod`: for real business usage in the formal environment
11
+
12
+ If the user did not specify an environment, default to `prod`.
13
+
14
+ ## Test Environment
15
+
16
+ Default characteristics:
17
+
18
+ - preferred for first-time setup and local MCP validation
19
+ - mock or smoke data is acceptable when the user asks for it
20
+ - use read/write verification freely inside the intended test workspace
21
+
22
+ Known values in the current workspace:
23
+
24
+ - use an explicitly provided non-production backend
25
+ - common test workspace example: `ws_id=2`
26
+ - `qf_version`: usually unset unless the user explicitly needs a routed version
27
+
28
+ Setup behavior:
29
+
30
+ - prefer this environment for Claude Desktop or local MCP client onboarding
31
+ - use `auth_use_token` or `auth_login`, then `workspace_list`, then `workspace_select`
32
+ - if the user asks to verify installation, a real read-only smoke path is acceptable
33
+
34
+ ## Production Environment
35
+
36
+ Production is the default environment when the user does not specify one. If the user explicitly says `test`, switch to the dedicated non-production backend they provide.
37
+
38
+ Expected behavior:
39
+
40
+ - default `base_url`: `https://qingflow.com/api`
41
+ - confirm the production `qf_version` explicitly when browser traffic depends on routed versions such as `canary`
42
+ - confirm the exact workspace before any live validation
43
+ - prefer read-only checks first
44
+ - avoid mock data, smoke writes, or destructive tests unless the user explicitly asks for them
45
+
46
+ Production guardrails:
47
+
48
+ - do not store credentials in skill files or examples
49
+ - do not assume the same workspace ids as test
50
+ - treat startup verification and auth verification as separate steps
51
+ - when sharing snippets, label them as `prod` and `test` clearly
52
+ - when MCP and browser results diverge, compare `request_route` with the browser route before blaming the query logic
53
+
54
+ ## Reporting Rule
55
+
56
+ When you give setup instructions, always state:
57
+
58
+ - active environment
59
+ - selected `base_url`
60
+ - selected `qf_version` when relevant
61
+ - whether the next step is read-only or write-impacting
@@ -0,0 +1,31 @@
1
+ # Generic Stdio MCP Clients
2
+
3
+ Use this for any local AI client that supports MCP over stdio.
4
+
5
+ ## Required mapping
6
+
7
+ - `command`: `<ABSOLUTE_PATH_TO_REPO>/qingflow-support/mcp-server/qingflow-mcp`
8
+ - `args`: `[]`
9
+ - `env.QINGFLOW_MCP_DEFAULT_BASE_URL`: backend base URL for the active environment
10
+
11
+ Environment examples:
12
+
13
+ - `prod` (default): `https://qingflow.com/api`
14
+ - `test`: use the explicitly provided non-production backend
15
+
16
+ Keep separate client entries or separate config snippets for `test` and `prod`.
17
+
18
+ ## Validation sequence
19
+
20
+ 1. Start the client
21
+ 2. Confirm the `qingflow` MCP server is visible
22
+ 3. Run `auth_use_token`
23
+ 4. Run `workspace_list`
24
+ 5. Run `workspace_select`
25
+ 6. Run a read-only tool such as `app_list`
26
+
27
+ ## Common failures
28
+
29
+ - Launch failure: bad `command` path or missing `.venv`
30
+ - Auth failure: invalid or expired token
31
+ - Business tool failure before setup: workspace not selected
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
5
+ ROOT="${QINGFLOW_MCP_ROOT:-}"
6
+
7
+ if [[ -z "$ROOT" ]]; then
8
+ if git_root="$(git rev-parse --show-toplevel 2>/dev/null)" && [[ -d "$git_root/qingflow-support/mcp-server" ]]; then
9
+ ROOT="$git_root/qingflow-support/mcp-server"
10
+ elif [[ -d "$PWD/qingflow-support/mcp-server" ]]; then
11
+ ROOT="$PWD/qingflow-support/mcp-server"
12
+ else
13
+ repo_root="$(cd "$SCRIPT_DIR/../../../.." && pwd)"
14
+ if [[ -d "$repo_root/qingflow-support/mcp-server" ]]; then
15
+ ROOT="$repo_root/qingflow-support/mcp-server"
16
+ fi
17
+ fi
18
+ fi
19
+
20
+ if [[ -z "$ROOT" ]]; then
21
+ echo "Unable to locate qingflow-support/mcp-server. Set QINGFLOW_MCP_ROOT to the repo copy of the MCP server." >&2
22
+ exit 1
23
+ fi
24
+
25
+ ENTRY="$ROOT/qingflow-mcp"
26
+ PY="$ROOT/.venv/bin/python"
27
+
28
+ echo "ROOT=$ROOT"
29
+ test -d "$ROOT"
30
+ echo "OK root exists"
31
+
32
+ test -x "$ENTRY"
33
+ echo "OK entrypoint exists and is executable"
34
+
35
+ test -x "$PY"
36
+ echo "OK virtualenv python exists"
37
+
38
+ PYTHONPATH="$ROOT/src" "$PY" -c "import qingflow_mcp.server; print('OK import qingflow_mcp.server')"
@@ -0,0 +1,96 @@
1
+ ---
2
+ name: qingflow-workflow-builder
3
+ description: |
4
+ 在已有的轻流应用中,根据业务建模使用 qingflow CLI 声明式搭建工作流。
5
+ 适用场景:应用已存在、字段已就绪,需要创建或更新审批/填写/网关/自动化/抄送流程。
6
+ 不适用场景:应用不存在或字段缺失——应先完成应用搭建(schema apply)再使用本 Skill。
7
+ ---
8
+
9
+ # 轻流工作流搭建 Skill
10
+
11
+ ## 快速索引
12
+
13
+ | 主题 | 文件 |
14
+ |------|------|
15
+ | 依赖命令、能力边界 | [references/01-overview.md](references/01-overview.md) |
16
+ | 更新模式与最小修改原则 | [references/02-update-mode.md](references/02-update-mode.md) |
17
+ | 流程模式速查(线性/分支/回退) | [references/03-flow-patterns.md](references/03-flow-patterns.md) |
18
+ | 阶段 1:业务建模与自检 | [references/04-stage1-business-modeling.md](references/04-stage1-business-modeling.md) |
19
+ | 阶段 2:成员/角色搜索 | [references/05-stage2-members-roles.md](references/05-stage2-members-roles.md) |
20
+ | 阶段 3:Schema + 构建 Spec | [references/06-stage3-build-spec.md](references/06-stage3-build-spec.md) |
21
+ | 阶段 4:验证 Spec | [references/07-stage4-validate-spec.md](references/07-stage4-validate-spec.md) |
22
+ | 阶段 5:Apply + 验证循环 | [references/08-stage5-apply-verify.md](references/08-stage5-apply-verify.md) |
23
+ | 阶段 6:总结报告与回退 | [references/09-stage6-summary.md](references/09-stage6-summary.md) |
24
+ | 节点配置参考 | [references/10-node-config-reference.md](references/10-node-config-reference.md) |
25
+ | 常见问题与排障 | [references/11-troubleshooting.md](references/11-troubleshooting.md) |
26
+
27
+ ---
28
+
29
+ ## 一、思考(Thought):何时启用与前置条件
30
+
31
+ ### 触发条件
32
+
33
+ 当用户要求**在轻流应用中搭建工作流**时启用本 Skill,典型触发语:
34
+
35
+ - "帮我搭建审批流程"
36
+ - "在这个应用里创建工作流"
37
+ - "按照这张流程图实现工作流"
38
+ - "配置流程分支条件"
39
+ - "给这个应用加一个审批节点"
40
+
41
+ ### 前提检查(进入行动前必须完成)
42
+
43
+ 在开始任何搭建操作前,按顺序确认以下条件:
44
+
45
+ 1. **应用存在性**:`qingflow --json app get --app-key <APP_KEY>` 成功返回
46
+ 2. **字段就绪**:`qingflow --json builder app get --app-key <APP_KEY> fields` 返回字段列表,确认业务建模所需字段(如单选框、成员、部门字段)均已存在
47
+ 3. **未启用已有流程**(新建场景):`qingflow --json builder app get --app-key <APP_KEY> flow` 查看 `enabled` 状态,若已有流程则为**更新模式**
48
+
49
+ **不满足时的处理**:
50
+ - 应用不存在 → 先完成应用搭建和字段配置,再继续工作流搭建
51
+ - 字段缺失 → 先补充缺失的字段定义,再继续工作流搭建
52
+ - 应用已启用流程 → 进入更新模式(读取现有 spec 再修改)
53
+
54
+ ### 能力边界
55
+
56
+ | 在范围内 | 超出范围 |
57
+ |----------|----------|
58
+ | 基于已有应用搭建工作流 | 从零创建应用 |
59
+ | 声明式 WorkflowSpec 生成与 apply | 操作复杂命令拼接 |
60
+ | 分支条件(gateway + autoJudges)配置 | 后端不支持的高级特性 |
61
+ | 审批/填写/抄送/自动化节点配置 | 修改字段定义 |
62
+ | 成员/角色搜索用于节点负责人 | 组织架构管理 |
63
+ | 验证 → apply → 校验循环 | 前端 UI 拖拽操作 |
64
+
65
+ 完整命令与依赖说明见 [references/01-overview.md](references/01-overview.md)。
66
+ 本 Skill 中的 `scripts/...` 路径均以 `qingflow-workflow-builder/` 技能根目录为基准;执行脚本时先解析为该技能目录下的实际文件。
67
+
68
+ ---
69
+
70
+ ## 二、行动(Action):核心 SOP
71
+
72
+ 按顺序执行以下阶段,每个阶段详见对应 reference 文件:
73
+
74
+ | 阶段 | 任务 | 参考文件 |
75
+ |------|------|----------|
76
+ | 阶段 0 | 判断是否为更新模式,确认最小修改原则 | [references/02-update-mode.md](references/02-update-mode.md) |
77
+ | 阶段 1 | 提取业务建模,完成七维度业务自检 | [references/04-stage1-business-modeling.md](references/04-stage1-business-modeling.md) |
78
+ | 阶段 2 | 搜索成员/角色,用于节点负责人配置 | [references/05-stage2-members-roles.md](references/05-stage2-members-roles.md) |
79
+ | 阶段 3 | 获取 Schema、读取现有 Spec、构建新 Spec | [references/06-stage3-build-spec.md](references/06-stage3-build-spec.md) |
80
+ | 阶段 4 | 验证 Spec(JSON Schema + 自定义约束) | [references/07-stage4-validate-spec.md](references/07-stage4-validate-spec.md) |
81
+ | 阶段 5 | Apply 工作流并验证部署结果 | [references/08-stage5-apply-verify.md](references/08-stage5-apply-verify.md) |
82
+
83
+ 构建 Spec 前,若对流程模式有疑问,先查阅 [references/03-flow-patterns.md](references/03-flow-patterns.md)。
84
+
85
+ ---
86
+
87
+ ## 三、反思(Reflection):验证与总结
88
+
89
+ | 阶段 | 任务 | 参考文件 |
90
+ |------|------|----------|
91
+ | 阶段 6 | 输出结构化搭建报告,回顾业务完整性 | [references/09-stage6-summary.md](references/09-stage6-summary.md) |
92
+
93
+ 搭建失败时的回退策略、节点配置细节、常见问题排障分别见:
94
+ - [references/09-stage6-summary.md](references/09-stage6-summary.md)
95
+ - [references/10-node-config-reference.md](references/10-node-config-reference.md)
96
+ - [references/11-troubleshooting.md](references/11-troubleshooting.md)
@@ -0,0 +1,8 @@
1
+ identity: qingflow_workflow_builder
2
+ type: skill
3
+ description: 在轻流应用中搭建工作流。从业务建模提取流程结构(含业务完整性自检:规模分级、组织层级、异常路径、状态闭环、角色分离),映射为声明式 WorkflowSpec,通过 qingflow CLI 的 schema/get/apply 三步部署工作流,并验证分支条件与自动化节点配置一致性。
4
+ tags:
5
+ - qingflow
6
+ - workflow
7
+ - builder
8
+ - flow
@@ -0,0 +1,45 @@
1
+ # 轻流工作流搭建:概览与依赖
2
+
3
+ ## 关联文件
4
+
5
+ | 文件 | 说明 |
6
+ |------|------|
7
+ | `manifest.yaml` | 技能清单 |
8
+ | `SKILL.md` | 主流程入口 |
9
+ | `scripts/validate_flow_spec.py` | 工作流 Spec 验证脚本,基于 JSON Schema + 自定义约束 |
10
+ | `scripts/diff_flow_spec.py` | 新旧 Spec 差异分析脚本,辅助更新模式下最小修改原则判断 |
11
+
12
+ ---
13
+
14
+ ## 依赖声明
15
+
16
+ 本 Skill 关键依赖 **qingflow CLI**(已安装于 PATH,详见 `qingflow_cli` Skill)。以下 qingflow 命令为核心操作:
17
+
18
+ | 命令 | 用途 |
19
+ |------|------|
20
+ | `qingflow builder flow schema --json` | 获取最新 WorkflowSpecDTO JSON Schema |
21
+ | `qingflow builder flow get --app-key <KEY>` | 读取当前工作流 spec |
22
+ | `qingflow builder flow apply --app-key <KEY> --spec-file <FILE>` | 部署/更新工作流 |
23
+ | `qingflow builder member search --query <关键词>` | 搜索成员 |
24
+ | `qingflow builder role search --keyword <关键词>` | 搜索角色 |
25
+ | `qingflow --json app get --app-key <KEY>` | 获取应用信息(字段列表等) |
26
+ | `qingflow --json builder app get --app-key <KEY> fields` | 获取应用可搭建字段详情 |
27
+ | `qingflow --json builder app get --app-key <KEY> flow` | 获取流程摘要(是否启用等) |
28
+
29
+ ---
30
+
31
+ ## 能力边界
32
+
33
+ | 在范围内 | 超出范围 |
34
+ |----------|----------|
35
+ | 基于已有应用搭建工作流 | 从零创建应用 |
36
+ | 声明式 WorkflowSpec 生成与 apply | 操作复杂命令拼接 |
37
+ | 分支条件(gateway + autoJudges)配置 | 后端不支持的高级特性 |
38
+ | 审批/填写/抄送/自动化节点配置 | 修改字段定义 |
39
+ | 成员/角色搜索用于节点负责人 | 组织架构管理 |
40
+ | 验证 → apply → 校验循环 | 前端 UI 拖拽操作 |
41
+
42
+ ---
43
+
44
+ ← 返回主流程:[../SKILL.md](../SKILL.md)
45
+ → 下一步:[02-update-mode.md](02-update-mode.md)
@@ -0,0 +1,53 @@
1
+ # 更新模式与最小修改原则
2
+
3
+ 当应用已有工作流时,进入**更新模式**。核心原则是**最小修改**——只改动必要的部分,保持其他结构不变。
4
+
5
+ ## 为什么要保持节点 ID 稳定
6
+
7
+ 后端可能存储了 spec 中不支持的运行时配置(如审批策略、超时规则、高级权限等),这些配置与节点 ID 绑定。一旦修改节点 ID,后端会将其视为「删除旧节点 + 创建新节点」,导致不支持的配置全部丢失。
8
+
9
+ **因此:修改已有节点时,只改 attrs/name,绝不改 id。**
10
+
11
+ ## 最小修改原则速查
12
+
13
+ | 操作 | ✅ 正确做法 | ❌ 错误做法 |
14
+ |------|-----------|-----------|
15
+ | 添加节点 | 使用新 ID,追加到 nodes 末尾 | 重排已有节点 ID |
16
+ | 删除节点 | 删除对应 node 和关联边 | 不删关联边导致孤立边 |
17
+ | 修改节点配置 | 同一 ID 下只改 attrs/name | 改 ID 导致节点重建 |
18
+ | 添加边 | 追加到 edges 数组 | 修改已有边的 from/to |
19
+ | 修改条件 | 同一条边内改 condition | 删除边再新建 |
20
+ | 调整流转 | 修改边的 from/to | 改节点 ID 来适配 |
21
+
22
+ ## 使用 diff 脚本辅助判断
23
+
24
+ 在构建新 spec 后、apply 前,使用 diff 脚本对比新旧 spec:
25
+
26
+ ```bash
27
+ python3 scripts/diff_flow_spec.py tmp/current_flow.json tmp/flow_spec.json
28
+ ```
29
+
30
+ 输出会显示删除的节点/边、新增的节点/边、修改的节点/边,并自动评估是否符合最小修改原则。
31
+
32
+ 验证脚本也支持在更新模式下进行最小修改原则校验:
33
+
34
+ ```bash
35
+ python3 scripts/validate_flow_spec.py \
36
+ tmp/flow_spec.json \
37
+ --schema tmp/flow_schema.json \
38
+ --previous tmp/current_flow.json
39
+ ```
40
+
41
+ ## 更新模式 SOP 调整
42
+
43
+ 在更新模式下,阶段 3.2 变为**必须执行**(读取现有 spec),阶段 5.2 的对比验证增加最小修改原则检查:
44
+
45
+ - 节点 ID 不应无故变更
46
+ - 删除的节点/边应为业务需要,而非误删
47
+ - 修改范围应仅限于业务建模中变更的部分
48
+
49
+ ---
50
+
51
+ ← 上一步:[01-overview.md](01-overview.md)
52
+ ← 返回主流程:[../SKILL.md](../SKILL.md)
53
+ → 下一步:[03-flow-patterns.md](03-flow-patterns.md)
@@ -0,0 +1,57 @@
1
+ # 流程模式速查
2
+
3
+ 在构建 spec 前,先判断当前流程属于哪种模式,避免用错节点类型或边结构。
4
+
5
+ ## 线性流程
6
+
7
+ 最简单的流程模式:节点首尾相连,无分支、无条件。
8
+
9
+ ```
10
+ n1 → n2 → n3 → n4
11
+ ```
12
+
13
+ - 边不带 `condition`,按顺序流转即可
14
+ - 无需 gateway 节点
15
+ - 适用于:简单的提交→审批→结束
16
+
17
+ ## 分支流程
18
+
19
+ 轻流的分支采用**并行分支**模型——通过 `gateway` 节点(`mode: parallel`)分发,所有出边指向的分支**都会进入**,通过每条边上的条件(`condition.autoJudges`)控制分支内的节点逻辑是否执行。
20
+
21
+ ```
22
+ ┌──[条件A成立]→ n3 → n4
23
+ n1 → n2 → g1 ──┤
24
+ └──[条件B成立]→ n5
25
+ ```
26
+
27
+ **关键点**:
28
+ - 分支起点必须是 `gateway`(`mode: parallel`),终点必须是 `gateway`(`mode: join`)
29
+ - 每条分支边都需要配置 `condition`,其中至少一条为 `kind: rules` 带 `autoJudges`
30
+ - 没有条件的边使用 `kind: default` 作为兜底
31
+ - 所有分支并行进入,条件只决定分支内逻辑是否执行,不存在"条件匹配就跳过其他分支"的互斥语义
32
+
33
+ ## 循环/回退
34
+
35
+ **轻流工作流引擎不支持循环结构**。不要通过 gateway 或其他方式构建回到前序节点的环。
36
+
37
+ 如需回退到前序节点重新处理,应使用审批节点的回退开关:
38
+
39
+ ```json
40
+ {
41
+ "type": "approval",
42
+ "attrs": {
43
+ "revert": true,
44
+ "revertScope": "all"
45
+ }
46
+ }
47
+ ```
48
+
49
+ - `revert: true` 开启驳回/回退能力
50
+ - `revertScope` 控制回退范围:`all` 可回退到任意前序节点
51
+ - 这是引擎原生支持的回退机制,无需在 spec 中构建回退边
52
+
53
+ ---
54
+
55
+ ← 上一步:[02-update-mode.md](02-update-mode.md)
56
+ ← 返回主流程:[../SKILL.md](../SKILL.md)
57
+ → 下一步:[04-stage1-business-modeling.md](04-stage1-business-modeling.md)
@@ -0,0 +1,131 @@
1
+ # 阶段 1:提取业务建模
2
+
3
+ 从用户上下文(对话文本、上传的流程图图片、需求描述等)中提取业务建模。
4
+
5
+ ## 若上下文包含流程图图片
6
+
7
+ 1. 优先使用当前客户端已暴露的图片理解能力读取流程图;不要假定某个跨插件工具名一定存在
8
+ 2. 如果当前环境没有图片理解能力,要求用户补充流程文字说明或节点/分支清单
9
+ 3. 从图片理解结果或用户补充中提取:节点名称、节点类型、流转顺序、分支条件(字段→选项→目标)
10
+
11
+ ## 建模输出格式
12
+
13
+ 保存到 `tmp/业务建模_<应用名>.md`:
14
+
15
+ ```markdown
16
+ # 业务建模:<流程名称>
17
+
18
+ ## 应用信息
19
+ - APP_KEY: <xxx>
20
+ - 应用名称: <xxx>
21
+
22
+ ## 节点清单
23
+ | id | 名称 | 类型 | 审批人/处理人 | 说明 |
24
+ |----|------|------|--------------|------|
25
+ | n1 | 员工提交申请 | applicant | — | 工作流入门 |
26
+ | n2 | 部门经理审批 | approval | 部门经理 | 或签 |
27
+ | ... | ... | ... | ... | ... |
28
+
29
+ ## 流转路径
30
+ n1 → n2 → [分支:字段=选项]
31
+ ├─ 选项A → n3
32
+ └─ 选项B → n4
33
+ ...
34
+
35
+ ## 分支条件明细
36
+ | 分支来源 | 条件字段 | 判断符 | 选项值 | 目标节点 |
37
+ |----------|---------|--------|--------|----------|
38
+ | 服务类型 | 服务类型(单选) | equals | 客诉 | 质量部负责人接单 |
39
+ | ... | ... | ... | ... | ... |
40
+ ```
41
+
42
+ **无法提取时**:明确告知用户缺少哪些信息(节点、角色、条件等),要求补充,**禁止臆测**。
43
+
44
+ ---
45
+
46
+ ## 业务完整性自检(建模完成后必须逐项确认)
47
+
48
+ > ⚠️ **用户指令优先**:如果用户给出了明确的流程设计指令,以用户指令为准,本自检仅作为补充建议。与用户指令冲突的项标记为「用户已明确」并跳过。
49
+ >
50
+ > 当用户未给出明确指令时,本自检从以下七个维度引导思考。回答「否」的项需在建模文件中说明理由。**禁止为了通过自检而添加无业务意义的节点。**
51
+
52
+ ### 一、审批强度与风险匹配
53
+ - 审批层数是否与业务风险匹配?
54
+ - 低风险场景是否走了简化路径?
55
+ - 是否存在冗余审批节点?
56
+
57
+ ### 二、角色策略与审批人指派
58
+ - 审批人是否基于角色而非个人?
59
+ - 不同审批层级是否代表不同能力或权限?
60
+ - 关键节点是否需要多人会签?审批人缺席时是否有替代方案?
61
+
62
+ ### 三、执行顺序与效率
63
+ - 互不依赖的审批是否并行?
64
+ - 是否存在可合并的冗余环节?
65
+ - 串行审批链是否过长?
66
+
67
+ ### 四、条件路由与分支设计
68
+ - 是否需要根据业务数据动态路由?
69
+ - 分支条件是否覆盖所有可能?是否有默认兜底?
70
+
71
+ ### 五、异常处理与纠错机制
72
+ - 审批不通过时是否可以修正重提?
73
+ - 驳回后回到哪个节点?
74
+ - 是否考虑了审批超时?
75
+ - 异常升级是否有终态?
76
+
77
+ ### 六、信息透明与闭环
78
+ - 关键决策节点完成后是否需要抄送?
79
+ - 流程结束后提交人是否能明确知道结果?
80
+ - 是否需要自动化节点更新状态字段?
81
+
82
+ ### 七、流程嵌入与业务衔接
83
+ - 审批通过后是否有后续业务动作?
84
+ - 是否有前置校验需求?
85
+
86
+ ---
87
+
88
+ ## 自检结果格式
89
+
90
+ 追加到建模文件末尾:
91
+
92
+ ```markdown
93
+ ## 业务完整性自检
94
+
95
+ | 维度 | 检查项 | 结果 | 说明 |
96
+ |------|--------|:----:|------|
97
+ | 一、审批强度 | 审批层数是否与风险匹配? | ✅/❌ | |
98
+ | 一、审批强度 | 低风险是否简化路径? | ✅/❌ | |
99
+ | 一、审批强度 | 是否存在冗余审批节点? | ✅/❌ | |
100
+ | 二、角色策略 | 审批人是否基于角色? | ✅/❌ | |
101
+ | 二、角色策略 | 不同层级是否代表不同能力? | ✅/❌ | |
102
+ | 二、角色策略 | 是否考虑缺席替代方案? | ✅/❌ | |
103
+ | 三、执行效率 | 独立审批是否并行化? | ✅/❌ | |
104
+ | 三、执行效率 | 串行链是否过长? | ✅/❌ | |
105
+ | 三、执行效率 | 是否存在可合并环节? | ✅/❌ | |
106
+ | 四、条件路由 | 是否需要动态路由? | ✅/❌ | |
107
+ | 四、条件路由 | 分支条件是否全覆盖? | ✅/❌ | |
108
+ | 四、条件路由 | 是否有默认兜底? | ✅/❌ | |
109
+ | 五、异常处理 | 驳回后是否可修正重提? | ✅/❌ | |
110
+ | 五、异常处理 | 是否考虑审批超时? | ✅/❌ | |
111
+ | 五、异常处理 | 异常升级是否有终态? | ✅/❌ | |
112
+ | 六、信息透明 | 关键节点是否抄送? | ✅/❌ | |
113
+ | 六、信息透明 | 提交人能否明确结果? | ✅/❌ | |
114
+ | 六、信息透明 | 状态字段是否自动更新? | ✅/❌ | |
115
+ | 七、业务衔接 | 是否有前置校验? | ✅/❌ | |
116
+ | 七、业务衔接 | 审批后是否有后续动作? | ✅/❌ | |
117
+ ```
118
+
119
+ ## 自检不通过时的处理
120
+
121
+ - 某个维度确实需要但设计中遗漏了 → 回到建模环节补充
122
+ - 某个维度在业务上确实不需要 → 在「说明」列记录理由后放行
123
+ - 与用户明确指令冲突 → 标记「用户已明确」,以用户指令为准
124
+
125
+ **无法提取时**:明确告知用户缺少哪些信息,要求补充,**禁止臆测**。
126
+
127
+ ---
128
+
129
+ ← 上一步:[03-flow-patterns.md](03-flow-patterns.md)
130
+ ← 返回主流程:[../SKILL.md](../SKILL.md)
131
+ → 下一步:[05-stage2-members-roles.md](05-stage2-members-roles.md)
@@ -0,0 +1,29 @@
1
+ # 阶段 2:获取成员/角色信息
2
+
3
+ 在配置节点负责人(`responsible`)前,需要搜索可用成员与角色:
4
+
5
+ ```bash
6
+ # 搜索成员
7
+ qingflow --json builder member search --query "<姓名/关键词>" --page-size 20
8
+ # 搜索角色
9
+ qingflow --json builder role search --keyword "<角色名>" --page-size 20
10
+ ```
11
+
12
+ ## 注意事项
13
+
14
+ - `responsible` 是 **MemberRefDTO 数组**,不是单值对象
15
+ - `type` 字段可取:
16
+ - `user`(指定人)
17
+ - `role`(角色)
18
+ - `dept`(部门)
19
+ - `applicant` / `leader` / `formEmail` / `formMember` / `formDept` / `nodeLeader`
20
+ - 指定人时使用 `uid` 传入成员 UID(整数)
21
+ - 角色时使用 `roleId` 传入角色 ID(整数)
22
+ - 部门时使用 `deptId` 传入部门 ID(整数),可选 `havingSubDept`
23
+ - 避免硬编码 UID/角色 ID/部门 ID,始终从搜索结果中提取
24
+
25
+ ---
26
+
27
+ ← 上一步:[04-stage1-business-modeling.md](04-stage1-business-modeling.md)
28
+ ← 返回主流程:[../SKILL.md](../SKILL.md)
29
+ → 下一步:[06-stage3-build-spec.md](06-stage3-build-spec.md)