@josephyan/qingflow-app-builder-mcp 0.2.0-beta.4 → 0.2.0-beta.40

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 (36) 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 +142 -22
  5. package/skills/qingflow-app-builder/references/create-app.md +51 -21
  6. package/skills/qingflow-app-builder/references/environments.md +1 -1
  7. package/skills/qingflow-app-builder/references/flow-actors-and-permissions.md +123 -0
  8. package/skills/qingflow-app-builder/references/gotchas.md +28 -1
  9. package/skills/qingflow-app-builder/references/solution-playbooks.md +14 -12
  10. package/skills/qingflow-app-builder/references/tool-selection.md +45 -17
  11. package/skills/qingflow-app-builder/references/update-flow.md +141 -13
  12. package/skills/qingflow-app-builder/references/update-layout.md +11 -24
  13. package/skills/qingflow-app-builder/references/update-schema.md +1 -23
  14. package/skills/qingflow-app-builder/references/update-views.md +87 -21
  15. package/src/qingflow_mcp/__init__.py +1 -1
  16. package/src/qingflow_mcp/builder_facade/models.py +576 -1
  17. package/src/qingflow_mcp/builder_facade/service.py +4193 -258
  18. package/src/qingflow_mcp/config.py +39 -0
  19. package/src/qingflow_mcp/list_type_labels.py +24 -0
  20. package/src/qingflow_mcp/server.py +120 -16
  21. package/src/qingflow_mcp/server_app_builder.py +132 -72
  22. package/src/qingflow_mcp/server_app_user.py +130 -187
  23. package/src/qingflow_mcp/solution/compiler/form_compiler.py +1 -1
  24. package/src/qingflow_mcp/solution/compiler/workflow_compiler.py +21 -2
  25. package/src/qingflow_mcp/solution/executor.py +34 -7
  26. package/src/qingflow_mcp/tools/ai_builder_tools.py +1640 -144
  27. package/src/qingflow_mcp/tools/app_tools.py +243 -14
  28. package/src/qingflow_mcp/tools/approval_tools.py +411 -76
  29. package/src/qingflow_mcp/tools/directory_tools.py +203 -31
  30. package/src/qingflow_mcp/tools/feedback_tools.py +230 -0
  31. package/src/qingflow_mcp/tools/file_tools.py +1 -0
  32. package/src/qingflow_mcp/tools/portal_tools.py +31 -0
  33. package/src/qingflow_mcp/tools/record_tools.py +4862 -1051
  34. package/src/qingflow_mcp/tools/task_context_tools.py +1063 -0
  35. package/src/qingflow_mcp/tools/task_tools.py +376 -225
  36. 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.4
6
+ npm install @josephyan/qingflow-app-builder-mcp@0.2.0-beta.40
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.4 qingflow-app-builder-mcp
12
+ npx -y -p @josephyan/qingflow-app-builder-mcp@0.2.0-beta.40 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.4",
3
+ "version": "0.2.0-beta.40",
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.0b4"
7
+ version = "0.2.0b40"
8
8
  description = "User-authenticated MCP server for Qingflow"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -17,23 +17,69 @@ 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
+ ## Shared Helper
21
+
22
+ - `feedback_submit` is a cross-cutting helper for product feedback submission
23
+ - It does not require Qingflow login or workspace selection
24
+ - If builder capability is unsupported or still cannot satisfy the need after reasonable use, summarize the gap, ask whether to submit feedback, and call `feedback_submit` only after explicit user confirmation.
25
+
26
+ ## Mental Model
27
+
28
+ Model builder requests in four layers. Do not flatten them.
29
+
30
+ - `package`: the solution container or app bundle, for example “研发项目管理” or “费控管理系统”
31
+ - `app`: one form/app inside that package, for example “项目”, “需求”, “任务”, “缺陷”, “团队”
32
+ - `field`: one field inside one app
33
+ - `relation`: a field that links one app to another app
34
+
35
+ Interpret user intent with this hierarchy:
36
+
37
+ - If the user says “应用包”, “系统”, “包含多个表单”, “多个模块”, or asks for several named forms that relate to each other, treat it as a `package` with multiple `apps`
38
+ - Do not compress a multi-app system into one app with several text fields
39
+ - Names like “项目/需求/任务/缺陷/团队” or “费用申请/预算管理/报销审批” are usually separate apps, not text fields
40
+ - Build the apps first, then add `relation` fields to connect them
41
+
42
+ Default modeling rules:
43
+
44
+ - One business object -> one app
45
+ - Attributes of that object -> fields inside that app
46
+ - Another business object -> a separate app, not a text field
47
+ - Cross-object links -> relation fields, not text fields
48
+
20
49
  - Authentication and workspace: `auth_*`, `workspace_*`
