@josephyan/qingflow-app-builder-mcp 0.2.0-beta.3 → 0.2.0-beta.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.
Files changed (30) hide show
  1. package/README.md +3 -3
  2. package/package.json +1 -1
  3. package/pyproject.toml +1 -1
  4. package/skills/qingflow-app-builder/SKILL.md +122 -13
  5. package/skills/qingflow-app-builder/references/create-app.md +50 -0
  6. package/skills/qingflow-app-builder/references/environments.md +1 -1
  7. package/skills/qingflow-app-builder/references/flow-actors-and-permissions.md +124 -0
  8. package/skills/qingflow-app-builder/references/gotchas.md +27 -0
  9. package/skills/qingflow-app-builder/references/solution-playbooks.md +11 -4
  10. package/skills/qingflow-app-builder/references/tool-selection.md +35 -4
  11. package/skills/qingflow-app-builder/references/update-flow.md +174 -12
  12. package/skills/qingflow-app-builder/references/update-layout.md +13 -3
  13. package/skills/qingflow-app-builder/references/update-views.md +98 -10
  14. package/src/qingflow_mcp/__init__.py +1 -1
  15. package/src/qingflow_mcp/builder_facade/models.py +294 -1
  16. package/src/qingflow_mcp/builder_facade/service.py +2597 -198
  17. package/src/qingflow_mcp/server.py +82 -16
  18. package/src/qingflow_mcp/server_app_builder.py +70 -1
  19. package/src/qingflow_mcp/server_app_user.py +88 -188
  20. package/src/qingflow_mcp/solution/compiler/form_compiler.py +1 -1
  21. package/src/qingflow_mcp/solution/compiler/workflow_compiler.py +21 -2
  22. package/src/qingflow_mcp/solution/executor.py +34 -7
  23. package/src/qingflow_mcp/tools/ai_builder_tools.py +1025 -29
  24. package/src/qingflow_mcp/tools/app_tools.py +110 -13
  25. package/src/qingflow_mcp/tools/approval_tools.py +357 -75
  26. package/src/qingflow_mcp/tools/directory_tools.py +203 -31
  27. package/src/qingflow_mcp/tools/file_tools.py +1 -0
  28. package/src/qingflow_mcp/tools/record_tools.py +3287 -998
  29. package/src/qingflow_mcp/tools/task_tools.py +376 -225
  30. package/src/qingflow_mcp/tools/workflow_tools.py +78 -4
package/README.md CHANGED
@@ -3,13 +3,13 @@
3
3
  Install:
4
4
 
5
5
  ```bash
6
- npm install @josephyan/qingflow-app-builder-mcp@0.2.0-beta.3
6
+ npm install @josephyan/qingflow-app-builder-mcp@0.2.0-beta.30
7
7
  ```
8
8
 
9
9
  Run:
10
10
 
11
11
  ```bash
12
- npx -y -p @josephyan/qingflow-app-builder-mcp@0.2.0-beta.3 qingflow-app-builder-mcp
12
+ npx -y -p @josephyan/qingflow-app-builder-mcp@0.2.0-beta.30 qingflow-app-builder-mcp
13
13
  ```
14
14
 
15
15
  Environment:
@@ -20,7 +20,7 @@ Environment:
20
20
 
21
21
  This package bootstraps a local Python runtime on first install and then starts the `qingflow-app-builder-mcp` stdio MCP server.
22
22
 
23
- Bundled skill:
23
+ Bundled skills:
24
24
 
25
25
  - `skills/qingflow-app-builder`
26
26
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@josephyan/qingflow-app-builder-mcp",
3
- "version": "0.2.0-beta.3",
3
+ "version": "0.2.0-beta.30",
4
4
  "description": "Builder MCP for Qingflow app/package/system design and staged solution workflows.",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/pyproject.toml CHANGED
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "qingflow-mcp"
7
- version = "0.2.0b3"
7
+ version = "0.2.0b30"
8
8
  description = "User-authenticated MCP server for Qingflow"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -17,11 +17,34 @@ Before any write or verification flow, identify whether the task targets `test`
17
17
 
18
18
  Pick the smallest tool layer that can finish the task.
19
19
 
20
+ ## Mental Model
21
+
22
+ Model builder requests in four layers. Do not flatten them.
23
+
24
+ - `package`: the solution container or app bundle, for example “研发项目管理” or “费控管理系统”
25
+ - `app`: one form/app inside that package, for example “项目”, “需求”, “任务”, “缺陷”, “团队”
26
+ - `field`: one field inside one app
27
+ - `relation`: a field that links one app to another app
28
+
29
+ Interpret user intent with this hierarchy:
30
+
31
+ - If the user says “应用包”, “系统”, “包含多个表单”, “多个模块”, or asks for several named forms that relate to each other, treat it as a `package` with multiple `apps`
32
+ - Do not compress a multi-app system into one app with several text fields
33
+ - Names like “项目/需求/任务/缺陷/团队” or “费用申请/预算管理/报销审批” are usually separate apps, not text fields
34
+ - Build the apps first, then add `relation` fields to connect them
35
+
36
+ Default modeling rules:
37
+
38
+ - One business object -> one app
39
+ - Attributes of that object -> fields inside that app
40
+ - Another business object -> a separate app, not a text field
41
+ - Cross-object links -> relation fields, not text fields
42
+
20
43
  - Authentication and workspace: `auth_*`, `workspace_*`
21
44
  - File upload: `file_upload_local`
22
- - Resource resolve/read: `package_list`, `package_resolve`, `app_resolve`, `app_read_summary`, `app_read_fields`, `app_read_layout_summary`, `app_read_views_summary`, `app_read_flow_summary`
45
+ - Resource resolve/read: `package_list`, `package_resolve`, `package_create`, `builder_tool_contract`, `member_search`, `role_search`, `app_resolve`, `app_read_summary`, `app_read_fields`, `app_read_layout_summary`, `app_read_views_summary`, `app_read_flow_summary`
23
46
  - Resource plan: `app_schema_plan`, `app_layout_plan`, `app_flow_plan`, `app_views_plan`
24
- - Resource patch: `app_schema_apply`, `app_layout_apply`, `app_flow_apply`, `app_views_apply`, `package_attach_app`
47
+ - Resource patch: `app_schema_apply`, `app_layout_apply`, `app_flow_apply`, `app_views_apply`, `package_attach_app`, `app_release_edit_lock_if_mine`, `role_create`
25
48
  - Publish and verify: `app_publish_verify`
26
49
 
27
50
  Note:
@@ -29,11 +52,23 @@ Note:
29
52
  - Do not rely on low-level `view_*`, `workflow_*`, or `qingbi_report_*` write payloads from public builder flows.
30
53
  - Public builder work should stay on the resource path: `resolve -> summary read -> plan -> apply -> attach -> publish_verify`.
31
54
  - `app_schema_apply` / `app_layout_apply` / `app_flow_apply` / `app_views_apply` publish by default; pass `publish=false` only when you intentionally want to leave changes in draft.
55
+ - If you are unsure about a public builder tool's keys, aliases, presets, or minimal legal shape, call `builder_tool_contract` instead of guessing.
56
+ - For views, always write the canonical key `columns`. Do not emit `column_names`; treat `fields` only as a tolerated legacy alias, not the preferred shape.
57
+ - For flow presets, map natural language to canonical values before calling MCP:
58
+ - “默认审批/基础审批/普通审批” -> `basic_approval`
59
+ - “先填报再审批/提交后审批” -> `basic_fill_then_approve`
60
+ - For first-time flow or view work in a session, read `builder_tool_contract` before planning so keys, aliases, presets, and minimal examples come from MCP instead of memory.
61
+ - For workflow assignees, prefer roles over explicit members:
62
+ - use `role_search` first
63
+ - use `member_search` only when the user explicitly names members or no stable role exists
64
+ - use `role_create` when the business owner wants a reusable directory role instead of hard-coded members
65
+ - On any `VALIDATION_ERROR`, inspect `suggested_next_call` first and prefer reusing the MCP-normalized arguments over re-guessing from the original natural language.
32
66
 
33
67
  Default policy:
34
68
 
35
69
  - Creating or updating one app inside an existing package: resolve the package/app, read compact state, plan patches on the server, then apply schema/layout/flow/views patches explicitly.
36
- - Do not create a new package unless the user explicitly asks for package separation.
70
+ - If package creation looks necessary or beneficial, ask the user to confirm before calling `package_create`.
71
+ - If the user describes a system/package with multiple forms or modules, do not start with `app_schema_apply` on the package name. Resolve or create the package first, then create each app separately.
37
72
 
38
73
  ## Standard Operating Order
39
74
 
@@ -45,16 +80,50 @@ Before any business tool:
45
80
 
46
81
  For builder work:
47
82
 