21
50
  - 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`
23
- - 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`
51
+ - 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`, `app_read_charts_summary`, `portal_read_summary`
52
+ - Resource patch: `app_schema_apply`, `app_layout_apply`, `app_flow_apply`, `app_views_apply`, `app_charts_apply`, `portal_apply`, `package_attach_app`, `app_release_edit_lock_if_mine`, `role_create`
25
53
  - Publish and verify: `app_publish_verify`
26
54
 
27
55
  Note:
28
56
  - Do not try to handcraft raw Qingflow schema or internal solution payloads.
29
- - Do not rely on low-level `view_*`, `workflow_*`, or `qingbi_report_*` write payloads from public builder flows.
30
- - Public builder work should stay on the resource path: `resolve -> summary read -> plan -> apply -> attach -> publish_verify`.
57
+ - Do not rely on low-level `view_*`, `workflow_*`, `qingbi_report_*`, or `portal_*` write payloads from public builder flows.
58
+ - Public builder work should stay on the resource path: `resolve -> summary read -> apply -> attach -> publish_verify`.
31
59
  - `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.
60
+ - `app_charts_apply` is immediate-live and does not publish; it resolves targets by `chart_id` first and then exact unique chart name.
61
+ - `portal_apply` uses replace semantics for sections; remove a section by omitting it from the next full sections list. `publish=false` only guarantees draft/base-info updates, and `chart_ref/view_ref` resolve by `id/key` first and exact unique name second.
62
+ - `app_read_charts_summary` is the compact discovery path for current chart inventory; use it before `app_charts_apply` when you need exact `chart_id` values.
63
+ - `portal_read_summary` is the compact discovery path for portal draft/live summaries; it returns section summaries, not the raw dash payload.
64
+ - `app_schema_apply` / `app_layout_apply` / `app_flow_apply` / `app_views_apply` now perform planning, normalization, and dependency checks internally; when prechecks block, read the returned blocking issues and `suggested_next_call` directly from the apply result.
65
+ - If you are unsure about a public builder tool's keys, aliases, presets, or minimal legal shape, call `builder_tool_contract` instead of guessing.
66
+ - 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.
67
+ - For flow presets, map natural language to canonical values before calling MCP:
68
+ - “默认审批/基础审批/普通审批” -> `basic_approval`
69
+ - “先填报再审批/提交后审批” -> `basic_fill_then_approve`
70
+ - 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.
71
+ - For workflow assignees, prefer roles over explicit members:
72
+ - use `role_search` first
73
+ - use `member_search` only when the user explicitly names members or no stable role exists
74
+ - use `role_create` when the business owner wants a reusable directory role instead of hard-coded members
75
+ - On any `VALIDATION_ERROR`, inspect `suggested_next_call` first and prefer reusing the MCP-normalized arguments over re-guessing from the original natural language.
76
+ - If the current MCP capability is unsupported, the workflow is awkward, or the user's need still cannot be satisfied after reasonable use, summarize the gap, ask whether to submit feedback, and call `feedback_submit` only after explicit user confirmation.
32
77
 
33
78
  Default policy:
34
79
 
35
- - 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.
80
+ - Creating or updating one app inside an existing package: resolve the package/app, read compact state, then apply schema/layout/flow/views patches explicitly.
81
+ - If package creation looks necessary or beneficial, ask the user to confirm before calling `package_create`.
82
+ - 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
83
 
38
84
  ## Standard Operating Order
39
85
 
@@ -45,18 +91,51 @@ Before any business tool:
45
91
 
46
92
  For builder work:
47
93
 
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.
94
+ 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`.
95
+ 2. Decide whether the target is one app or a multi-app package:
96
+ - one app: continue with `app_resolve`
97
+ - multi-app package/system: create or resolve the package, then create each app separately before adding relations
98
+ 3. Resolve the target app with `app_resolve` if the request is an update.
99
+ 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`, `app_read_charts_summary`, `portal_read_summary`.
100
+ 5. Use `app_schema_apply` for create/upsert/remove field work. It publishes by default after the patch lands; noop schema requests do not publish.
53
101
  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.