48
- 1. Resolve the target package with `package_resolve` when the user gives a package name. If resolution is ambiguous or you need a read-only fallback, use `package_list`.
49
- 2. Resolve the target app with `app_resolve` if the request is an update.
50
- 3. Read only the smallest summary you need: `app_read_summary`, `app_read_fields`, `app_read_layout_summary`, `app_read_views_summary`, `app_read_flow_summary`.
51
- 4. Use `app_schema_plan`, `app_layout_plan`, `app_flow_plan`, or `app_views_plan` before any non-trivial write.
52
- 5. Use `app_schema_apply` for create/upsert/remove field work. It publishes by default after the patch lands.
53
- 6. If the app must belong to a package, use `package_attach_app` explicitly after schema work unless readback already shows the target `tag_id`.
54
- 7. Use `app_layout_apply` only when the user is explicitly changing layout. Prefer the default `mode=merge`; use `mode=replace` only when you intend to place every field explicitly. It publishes by default.
55
- 8. Use `app_flow_apply` after schema exists. It publishes by default.
56
- 9. Use `app_views_apply` when the user wants explicit list/card/board views. It publishes by default.
57
- 10. Use `app_publish_verify` only when the user explicitly wants final publish/live verification or you need an explicit verification pass.
83
+ 1. Resolve the target package with `package_resolve`; if resolution is ambiguous or you need a read-only fallback, use `package_list`. If you believe a new package should be created, ask the user to confirm before calling `package_create`.
84
+ 2. Decide whether the target is one app or a multi-app package:
85
+ - one app: continue with `app_resolve`
86
+ - multi-app package/system: create or resolve the package, then create each app separately before adding relations
87
+ 3. Resolve the target app with `app_resolve` if the request is an update.
88
+ 4. Read only the smallest summary you need: `app_read_summary`, `app_read_fields`, `app_read_layout_summary`, `app_read_views_summary`, `app_read_flow_summary`.
89
+ 5. Use `app_schema_plan`, `app_layout_plan`, `app_flow_plan`, or `app_views_plan` before any non-trivial write.
90
+ 6. Use `app_schema_apply` for create/upsert/remove field work. It publishes by default after the patch lands.
91
+ 7. If the app must belong to a package, use `package_attach_app` explicitly after schema work unless readback already shows the target `tag_id`.
92
+ 8. Use `app_layout_apply` only when the user is explicitly changing layout. Prefer the default `mode=merge`; use `mode=replace` only when you intend to place every field explicitly. It publishes by default.
93
+ 9. Use `app_flow_apply` after schema exists. It publishes by default.
94
+ 10. Use `app_views_apply` when the user wants explicit table/card/board/gantt views. It publishes by default.
95
+ 11. Use `app_publish_verify` only when the user explicitly wants final publish/live verification or you need an explicit verification pass.
96
+ 12. If a write fails with `APP_EDIT_LOCKED`, stop normal writes. Only use `app_release_edit_lock_if_mine` when the failed result shows the lock owner is the current logged-in user.
97
+
98
+ For view work, keep the order strict:
99
+
100
+ 1. `builder_tool_contract`
101
+ 2. `app_read_fields`
102
+ 3. `app_read_views_summary`
103
+ 4. `app_views_plan`
104
+ 5. `app_views_apply`
105
+ 6. `app_read_views_summary` again whenever `app_views_apply` returns `failed` or `partial_success`
106
+
107
+ For flow work, keep the order strict:
108
+
109
+ 1. `builder_tool_contract`
110
+ 2. `app_read_fields`
111
+ 3. `app_read_flow_summary`
112
+ 4. `role_search` or `member_search` if assignees need to come from the directory
113
+ 5. `role_create` if the user wants a reusable role and no suitable role exists yet
114
+ 6. Start from a canonical preset when possible
115
+ 7. Use patch-style edits to that skeleton instead of freehand full-graph generation
116
+ 8. When patching a preset skeleton, reuse the preset node ids:
117
+ - `basic_approval` -> patch `approve_1`
118
+ - `basic_fill_then_approve` -> patch `fill_1` and `approve_1`
119
+ Do not invent a second approval/fill node id unless you are intentionally replacing the skeleton and removing the preset node.
120
+ 9. Declare approver/fill/copy assignees explicitly:
121
+ - prefer `assignees.role_names`
122
+ - support `assignees.member_names` / `assignees.member_emails` / `assignees.member_uids`
123
+ 10. When a node must edit specific fields, declare `permissions.editable_fields`
124
+ 11. `app_flow_plan`
125
+ 12. `app_flow_apply`
126
+ 13. `app_read_flow_summary` after apply whenever the user asked for verification or apply returns `partial_success`
58
127
 
59
128
  In `prod`, keep `plan` and `apply` as separate phases unless the user explicitly asks for a direct live execution.
60
129
 
@@ -70,10 +139,32 @@ For additive work on existing systems:
70
139
  - When using `package_name`, expect deterministic resolution only on a unique exact package name match; if multiple packages match, stop and resolve the ambiguity instead of guessing
71
140
  - `app_schema_apply` is the only public patch tool allowed to create an app shell; `app_layout_apply`, `app_flow_apply`, and `app_views_apply` require an existing app.
72
141
  - Prefer `*_plan` before `*_apply`; the plan tools do server-side normalization and return the next executable call skeleton.
142
+ - For abstract requests like “默认视图”, “基础审批流”, “灵活流程”, or “美观布局”, first translate the intent into a stable preset or explicit patch. Do not send those phrases to MCP unchanged.
143
+ - If the user asks for a business system or package that contains several forms, do not use the system/package name as `app_name` and do not try to store the child app names as text fields.
144
+ - For flexible workflow requests, split the work into two steps:
145
+ 1. create a base skeleton with a preset
146
+ 2. apply explicit business-specific changes as patchable nodes/transitions
147
+ - For preset-based flows, treat preset node ids as part of the public contract. Patch the skeleton nodes by the same ids instead of creating a parallel node with a new id and leaving the preset node unassigned.
148
+ - Approval, fill, and copy nodes must declare at least one assignee. Treat this as a hard requirement, not an optional detail.
149
+ - For workflow nodes, use the canonical public shape:
150
+ - `assignees.role_names`
151
+ - `assignees.member_names`
152
+ - `permissions.editable_fields`
153
+ - Reuse `app_flow_plan` output directly when it succeeds. Do not rewrite it into internal keys such as `role_entries` or `editable_que_ids`.
154
+ - Reuse `app_views_plan` output directly when it succeeds. Do not re-expand aliases such as `column_names`.
155
+ - For layout work, keep the public section shape canonical:
156
+ - `title`
157
+ - `rows`
158
+ Do not invent top-level layout `columns`, and do not prefer `fields` or `field_ids` once `rows` is known.
159
+ - Translate natural language like “一行四个字段 / 四列布局 / 每行放四个” into `rows` matrices, not guessed layout parameters.
160
+ - If the same layout-shape `VALIDATION_ERROR` repeats twice, stop guessing and re-read `builder_tool_contract(app_layout_plan)` or the layout reference before trying again.
161
+ - Do not guess role ids or member ids. Resolve them from the directory first.
73
162
  - `app_schema_apply` does not treat package attachment as success criteria; if package ownership matters, verify `tag_ids_after` and call `package_attach_app` explicitly.
74
163
  - `package_attach_app` is the source of truth for package ownership; do not assume app creation or publish implicitly attaches the app.
75
164
  - `relation` and `subtable` must be explicit; do not infer them from vague natural language.
165
+ - Another app is not a field. If two business objects should both have their own records, build two apps and connect them with relation fields.
76
166
  - In `prod`, prefer explicit patch tools and avoid any speculative create flow.
167
+ - Never try to bypass collaborative edit locks. `app_release_edit_lock_if_mine` is only for the case where the lock owner is the current authenticated user.
77
168
 
78
169
  ## Response Interpretation
79
170
 
@@ -81,11 +172,24 @@ For additive work on existing systems:
81
172
  - `app_publish_verify` is the publish source of truth.
82
173
  - If readback mismatches the UI, compare `request_route` and do not assume the builder hit the same `qf_version` as the browser
83
174
  - Treat post-write readback as the source of truth, not just write status codes
175
+ - For views, a top-level `VIEW_APPLY_FAILED` does not prove all requested views failed. Read back the view list and verify which views actually landed.
176
+ - For views, “view exists” is not the same as “filters are active”. If `app_views_apply` returns `partial_success`, `views_verified=false`, or `details.filter_mismatches`, report the view as created but the filters as unverified until readback confirms them.
177
+ - If multiple views share the same name, do not guess which one to update. Read `view_key` from `app_read_views_summary` and pass it explicitly in `upsert_views[]`.
178
+ - In final user-facing summaries, distinguish clearly between:
179
+ - contract is visible / canonical shape is known
180
+ - plan succeeded
181
+ - apply landed and readback verified it
182
+ - base template/skeleton applied
183
+ - business-specific rules completed
184
+ - remaining gaps or follow-up patches
185
+ - Do not report “流程已满足业务需求” when only a preset skeleton has landed.
84
186
 
85
187
  ## Practical Patterns
86
188
 
87
189
  - List packages: `package_list`
88
190
  - Resolve one package: `package_resolve`
191
+ - Create one package: `package_create`
192
+ - Read one public tool contract: `builder_tool_contract`
89
193
  - Resolve one app: `app_resolve`