102
+ 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 after the patch lands; noop layout requests do not publish.
103
+ 8. Use `app_flow_apply` after schema exists. It publishes by default; pass `publish=false` when you only want draft/precheck behavior.
104
+ 9. Use `app_views_apply` when the user wants explicit table/card/board/gantt views. It publishes by default after the patch lands; noop view requests do not publish.
57
105
  10. Use `app_publish_verify` only when the user explicitly wants final publish/live verification or you need an explicit verification pass.
58
-
59
- In `prod`, keep `plan` and `apply` as separate phases unless the user explicitly asks for a direct live execution.
106
+ 11. 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.
107
+
108
+ For view work, keep the order strict:
109
+
110
+ 1. `builder_tool_contract`
111
+ 2. `app_read_fields`
112
+ 3. `app_read_views_summary`
113
+ 4. `app_views_apply`
114
+ 5. `app_read_views_summary` again whenever `app_views_apply` returns `failed` or `partial_success`
115
+
116
+ For flow work, keep the order strict:
117
+
118
+ 1. `builder_tool_contract`
119
+ 2. `app_read_fields`
120
+ 3. `app_read_flow_summary`
121
+ 4. `role_search` or `member_search` if assignees need to come from the directory
122
+ 5. `role_create` if the user wants a reusable role and no suitable role exists yet
123
+ 6. Start from a canonical preset when possible
124
+ 7. Use patch-style edits to that skeleton instead of freehand full-graph generation
125
+ 8. When patching a preset skeleton, reuse the preset node ids:
126
+ - `basic_approval` -> patch `approve_1`
127
+ - `basic_fill_then_approve` -> patch `fill_1` and `approve_1`
128
+ Do not invent a second approval/fill node id unless you are intentionally replacing the skeleton and removing the preset node.
129
+ 9. Declare approver/fill/copy assignees explicitly:
130
+ - prefer `assignees.role_names`
131
+ - support `assignees.member_names` / `assignees.member_emails` / `assignees.member_uids`
132
+ 10. When a node must edit specific fields, declare `permissions.editable_fields`
133
+ 11. `app_flow_apply`
134
+ 12. `app_read_flow_summary` after apply whenever the user asked for verification or apply returns `partial_success`
135
+ 13. Use `app_read_charts_summary` before chart work whenever exact current `chart_id` values matter
136
+ 14. Use `app_charts_apply` for QingBI chart creation and updates, not raw `qingbi_report_*` writes
137
+ 15. Use `portal_read_summary` before portal work whenever exact current draft/live section inventory matters
138
+ 16. Use `portal_apply` for builder-side portal work; treat sections as a full replacement list
60
139
 
61
140
  For additive work on existing systems:
62
141
 
@@ -69,38 +148,78 @@ For additive work on existing systems:
69
148
 
70
149
  - 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
150
  - `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
- - Prefer `*_plan` before `*_apply`; the plan tools do server-side normalization and return the next executable call skeleton.
151
+ - Prefer reading compact state plus `builder_tool_contract` before `*_apply`; apply already performs server-side normalization and returns blocking issues or the next executable call shape when needed.
152
+ - For abstract requests like “默认视图”, “基础审批流”, “灵活流程”, or “美观布局”, first translate the intent into a stable preset or explicit patch. Do not send those phrases to MCP unchanged.
153
+ - 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.
154
+ - For flexible workflow requests, split the work into two steps:
155
+ 1. create a base skeleton with a preset
156
+ 2. apply explicit business-specific changes as patchable nodes/transitions
157
+ - 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.
158
+ - Approval, fill, and copy nodes must declare at least one assignee. Treat this as a hard requirement, not an optional detail.
159
+ - For workflow nodes, use the canonical public shape:
160
+ - `assignees.role_names`
161
+ - `assignees.member_names`
162
+ - `permissions.editable_fields`
163
+ - For layout work, keep the public section shape canonical:
164
+ - `title`
165
+ - `rows`
166
+ Do not invent top-level layout `columns`, and do not prefer `fields` or `field_ids` once `rows` is known.
167
+ - Translate natural language like “一行四个字段 / 四列布局 / 每行放四个” into `rows` matrices, not guessed layout parameters.
168
+ - If the same layout-shape `VALIDATION_ERROR` repeats twice, stop guessing and re-read `builder_tool_contract(app_layout_apply)` or the layout reference before trying again.
169
+ - Do not guess role ids or member ids. Resolve them from the directory first.
73
170
  - `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