90
194
  - Read one app summary: `app_read_summary`
91
195
  - Read fields only: `app_read_fields`
@@ -96,11 +200,15 @@ For additive work on existing systems:
96
200
  - Plan layout patch: `app_layout_plan`
97
201
  - Plan workflow patch: `app_flow_plan`
98
202
  - Plan view patch: `app_views_plan`
203
+ - Search members for workflow assignees: `member_search`
204
+ - Search roles for workflow assignees: `role_search`
205
+ - Create reusable workflow role: `role_create`
99
206
  - Add/update/remove fields: `app_schema_apply`
100
207
  - Merge or replace layout: `app_layout_apply`
101
208
  - Replace workflow: `app_flow_apply`
102
209
  - Upsert/remove views: `app_views_apply`
103
210
  - Attach one app to a package: `package_attach_app`
211
+ - Release your own stale edit lock: `app_release_edit_lock_if_mine`
104
212
  - Publish and verify: `app_publish_verify` when you need a separate verification pass beyond the default auto-publish behavior in apply tools
105
213
 
106
214
  Detailed playbooks:
@@ -112,5 +220,6 @@ Detailed playbooks:
112
220
  - Update fields only: [references/update-schema.md](references/update-schema.md)
113
221
  - Update layout only: [references/update-layout.md](references/update-layout.md)
114
222
  - Update workflow only: [references/update-flow.md](references/update-flow.md)
223
+ - Workflow assignees and node permissions: [references/flow-actors-and-permissions.md](references/flow-actors-and-permissions.md)
115
224
  - Update views only: [references/update-views.md](references/update-views.md)
116
225
  - Standard end-to-end builder sequences: [references/solution-playbooks.md](references/solution-playbooks.md)
@@ -2,6 +2,20 @@
2
2
 
3
3
  Use this when the user wants one new app inside an existing package.
4
4
 
5
+ Do not use this playbook when the user is really asking for a system/package with multiple forms or modules. In that case:
6
+
7
+ 1. resolve or create the package
8
+ 2. create each app separately
9
+ 3. attach each app to the package
10
+ 4. add relation fields between apps
11
+
12
+ Hierarchy reminder:
13
+
14
+ - package -> app -> field -> relation
15
+ - another business object is another app, not a text field
16
+
17
+ If creating a brand new package would help, ask the user to confirm package creation first. After confirmation, call `package_create` before this sequence.
18
+
5
19
  ## Minimal sequence
6
20
 
7
21
  1. `package_resolve`
@@ -11,8 +25,36 @@ Use this when the user wants one new app inside an existing package.
11
25
  5. `package_attach_app`
12
26
  6. `app_publish_verify` only when the user asks for explicit final verification
13
27
 
28
+ ## Multi-app systems are different
29
+
30
+ If the user says things like:
31
+
32
+ - “创建一个完整应用包”
33
+ - “包含项目、需求、任务、缺陷、团队这几个表单”
34
+ - “这些表单之间建立关联关系”
35
+
36
+ then do not treat that as one app.
37
+
38
+ Use this pattern instead:
39
+
40
+ 1. `package_resolve` or `package_create`
41
+ 2. for each app name, run `app_schema_plan -> app_schema_apply -> package_attach_app`
42
+ 3. once the apps exist, add `relation` fields between them
43
+
14
44
  ## Example
15
45
 
46
+ Create a new package only after the user confirms package creation:
47
+
48
+ ```json
49
+ {
50
+ "tool_name": "package_create",
51
+ "arguments": {
52
+ "profile": "default",
53
+ "package_name": "研发项目管理"
54
+ }
55
+ }
56
+ ```
57
+
16
58
  Resolve the package:
17
59
 
18
60
  ```json
@@ -96,3 +138,11 @@ The create route did not resolve in the current backend route context. Re-run `w
96
138
  ### `PACKAGE_ATTACH_FAILED`
97
139
 
98
140
  Do not retry schema creation. Re-run only `package_attach_app`, then verify with `app_read_summary`.
141
+
142
+ ### Hierarchy modeling mistake
143
+
144
+ If the user asked for several named forms/apps but the draft patch turns them into text fields inside one app, stop and remodel the task as:
145
+
146
+ - one package
147
+ - many apps
148
+ - relation fields between those apps
@@ -43,7 +43,7 @@ Builder behavior in prod:
43
43
  - always identify the target package or app set before changing anything
44
44
  - default to `preflight` or `plan` before any `apply`
45
45
  - additive requirements should modify the existing package with ordinary tools by default
46
- - do not create a new package unless the user explicitly wants package separation
46
+ - if creating a new package seems necessary in prod, ask the user to confirm package creation first
47
47
  - do not seed mock data unless the user explicitly approves it for production
48
48
  - verify is mandatory after writes
49
49
 
@@ -0,0 +1,124 @@
1
+ # Flow Actors And Permissions
2
+
3
+ Use this when the workflow needs real assignees or node-level editable field permissions.
4
+
5
+ ## Canonical policy
6
+
7
+ - Approval, fill, and copy nodes must declare at least one assignee.
8
+ - Prefer roles over explicit members.
9
+ - Resolve directory actors before calling `app_flow_plan` or `app_flow_apply`.
10
+ - Use canonical keys only:
11
+ - `assignees.role_names`
12
+ - `assignees.role_ids`
13
+ - `assignees.member_names`
14
+ - `assignees.member_emails`
15
+ - `assignees.member_uids`
16
+ - `permissions.editable_fields`
17
+
18
+ ## Recommended order
19
+
20
+ 1. `app_read_fields`
21
+ 2. `app_read_flow_summary`
22
+ 3. `role_search`
23
+ 4. `member_search` when the user explicitly names people
24
+ 5. `role_create` when no reusable role exists and the user wants role-based routing
25
+ 6. `app_flow_plan`
26
+ 7. `app_flow_apply`
27
+
28
+ ## Examples
29
+
30
+ ### Route an approval node to a reusable role
31
+
32
+ ```json
33
+ {
34
+ "tool_name": "app_flow_plan",
35
+ "arguments": {
36
+ "profile": "default",
37
+ "app_key": "APP_123",
38
+ "preset": "basic_approval",
39
+ "nodes": [
40
+ {
41
+ "id": "approve_1",
42
+ "type": "approve",
43
+ "name": "部门审批",
44
+ "assignees": {
45
+ "role_names": ["项目经理"]
46
+ }
47
+ }
48
+ ]
49
+ }
50
+ }
51
+ ```
52
+
53
+ ### Route to explicit members when the user names people
54
+
55
+ ```json
56
+ {
57
+ "tool_name": "app_flow_plan",
58
+ "arguments": {
59
+ "profile": "default",
60
+ "app_key": "APP_123",
61
+ "preset": "basic_approval",
62
+ "nodes": [
63
+ {
64
+ "id": "approve_1",
65
+ "type": "approve",
66
+ "name": "部门审批",
67
+ "assignees": {
68
+ "member_names": ["严琪东", "张三"]
69
+ }
70
+ }
71
+ ]
72
+ }
73
+ }
74
+ ```
75
+
76
+ ### Let one node edit selected fields only
77
+
78
+ ```json
79
+ {
80
+ "tool_name": "app_flow_apply",
81
+ "arguments": {
82
+ "profile": "default",
83
+ "app_key": "APP_123",
84
+ "mode": "replace",
85
+ "publish": true,
86
+ "nodes": [
87
+ {"id": "start", "type": "start", "name": "发起"},
88
+ {
89
+ "id": "approve_1",
90
+ "type": "approve",
91
+ "name": "部门审批",
92
+ "assignees": {
93
+ "role_names": ["项目经理"]
94
+ },
95
+ "permissions": {
96
+ "editable_fields": ["状态", "审批意见", "项目负责人"]
97
+ }
98
+ },
99
+ {"id": "end", "type": "end", "name": "结束"}
100
+ ],
101
+ "transitions": [
102
+ {"from": "start", "to": "approve_1"},
103
+ {"from": "approve_1", "to": "end"}
104
+ ]
105
+ }
106
+ }
107
+ ```
108
+
109
+ ## Common recovery
110
+
111
+ ### `ROLE_NOT_FOUND` / `AMBIGUOUS_ROLE`
112
+
113
+ - retry with `role_search`
114
+ - if the business wants a reusable route and no exact role exists, create one with `role_create`
115
+
116
+ ### `MEMBER_NOT_FOUND` / `AMBIGUOUS_MEMBER`
117
+
118
+ - retry with `member_search`
119
+ - do not guess user ids
120
+
121
+ ### `UNKNOWN_FLOW_FIELD`
122
+
123
+ - reread fields with `app_read_fields`
124
+ - only pass real current field names to `permissions.editable_fields`
@@ -11,6 +11,13 @@
11
11
  - Treat `package_attach_app` as the source of truth for package ownership
12
12
  - Check `tag_ids_after` after schema writes
13
13
 
14
+ ## Package vs app vs field
15
+
16
+ - A package/system is not an app
17
+ - Another app is not a field
18
+ - If the user names multiple forms/modules that relate to each other, create multiple apps and connect them with relation fields
19
+ - Do not use child app names like “项目/需求/任务/缺陷/团队” as plain text fields inside one app
20
+
14
21
  ## Auto publish
15
22
 
16
23
  - `app_schema_apply`, `app_layout_apply`, `app_flow_apply`, and `app_views_apply` publish by default
@@ -23,10 +30,16 @@
23
30
  - Use `app_read_fields` before schema or view work
24
31
  - Use `app_read_layout_summary` before layout work
25
32
  - Use `app_read_flow_summary` before workflow work
33
+ - Use `app_read_views_summary` before view work
26
34
 
27
35
  ## Workflow dependencies
28
36
 
29
37
  - Approval-style flows usually require an explicit status field
38
+ - Approval, fill, and copy nodes also require at least one assignee
39
+ - Prefer roles over explicit members unless the user explicitly names people
40
+ - Resolve assignees with `role_search` / `member_search` before flow apply
41
+ - Use `permissions.editable_fields` for node-level editable field permissions; do not guess field ids
42
+ - Preset node ids matter. When patching `basic_approval` or `basic_fill_then_approve`, reuse `approve_1` and `fill_1` unless you are explicitly replacing the skeleton.
30
43
  - If `app_flow_plan` reports `FLOW_DEPENDENCY_MISSING`, fix schema first
31
44
  - Do not switch to hidden `solution_*` tools from public builder flows
32
45
 
@@ -35,3 +48,17 @@
35
48
  - If a write returns `partial_success`, read back before retrying
36
49
  - Do not repeat create steps after `app_key` already exists
37
50
  - For backend rejects, keep the retry narrow: retry only the failed tool, not the whole chain
51
+ - For `VALIDATION_ERROR`, do not keep guessing. Reuse `suggested_next_call`, `canonical_arguments`, `allowed_keys`, and `allowed_values` first.
52
+ - For layout `VALIDATION_ERROR`, also inspect `section_allowed_keys`, `section_aliases`, and `minimal_section_example`. If the same layout-shape error repeats twice, stop free-form retries and re-read `builder_tool_contract(app_layout_plan)`.
53
+ - For flow work, do not replay internal keys from old logs or plan outputs. Public builder calls should stay on:
54
+ - `assignees.role_ids` / `assignees.member_uids` / `assignees.member_emails`
55
+ - `permissions.editable_fields`
56
+ - For view work, treat `columns` as the only canonical public key. `app_read_views_summary` and `app_views_plan/apply` should all be read and written in that shape.
57
+ - For layout work, treat `title + rows` as the only canonical public section shape. `fields`, `field_ids`, and `columns` may appear in legacy/internal shapes, but they are not the preferred public write shape.
58
+ - A created view is not enough to claim a filter succeeded. When `app_views_apply` returns `partial_success`, `views_verified=false`, or `details.filter_mismatches`, treat the view as present but the filter as unverified.
59
+ - If duplicate view names exist, do not retry by name. Read the exact `view_key` and target that one.
60
+ - If a view or flow write fails, report the smallest next action:
61
+ - wrong key -> switch to canonical key
62
+ - unsupported preset -> switch to allowed canonical preset
63
+ - backend reject -> re-read summary and retry only the failed patch
64
+ - Do not translate abstract user phrases like “灵活流程” or “默认视图” directly into MCP arguments. First convert them to a preset or explicit patch plan.
@@ -29,16 +29,23 @@ Prefer `mode=merge`. Use `mode=replace` only when every field placement is inten
29
29
  ## Add or update workflow
30
30
 
31
31
  1. `app_read_fields`
32
- 2. `app_flow_plan`
33
- 3. `app_flow_apply`
32
+ 2. `app_read_flow_summary`
33
+ 3. `role_search` or `member_search`
34
+ 4. `role_create` if the business wants a reusable role and no good exact role exists
35
+ 5. `app_flow_plan`
36
+ 6. `app_flow_apply`
34
37
 
35
38
  If `app_flow_plan` reports `FLOW_DEPENDENCY_MISSING`, fix schema first.
39
+ If it reports `FLOW_ASSIGNEE_REQUIRED`, resolve roles or members first and retry with canonical `assignees.*`.
36
40
 
37
41
  ## Add or update views
38
42
 
39
43
  1. `app_read_fields`
40
- 2. `app_views_plan`
41
- 3. `app_views_apply`
44
+ 2. `app_read_views_summary`
45
+ 3. `app_views_plan`
46
+ 4. `app_views_apply`
47
+
48
+ For both workflow and view work, prefer `suggested_next_call` over re-guessing arguments after a validation failure.
42
49
 