171
  - `package_attach_app` is the source of truth for package ownership; do not assume app creation or publish implicitly attaches the app.
75
172
  - `relation` and `subtable` must be explicit; do not infer them from vague natural language.
173
+ - 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
174
  - In `prod`, prefer explicit patch tools and avoid any speculative create flow.
175
+ - 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
176
 
78
177
  ## Response Interpretation
79
178
 
80
179
  - low-level list totals from the backend may report `0` while rows are present; prefer summary or aggregate readbacks for final conclusions
81
180
  - `app_publish_verify` is the publish source of truth.
181
+ - All public builder tools expose top-level `warnings`, `verification`, and `verified`. Read them before deciding whether a run is fully done.
182
+ - For read tools, `status=success` can still pair with `verified=false` when some optional readback is unavailable; in that case prefer `warnings` and `verification` over the bare status code.
183
+ - For `app_charts_apply`, `portal_apply`, and `app_publish_verify`, treat `success` as “write and verification completed” and `partial_success` as “write executed but verification is incomplete”.
82
184
  - If readback mismatches the UI, compare `request_route` and do not assume the builder hit the same `qf_version` as the browser
83
185
  - Treat post-write readback as the source of truth, not just write status codes
186
+ - 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.
187
+ - 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.
188
+ - 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[]`.
189
+ - In final user-facing summaries, distinguish clearly between:
190
+ - contract is visible / canonical shape is known
191
+ - apply precheck succeeded
192
+ - apply landed and readback verified it
193
+ - base template/skeleton applied
194
+ - business-specific rules completed
195
+ - remaining gaps or follow-up patches
196
+ - Do not report “流程已满足业务需求” when only a preset skeleton has landed.
84
197
 
85
198
  ## Practical Patterns
86
199
 
87
200
  - List packages: `package_list`
88
201
  - Resolve one package: `package_resolve`
202
+ - Create one package: `package_create`
203
+ - Read one public tool contract: `builder_tool_contract`
89
204
  - Resolve one app: `app_resolve`
90
205
  - Read one app summary: `app_read_summary`
91
206
  - Read fields only: `app_read_fields`
92
207
  - Read layout summary: `app_read_layout_summary`
93
208
  - Read views summary: `app_read_views_summary`
94
209
  - Read flow summary: `app_read_flow_summary`
95
- - Plan schema patch: `app_schema_plan`
96
- - Plan layout patch: `app_layout_plan`
97
- - Plan workflow patch: `app_flow_plan`
98
- - Plan view patch: `app_views_plan`
210
+ - Read chart summary: `app_read_charts_summary`
211
+ - Read portal summary: `portal_read_summary`
212
+ - Search members for workflow assignees: `member_search`
213
+ - Search roles for workflow assignees: `role_search`
214
+ - Create reusable workflow role: `role_create`
99
215
  - Add/update/remove fields: `app_schema_apply`
100
216
  - Merge or replace layout: `app_layout_apply`
101
217
  - Replace workflow: `app_flow_apply`
102
218
  - Upsert/remove views: `app_views_apply`
219
+ - Upsert/remove/reorder QingBI charts: `app_charts_apply`
220
+ - Create or replace-update portal pages: `portal_apply`
103
221
  - Attach one app to a package: `package_attach_app`
222
+ - Release your own stale edit lock: `app_release_edit_lock_if_mine`
104
223
  - Publish and verify: `app_publish_verify` when you need a separate verification pass beyond the default auto-publish behavior in apply tools
105
224
 
106
225
  Detailed playbooks:
@@ -112,5 +231,6 @@ Detailed playbooks:
112
231
  - Update fields only: [references/update-schema.md](references/update-schema.md)
113
232
  - Update layout only: [references/update-layout.md](references/update-layout.md)
114
233
  - Update workflow only: [references/update-flow.md](references/update-flow.md)
234
+ - Workflow assignees and node permissions: [references/flow-actors-and-permissions.md](references/flow-actors-and-permissions.md)
115
235
  - Update views only: [references/update-views.md](references/update-views.md)
116
236
  - Standard end-to-end builder sequences: [references/solution-playbooks.md](references/solution-playbooks.md)
@@ -2,52 +2,71 @@
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`
8
22
  2. `app_resolve`
9
- 3. `app_schema_plan`
10
- 4. `app_schema_apply`
11
- 5. `package_attach_app`
12
- 6. `app_publish_verify` only when the user asks for explicit final verification
23
+ 3. `app_schema_apply`
24
+ 4. `package_attach_app`
25
+ 5. `app_publish_verify` only when the user asks for explicit final verification
26
+
27
+ ## Multi-app systems are different
28
+
29
+ If the user says things like:
30
+
31
+ - “创建一个完整应用包”
32
+ - “包含项目、需求、任务、缺陷、团队这几个表单”
33
+ - “这些表单之间建立关联关系”
34
+
35
+ then do not treat that as one app.
36
+
37
+ Use this pattern instead:
38
+
39
+ 1. `package_resolve` or `package_create`
40
+ 2. for each app name, run `app_schema_apply -> package_attach_app`
41
+ 3. once the apps exist, add `relation` fields between them
13
42
 
14
43
  ## Example
15
44
 
16
- Resolve the package:
45
+ Create a new package only after the user confirms package creation:
17
46
 
18
47
  ```json
19
48
  {
20
- "tool_name": "package_resolve",
49
+ "tool_name": "package_create",
21
50
  "arguments": {
22
51
  "profile": "default",
23
- "package_name": "测试应用包"
52
+ "package_name": "研发项目管理"
24
53
  }
25
54
  }
26
55
  ```
27
56
 
28
- Plan schema for a new app:
57
+ Resolve the package:
29
58
 
30
59
  ```json
31
60
  {
32
- "tool_name": "app_schema_plan",
61
+ "tool_name": "package_resolve",
33
62
  "arguments": {
34
63
  "profile": "default",
35
- "app_name": "客户订单",
36
- "package_tag_id": 1218950,
37
- "create_if_missing": true,
38
- "add_fields": [
39
- {"name": "订单编号", "type": "text", "required": true},
40
- {"name": "客户名称", "type": "text", "required": true},
41
- {"name": "订单金额", "type": "amount"},
42
- {"name": "状态", "type": "single_select", "options": ["草稿", "进行中", "已完成"], "required": true}
43
- ],
44
- "update_fields": [],
45
- "remove_fields": []
64
+ "package_name": "测试应用包"
46
65
  }
47
66
  }
48
67
  ```
49
68
 
50
- Apply schema. This publishes by default:
69
+ Apply schema for a new app:
51
70
 
52
71
  ```json
53
72
  {
@@ -68,6 +87,9 @@ Apply schema. This publishes by default:
68
87
  "remove_fields": []
69
88
  }
70
89
  }
90
+ ```
91
+ }
92
+ }
71
93
  ```
72
94
 
73
95
  Attach explicitly if `tag_ids_after` does not yet contain the package:
@@ -96,3 +118,11 @@ The create route did not resolve in the current backend route context. Re-run `w
96
118
  ### `PACKAGE_ATTACH_FAILED`
97
119
 
98
120
  Do not retry schema creation. Re-run only `package_attach_app`, then verify with `app_read_summary`.