43
50
  ## Final readback
44
51
 
@@ -8,10 +8,25 @@ Use the smallest v2 builder tool chain that can finish the task.
8
8
 
9
9
  Use `plan` before `apply` unless the patch is trivial and already normalized.
10
10
 
11
+ ## Hierarchy first
12
+
13
+ Before picking tools, decide which layer the request targets:
14
+
15
+ - `package`: a solution/app bundle like “研发项目管理” or “费控管理系统”
16
+ - `app`: one form/app inside that package
17
+ - `field`: one field inside one app
18
+ - `relation`: a field that links two apps
19
+
20
+ If the user asks for multiple forms/modules that relate to each other, this is a package-level multi-app task, not a single-app create.
21
+
11
22
  ## Resolve
12
23
 
24
+ - `package_create`: create a new package only after the user confirms package creation; exact-name duplicates return `noop=true`
13
25
  - `package_resolve`: exact package lookup by name
14
26
  - `package_list`: read-only fallback when package resolution is ambiguous
27
+ - `member_search`: resolve named people from the directory
28
+ - `role_search`: resolve reusable roles from the directory
29
+ - `role_create`: create a reusable role when the business owner wants role-based routing
15
30
  - `app_resolve`: locate an existing app by `app_key` or `app_name`
16
31
 
17
32
  ## Summary reads
@@ -31,6 +46,8 @@ Use these when the patch is non-trivial or the model is likely to drift.
31
46
  - `app_flow_plan`: validate workflow nodes, transitions, and dependencies
32
47
  - `app_views_plan`: normalize view aliases and validate referenced fields
33
48
 
49
+ Use `builder_tool_contract` before guessing keys, aliases, presets, or enum values.
50
+
34
51
  ## Apply tools
35
52
 
36
53
  These execute normalized patches and publish by default unless `publish=false`.
@@ -49,17 +66,31 @@ These execute normalized patches and publish by default unless `publish=false`.
49
66
 
50
67
  - Create one app inside an existing package:
51
68
  `package_resolve -> app_resolve -> app_schema_plan -> app_schema_apply -> package_attach_app`
69
+ - Create a brand new package, then create one app in it:
70
+ `package_create -> package_resolve -> app_schema_plan -> app_schema_apply -> package_attach_app`
71
+ - Create a brand new multi-app system/package:
72
+ `package_create/resolve -> per-app app_schema_plan/apply -> package_attach_app per app -> relation field patches`
52
73
  - Update fields on an existing app:
53
74
  `app_resolve -> app_read_fields -> app_schema_plan -> app_schema_apply`
54
75
  - Tidy layout:
55
- `app_read_layout_summary -> app_layout_plan -> app_layout_apply`
76
+ `app_read_fields -> app_read_layout_summary -> builder_tool_contract (if shape is unclear) -> app_layout_plan -> app_layout_apply`
56
77
  - Add workflow:
57
- `app_read_fields -> app_flow_plan -> app_flow_apply`
78
+ `builder_tool_contract -> app_read_fields -> app_read_flow_summary -> role_search/member_search -> app_flow_plan -> app_flow_apply -> app_read_flow_summary`
58
79
  - Add views:
59
- `app_read_fields -> app_views_plan -> app_views_apply`
80
+ `builder_tool_contract -> app_read_fields -> app_read_views_summary -> app_views_plan -> app_views_apply -> app_read_views_summary`
60
81
 
61
82
  ## Avoid
62
83
 
63
84
  - Do not handcraft raw Qingflow schema payloads
64
85
  - Do not rely on internal `solution_*` tools in public builder flows
65
- - Do not create a new package unless the user explicitly asks for package separation
86
+ - Do not create a new package without first asking the user to confirm package creation
87
+ - Do not treat a package/system name as `app_name` when the user clearly wants multiple apps inside it
88
+ - Do not compress multiple business objects into one app with several text fields
89
+ - Do not skip summary reads before flow or view work
90
+ - Do not emit `column_names`; always use `columns`
91
+ - Do not model layout shape with `fields`, `field_ids`, or top-level `columns`; custom layout sections should be `title + rows`
92
+ - Do not reuse internal flow keys such as `role_entries` or `editable_que_ids` in public builder calls
93
+ - Do not pass natural-language preset guesses such as `default_approval`; map them to canonical preset values first
94
+ - Do not omit assignees on approval/fill/copy nodes
95
+ - Do not patch preset flows with brand new approval/fill node ids unless you are intentionally replacing the skeleton; reuse preset ids like `approve_1` and `fill_1`
96
+ - Do not guess role ids, member ids, or editable field ids; resolve names first