121
+
122
+ ### Hierarchy modeling mistake
123
+
124
+ 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:
125
+
126
+ - one package
127
+ - many apps
128
+ - 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,123 @@
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_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_apply`
26
+
27
+ ## Examples
28
+
29
+ ### Route an approval node to a reusable role
30
+
31
+ ```json
32
+ {
33
+ "tool_name": "app_flow_apply",
34
+ "arguments": {
35
+ "profile": "default",
36
+ "app_key": "APP_123",
37
+ "preset": "basic_approval",
38
+ "nodes": [
39
+ {
40
+ "id": "approve_1",
41
+ "type": "approve",
42
+ "name": "部门审批",
43
+ "assignees": {
44
+ "role_names": ["项目经理"]
45
+ }
46
+ }
47
+ ]
48
+ }
49
+ }
50
+ ```
51
+
52
+ ### Route to explicit members when the user names people
53
+
54
+ ```json
55
+ {
56
+ "tool_name": "app_flow_apply",
57
+ "arguments": {
58
+ "profile": "default",
59
+ "app_key": "APP_123",
60
+ "preset": "basic_approval",
61
+ "nodes": [
62
+ {
63
+ "id": "approve_1",
64
+ "type": "approve",
65
+ "name": "部门审批",
66
+ "assignees": {
67
+ "member_names": ["严琪东", "张三"]
68
+ }
69
+ }
70
+ ]
71
+ }
72
+ }
73
+ ```
74
+
75
+ ### Let one node edit selected fields only
76
+
77
+ ```json
78
+ {
79
+ "tool_name": "app_flow_apply",
80
+ "arguments": {
81
+ "profile": "default",
82
+ "app_key": "APP_123",
83
+ "mode": "replace",
84
+ "publish": true,
85
+ "nodes": [
86
+ {"id": "start", "type": "start", "name": "发起"},
87
+ {
88
+ "id": "approve_1",
89
+ "type": "approve",
90
+ "name": "部门审批",
91
+ "assignees": {
92
+ "role_names": ["项目经理"]
93
+ },
94
+ "permissions": {
95
+ "editable_fields": ["状态", "审批意见", "项目负责人"]
96
+ }
97
+ },
98
+ {"id": "end", "type": "end", "name": "结束"}
99
+ ],
100
+ "transitions": [
101
+ {"from": "start", "to": "approve_1"},
102
+ {"from": "approve_1", "to": "end"}
103
+ ]
104
+ }
105
+ }
106
+ ```
107
+
108
+ ## Common recovery
109
+
110
+ ### `ROLE_NOT_FOUND` / `AMBIGUOUS_ROLE`
111
+
112
+ - retry with `role_search`
113
+ - if the business wants a reusable route and no exact role exists, create one with `role_create`
114
+
115
+ ### `MEMBER_NOT_FOUND` / `AMBIGUOUS_MEMBER`
116
+
117
+ - retry with `member_search`
118
+ - do not guess user ids
119
+
120
+ ### `UNKNOWN_FLOW_FIELD`
121
+
122
+ - reread fields with `app_read_fields`
123
+ - 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,11 +30,17 @@
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
30
- - If `app_flow_plan` reports `FLOW_DEPENDENCY_MISSING`, fix schema first
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.
43
+ - If `app_flow_apply` reports `FLOW_DEPENDENCY_MISSING`, fix schema first
31
44
  - Do not switch to hidden `solution_*` tools from public builder flows
32
45
 
33
46
  ## Retry discipline
@@ -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_apply)`.
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_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.
@@ -6,40 +6,42 @@ Use these when you need a quick reminder of the standard v2 builder sequences.
6
6
 
7
7
  1. `package_resolve`
8
8
  2. `app_resolve`
9
- 3. `app_schema_plan`
10
- 4. `app_schema_apply`
11
- 5. `package_attach_app`
12
- 6. `app_publish_verify` only if the user asks for explicit live verification
9
+ 3. `app_schema_apply`
10
+ 4. `package_attach_app`
11
+ 5. `app_publish_verify` only if the user asks for explicit live verification
13
12
 
14
13
  ## Update fields on an existing app
15
14
 
16
15
  1. `app_resolve`
17
16
  2. `app_read_fields`
18
- 3. `app_schema_plan`
19
- 4. `app_schema_apply`
17
+ 3. `app_schema_apply`
20
18
 
21
19
  ## Rework layout
22
20
 
23
21
  1. `app_read_layout_summary`
24
- 2. `app_layout_plan`
25
- 3. `app_layout_apply`
22
+ 2. `app_layout_apply`
26
23
 
27
24
  Prefer `mode=merge`. Use `mode=replace` only when every field placement is intentional.
28
25
 
29
26
  ## Add or update workflow
30
27
 
31
28
  1. `app_read_fields`
32
- 2. `app_flow_plan`
33
- 3. `app_flow_apply`
29
+ 2. `app_read_flow_summary`
30
+ 3. `role_search` or `member_search`
31
+ 4. `role_create` if the business wants a reusable role and no good exact role exists
32
+ 5. `app_flow_apply`
34
33
 
35
- If `app_flow_plan` reports `FLOW_DEPENDENCY_MISSING`, fix schema first.
34
+ If `app_flow_apply` reports `FLOW_DEPENDENCY_MISSING`, fix schema first.
35
+ If it reports `FLOW_ASSIGNEE_REQUIRED`, resolve roles or members first and retry with canonical `assignees.*`.
36
36
 
37
37
  ## Add or update views
38
38
 
39
39
  1. `app_read_fields`
40
- 2. `app_views_plan`
40
+ 2. `app_read_views_summary`
41
41
  3. `app_views_apply`
42
42
 
43
+ For both workflow and view work, prefer `suggested_next_call` over re-guessing arguments after a validation failure.
44
+
43
45
  ## Final readback
44
46
 
45
47
  Prefer these fields after writes: