@qingflow-tech/qingflow-app-user-mcp 1.0.11 → 1.0.12

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 (86) hide show
  1. package/README.md +9 -3
  2. package/docs/local-agent-install.md +54 -3
  3. package/entry_point.py +1 -1
  4. package/npm/bin/qingflow-skills.mjs +5 -0
  5. package/npm/lib/runtime.mjs +304 -13
  6. package/npm/scripts/postinstall.mjs +1 -5
  7. package/package.json +3 -2
  8. package/pyproject.toml +1 -1
  9. package/skills/qingflow-app-builder/SKILL.md +255 -0
  10. package/skills/qingflow-app-builder/agents/openai.yaml +4 -0
  11. package/skills/qingflow-app-builder/references/create-app.md +149 -0
  12. package/skills/qingflow-app-builder/references/environments.md +63 -0
  13. package/skills/qingflow-app-builder/references/flow-actors-and-permissions.md +123 -0
  14. package/skills/qingflow-app-builder/references/gotchas.md +107 -0
  15. package/skills/qingflow-app-builder/references/match-rules.md +114 -0
  16. package/skills/qingflow-app-builder/references/public-surface-sync.md +75 -0
  17. package/skills/qingflow-app-builder/references/solution-playbooks.md +52 -0
  18. package/skills/qingflow-app-builder/references/tool-selection.md +99 -0
  19. package/skills/qingflow-app-builder/references/update-flow.md +158 -0
  20. package/skills/qingflow-app-builder/references/update-layout.md +68 -0
  21. package/skills/qingflow-app-builder/references/update-schema.md +72 -0
  22. package/skills/qingflow-app-builder/references/update-views.md +284 -0
  23. package/skills/qingflow-app-builder-code-integrations/SKILL.md +137 -0
  24. package/skills/qingflow-app-builder-code-integrations/agents/openai.yaml +4 -0
  25. package/skills/qingflow-app-builder-code-integrations/references/code-block.md +66 -0
  26. package/skills/qingflow-app-builder-code-integrations/references/q-linker.md +77 -0
  27. package/skills/qingflow-app-user/SKILL.md +12 -11
  28. package/skills/qingflow-app-user/references/data-gotchas.md +2 -2
  29. package/skills/qingflow-app-user/references/public-surface-sync.md +3 -3
  30. package/skills/qingflow-app-user/references/record-patterns.md +5 -5
  31. package/skills/qingflow-app-user/references/workflow-usage.md +4 -5
  32. package/skills/qingflow-mcp-setup/SKILL.md +113 -0
  33. package/skills/qingflow-mcp-setup/agents/openai.yaml +4 -0
  34. package/skills/qingflow-mcp-setup/references/claude-desktop.md +34 -0
  35. package/skills/qingflow-mcp-setup/references/environments.md +62 -0
  36. package/skills/qingflow-mcp-setup/references/generic-stdio.md +32 -0
  37. package/skills/qingflow-mcp-setup/scripts/check_local_server.sh +38 -0
  38. package/skills/qingflow-record-analysis/SKILL.md +6 -7
  39. package/skills/qingflow-record-analysis/manifest.yaml +10 -0
  40. package/skills/qingflow-record-delete/SKILL.md +5 -3
  41. package/skills/qingflow-record-import/SKILL.md +6 -2
  42. package/skills/qingflow-record-insert/SKILL.md +48 -4
  43. package/skills/qingflow-record-insert/manifest.yaml +6 -0
  44. package/skills/qingflow-record-update/SKILL.md +36 -24
  45. package/skills/qingflow-task-ops/SKILL.md +25 -25
  46. package/skills/qingflow-task-ops/references/environments.md +0 -1
  47. package/skills/qingflow-task-ops/references/workflow-usage.md +4 -6
  48. package/src/qingflow_mcp/__main__.py +6 -2
  49. package/src/qingflow_mcp/builder_facade/service.py +1488 -288
  50. package/src/qingflow_mcp/cli/commands/builder.py +2 -2
  51. package/src/qingflow_mcp/cli/commands/exports.py +2 -2
  52. package/src/qingflow_mcp/cli/commands/imports.py +1 -1
  53. package/src/qingflow_mcp/cli/commands/record.py +39 -11
  54. package/src/qingflow_mcp/cli/context.py +0 -3
  55. package/src/qingflow_mcp/cli/formatters.py +206 -7
  56. package/src/qingflow_mcp/cli/main.py +47 -3
  57. package/src/qingflow_mcp/errors.py +43 -2
  58. package/src/qingflow_mcp/public_surface.py +21 -15
  59. package/src/qingflow_mcp/response_trim.py +68 -13
  60. package/src/qingflow_mcp/server.py +11 -9
  61. package/src/qingflow_mcp/server_app_builder.py +3 -2
  62. package/src/qingflow_mcp/server_app_user.py +15 -13
  63. package/src/qingflow_mcp/solution/executor.py +112 -15
  64. package/src/qingflow_mcp/tools/ai_builder_tools.py +36 -11
  65. package/src/qingflow_mcp/tools/app_tools.py +184 -43
  66. package/src/qingflow_mcp/tools/approval_tools.py +196 -34
  67. package/src/qingflow_mcp/tools/auth_tools.py +92 -16
  68. package/src/qingflow_mcp/tools/code_block_tools.py +296 -39
  69. package/src/qingflow_mcp/tools/custom_button_tools.py +64 -10
  70. package/src/qingflow_mcp/tools/directory_tools.py +236 -72
  71. package/src/qingflow_mcp/tools/export_tools.py +230 -33
  72. package/src/qingflow_mcp/tools/file_tools.py +7 -3
  73. package/src/qingflow_mcp/tools/import_tools.py +293 -40
  74. package/src/qingflow_mcp/tools/navigation_tools.py +91 -12
  75. package/src/qingflow_mcp/tools/package_tools.py +118 -6
  76. package/src/qingflow_mcp/tools/portal_tools.py +39 -3
  77. package/src/qingflow_mcp/tools/qingbi_report_tools.py +116 -7
  78. package/src/qingflow_mcp/tools/record_tools.py +1042 -338
  79. package/src/qingflow_mcp/tools/resource_read_tools.py +188 -39
  80. package/src/qingflow_mcp/tools/role_tools.py +80 -9
  81. package/src/qingflow_mcp/tools/solution_tools.py +57 -15
  82. package/src/qingflow_mcp/tools/task_context_tools.py +569 -119
  83. package/src/qingflow_mcp/tools/task_tools.py +113 -29
  84. package/src/qingflow_mcp/tools/view_tools.py +106 -3
  85. package/src/qingflow_mcp/tools/workflow_tools.py +17 -1
  86. package/src/qingflow_mcp/tools/workspace_tools.py +71 -3
@@ -0,0 +1,107 @@
1
+ # Builder Gotchas
2
+
3
+ ## Auth and workspace
4
+
5
+ - `auth_*` success does not mean a workspace is selected
6
+ - In Wingent Momo runtime, do not run `workspace_select` before builder work. Re-run it only after an explicit auth/route recovery or when a business tool reports the workspace is missing.
7
+
8
+ ## Package ownership
9
+
10
+ - Public package work should stay on `package_get / package_apply`
11
+ - Do not treat `package_attach_app` as the public default story anymore; if it still exists in low-level code, treat it as internal/legacy
12
+ - Check package-related readback after schema writes instead of assuming package ownership from the write alone
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
+
21
+ ## Auto publish
22
+
23
+ - `app_schema_apply`, `app_layout_apply`, `app_flow_apply`, and `app_views_apply` publish by default
24
+ - For those four tools, pass `publish=false` only when the user explicitly wants to leave changes in draft
25
+ - `app_custom_buttons_apply` and `app_associated_resources_apply` publish after at least one write succeeds and do not accept `publish=false`
26
+ - `app_publish_verify` is for explicit final verification, not the default next step after every write
27
+
28
+ ## BI Reports
29
+
30
+ - Use `app_charts_apply` for QingBI report body/config creation or updates.
31
+ - Use `app_associated_resources_apply` only when an existing BI report or view needs to appear in the Qingflow app associated-resource area or a specific view.
32
+ - `app_charts_apply` currently creates/updates app-source BI reports only (`dataSourceType=qingflow`); dataset BI reports can only be attached when they already exist.
33
+ - Creating a chart with `app_charts_apply` does not automatically show it in the Qingflow app UI; attach it separately if display is required.
34
+ - `target` and `table` remain compatibility aliases for QingBI `indicator` and `detail`; use the real QingBI chart type when you need a specific type such as `summary`, `columnar`, `stacked_bar`, `scatter`, or `dualaxes`.
35
+
36
+ ## Custom buttons
37
+
38
+ - Use `app_custom_buttons_apply` for button creation/update/removal and view placement; do not split placement into `app_views_apply.buttons` unless you are maintaining a legacy patch.
39
+ - When changing one existing button parameter, use `patch_buttons` with `set/unset`. Do not send a partial `upsert_buttons` object and expect the backend to preserve hidden required fields.
40
+ - For add-data buttons, prefer semantic `trigger_add_data_config.target_app_key`, `field_mappings`, and `default_values`.
41
+ - Do not handwrite raw `que_relation` unless you are preserving an existing backend config. If `field_mappings` and `que_relation` are mixed, the tool blocks the write.
42
+ - `field_mappings.source_field` can use source app fields and supported system fields such as `数据ID` (`field_id=-17`) and `编号` (`field_id=0`).
43
+ - To fill a target relation field with the current source record, map `{"source_field": "数据ID", "target_field": "目标引用字段"}`. Use `default_values` only for static constants.
44
+ - For field type compatibility, read `references/match-rules.md`.
45
+ - Default button placements are `header` and `detail`; these map to the frontend's header and detail button areas.
46
+ - `view_configs[].buttons` is required in merge mode. Do not send a view config with only `view_key`; it is blocked to avoid no-op writes and accidental publish.
47
+ - Builder view configs use raw `view_key` from `app_get.views[].view_key`; do not prefix it with `custom:`. The `custom:<viewKey>` form is for record-data `view_id`.
48
+ - View button bindings merge by default. Use `view_configs[].mode="replace"` to replace the full set, or pass an explicit empty `buttons: []` when you intend to clear all custom button bindings for that view.
49
+ - Advanced view button bindings can include `button_limit`, `button_formula`, `button_formula_type`, and `print_tpls`, but keep ordinary buttons simple unless the user asks for conditional visibility or print templates.
50
+ - `placement=list` configures row/list buttons. The tool maps it to the backend `INSIDE` button position, not a raw `LIST` config type.
51
+
52
+ ## Associated resources
53
+
54
+ - Before creating an associated view/report, check `app_get.associated_resources` for the same `target_app_key + view_key/chart_key`.
55
+ - If the resource already exists, use `patch_resources` with its `associated_item_id`; do not call `upsert_resources` again.
56
+ - For per-view display, remove, and reorder, existing associated reports/views may be referenced by `associated_item_id`, `chart_id`/`chart_key`, or `view_key`; the tool resolves these to the internal id before writing.
57
+ - `client_key` is only a same-call alias for `view_configs[].associated_item_refs`. It is not stored by Qingflow and cannot prevent duplicates in later calls.
58
+ - Repeated `upsert_resources` without `associated_item_id` can create multiple app-level associated items pointing to the same view/report.
59
+
60
+ ## Readback scope
61
+
62
+ - Prefer summary reads over large raw payloads
63
+ - Use `app_get_fields` before schema or view work
64
+ - Use `app_get_layout` before layout work
65
+ - Use `app_get_flow` before workflow work
66
+ - Use `app_get_views` before view work
67
+
68
+ ## Partial update discipline
69
+
70
+ - Existing views, custom buttons, associated resources, and charts support the same public partial pattern: `patch_*[].set` plus optional `patch_*[].unset`.
71
+ - The backend may still save a full payload. The MCP/CLI patch path is responsible for reading current config and preserving fields the user did not mention.
72
+ - Do not use `upsert_views`, `upsert_buttons`, `upsert_resources`, or `upsert_charts` for a tiny parameter replacement unless you are deliberately providing the full desired target config.
73
+ - `app_layout_apply(mode=merge)` is already a safe layout merge path; `mode=replace` is full layout replacement.
74
+ - `portal_apply` without `sections` is base-info-only. Supplying `sections` replaces the portal sections list.
75
+ - `app_flow_apply` is intentionally replace-only for the public linear workflow graph.
76
+
77
+ ## Workflow dependencies
78
+
79
+ - Approval-style flows usually require an explicit status field
80
+ - Approval, fill, and copy nodes also require at least one assignee
81
+ - Prefer roles over explicit members unless the user explicitly names people
82
+ - Resolve assignees with `role_search` / `member_search` before flow apply
83
+ - Use `permissions.editable_fields` for node-level editable field permissions; do not guess field ids
84
+ - 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.
85
+ - If `app_flow_apply` reports `FLOW_DEPENDENCY_MISSING`, fix schema first
86
+ - Do not switch to hidden `solution_*` tools from public builder flows
87
+
88
+ ## Retry discipline
89
+
90
+ - If a write returns `partial_success`, read back before retrying
91
+ - Do not repeat create steps after `app_key` already exists
92
+ - For backend rejects, keep the retry narrow: retry only the failed tool, not the whole chain
93
+ - For `VALIDATION_ERROR`, do not keep guessing. Reuse `suggested_next_call`, `canonical_arguments`, `allowed_keys`, and `allowed_values` first.
94
+ - 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)`.
95
+ - For flow work, do not replay internal keys from old logs or plan outputs. Public builder calls should stay on:
96
+ - `assignees.role_ids` / `assignees.member_uids` / `assignees.member_emails`
97
+ - `permissions.editable_fields`
98
+ - For view work, treat `columns` as the only canonical public key. `app_get_views` and `app_views_apply` should all be read and written in that shape.
99
+ - For existing view parameter changes, prefer `patch_views`. Example: to change only query-panel fields, set only `query_conditions`; the tool will preserve columns, filters, date config, card fields, buttons, and other backend-required fields.
100
+ - 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.
101
+ - 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.
102
+ - If duplicate view names exist, do not retry by name. Read the exact `view_key` and target that one.
103
+ - If a view or flow write fails, report the smallest next action:
104
+ - wrong key -> switch to canonical key
105
+ - unsupported preset -> switch to allowed canonical preset
106
+ - backend reject -> re-read summary and retry only the failed patch
107
+ - Do not translate abstract user phrases like “灵活流程” or “默认视图” directly into MCP arguments. First convert them to a preset or explicit patch plan.
@@ -0,0 +1,114 @@
1
+ # Builder Match Rules
2
+
3
+ Use this reference for builder-side field matching rules in custom buttons and associated view/report filters.
4
+
5
+ This is not the same thing as `record_access` analysis filters or normal view `filters`.
6
+
7
+ ## Where These Rules Apply
8
+
9
+ - `app_custom_buttons_apply.upsert_buttons[].trigger_add_data_config.field_mappings`
10
+ - `app_custom_buttons_apply.patch_buttons[].set.trigger_add_data_config.field_mappings`
11
+ - `app_associated_resources_apply.upsert_resources[].match_mappings`
12
+ - `app_associated_resources_apply.patch_resources[].set.match_mappings`
13
+
14
+ Prefer semantic mappings. Do not handwrite raw `que_relation` or `match_rules` unless you are preserving an existing backend config.
15
+
16
+ ## System Fields
17
+
18
+ System fields can participate in mappings:
19
+
20
+ - `数据ID`, `row_record_id`, `apply_id`, `_id` -> `field_id=-17`
21
+ This is the current record's real apply/record ID.
22
+ - `编号`, `数据编号`, `record_number` -> `field_id=0`
23
+ This is the frontend-visible record number. It may be custom formatted and is not the same as `数据ID`.
24
+
25
+ Explicit selectors such as `{"field_id": -17}` and `{"field_id": 0}` are allowed and remove ambiguity.
26
+
27
+ ## Custom Buttons
28
+
29
+ Use `field_mappings` for dynamic values copied from the current source record:
30
+
31
+ ```json
32
+ {
33
+ "target_app_key": "WORKLOG_APP",
34
+ "field_mappings": [
35
+ {"source_field": "数据ID", "target_field": "关联员工"},
36
+ {"source_field": "员工名称", "target_field": "员工姓名"}
37
+ ],
38
+ "default_values": {
39
+ "状态": "待提交"
40
+ }
41
+ }
42
+ ```
43
+
44
+ Use `default_values` only for static constants. Do not use `default_values` as the preferred way to pass the current record.
45
+
46
+ For an existing button, put the same semantic config under `patch_buttons[].set`:
47
+
48
+ ```json
49
+ {
50
+ "button_id": 3858041,
51
+ "set": {
52
+ "trigger_add_data_config": {
53
+ "target_app_key": "WORKLOG_APP",
54
+ "field_mappings": [
55
+ {"source_field": "数据ID", "target_field": "关联员工"}
56
+ ],
57
+ "default_values": {
58
+ "状态": "待提交"
59
+ }
60
+ }
61
+ }
62
+ }
63
+ ```
64
+
65
+ ## Associated Resources
66
+
67
+ Use `match_mappings` for associated view/report filters:
68
+
69
+ ```json
70
+ {
71
+ "graph_type": "view",
72
+ "target_app_key": "WORKLOG_APP",
73
+ "view_key": "WORKLOG_VIEW",
74
+ "match_mappings": [
75
+ {"target_field": "关联员工", "source_field": "数据ID"},
76
+ {"target_field": "状态", "value": "待提交"}
77
+ ]
78
+ }
79
+ ```
80
+
81
+ Dynamic conditions use `source_field`; static conditions use `value`.
82
+
83
+ For an existing associated resource, put the same filter mapping under `patch_resources[].set`:
84
+
85
+ ```json
86
+ {
87
+ "associated_item_id": 3497587,
88
+ "set": {
89
+ "match_mappings": [
90
+ {"target_field": "关联员工", "source_field": "数据ID"}
91
+ ]
92
+ }
93
+ }
94
+ ```
95
+
96
+ ## Type Compatibility
97
+
98
+ - Relation fields: match another relation field with the same target app, or match `数据ID(-17)` when the target relation points to the current source app.
99
+ - Record ID `数据ID(-17)`: can match relation fields that point to the current source app, or ID-compatible text/number fields.
100
+ - Record number `编号(0)`: can match text, long text, number, amount, or another record-number field.
101
+ - Member fields: only match member fields.
102
+ - Department fields: only match department fields.
103
+ - Option fields: single select, multi select, and boolean can match option-family fields or static option values.
104
+ - Date fields: date and datetime can match each other.
105
+ - Text fields: text, long text, phone, and email can match each other.
106
+ - Number fields: number and amount can match each other.
107
+ - Attachment, subtable, code block, Q-Linker, and address fields are not default match fields.
108
+
109
+ ## Error Interpretation
110
+
111
+ - Field not found: re-read `app_get` or `app_get_fields` and retry with an exact title or `field_id`.
112
+ - Type mismatch: choose a compatible source/target pair from the matrix above.
113
+ - Reference source mismatch: the target relation field points to a different app; choose a relation field that points back to the current source app, or match a non-relation field.
114
+ - Mixed raw and semantic modes: use either semantic `field_mappings/match_mappings` or raw `que_relation/match_rules`, never both in the same item.
@@ -0,0 +1,75 @@
1
+ # Qingflow Core Public Surface Sync
2
+
3
+ Use this file as the maintenance baseline for the core Qingflow skills.
4
+ It is not a user-facing product spec. It exists to prevent skill drift.
5
+
6
+ ## Current Public Defaults
7
+
8
+ ### User data
9
+
10
+ - Read range first with `app_get`, then `record_browse_schema_get(view_id=...)`
11
+ - Treat `record_browse_schema_get.fields` as the selected Qingflow table view header schema; `record_access.fields` and `record_list` field selectors must stay aligned with it.
12
+ - Standard flows:
13
+ - analyze: `app_get -> record_browse_schema_get -> record_access -> Python`
14
+ - browse detail: `app_get -> record_browse_schema_get -> record_list / record_get`
15
+ - explicit export/download/Excel: `app_get -> choose view_id -> view_get -> record_export_*` or `record_export_direct`; export tools require explicit `view_id`
16
+ - insert: `record_insert_schema_get -> record_insert(items)`
17
+ - update: `record_get -> record_update`; use `record_update_schema_get` only for failure diagnosis or ambiguous writable-field routing
18
+
19
+ ### Tasks
20
+
21
+ - Discovery stays on `task_list`
22
+ - `task_list --query` uses backend search first and only applies local fallback when backend returns zero rows
23
+ - Public actions are:
24
+ - `approve`
25
+ - `reject`
26
+ - `rollback`
27
+ - `transfer`
28
+ - `urge`
29
+ - `save_only`
30
+ - `reject` requires `payload.audit_feedback`
31
+ - `save_only` requires non-empty `fields`
32
+ - `TASK_RUNTIME_CONSUMED_AFTER_ACTION` is a normal post-success warning when the current node runtime is consumed and `46001` appears on re-read
33
+
34
+ ### Builder
35
+
36
+ - Official package entry: `package_get`, `package_apply`
37
+ - Official builder writes:
38
+ - `app_schema_apply`
39
+ - `app_layout_apply`
40
+ - `app_flow_apply`
41
+ - `app_views_apply`
42
+ - `app_custom_buttons_apply`
43
+ - `app_associated_resources_apply`
44
+ - `app_charts_apply`
45
+ - `portal_apply`
46
+ - `app_publish_verify`
47
+ - `portal_apply` edit mode may omit `sections` for base-info-only updates
48
+ - `app_charts_apply.visibility` is a public capability and should be treated as a base-only visibility update
49
+ - Existing object parameter replacement should use `patch_views`, `patch_buttons`, `patch_resources`, and `patch_charts`; `upsert_*` is for creation or full target config
50
+ - `app_get.editability` uses:
51
+ - `can_edit_app_base`
52
+ - `can_edit_form`
53
+ - `can_edit_flow`
54
+ - `can_edit_views`
55
+ - `can_edit_charts`
56
+
57
+ ## Known High-Drift Areas
58
+
59
+ - Task actions, especially `save_only`, reject payload requirements, and `46001` post-action interpretation
60
+ - Package public tools: do not regress to `package_create` / `package_attach_app` as the public default story
61
+ - App editability: do not let `can_edit_form` imply app base-info writes
62
+ - Portal and chart visibility: keep the public story on `portal_apply` / `app_charts_apply`, not low-level internal writes
63
+ - Analysis path: standard path stays `record_access -> Python`
64
+
65
+ ## Release Checklist For Skill Maintenance
66
+
67
+ After each beta that changes public behavior, re-check:
68
+
69
+ 1. `public_surface.py`
70
+ 2. `README.md`
71
+ 3. `server_app_builder.py` and `server.py` top-level guidance
72
+ 4. CLI help for `task`, `builder package`, `builder portal`, `builder charts`
73
+ 5. Whether new warnings or verification fields need to be explained in skills
74
+
75
+ If a tool behavior changed but the public surface did not, prefer updating the relevant skill section instead of expanding this file.
@@ -0,0 +1,52 @@
1
+ # Builder Playbooks
2
+
3
+ Use these when you need a quick reminder of the standard v2 builder sequences.
4
+
5
+ ## Create a new app in an existing package
6
+
7
+ 1. `package_get`
8
+ 2. `app_resolve`
9
+ 3. `app_schema_apply`
10
+ 5. `app_publish_verify` only if the user asks for explicit live verification
11
+
12
+ ## Update fields on an existing app
13
+
14
+ 1. `app_resolve`
15
+ 2. `app_get_fields`
16
+ 3. `app_schema_apply`
17
+
18
+ ## Rework layout
19
+
20
+ 1. `app_get_layout`
21
+ 2. `app_layout_apply`
22
+
23
+ Prefer `mode=merge`. Use `mode=replace` only when every field placement is intentional.
24
+
25
+ ## Add or update workflow
26
+
27
+ 1. `app_get_fields`
28
+ 2. `app_get_flow`
29
+ 3. `role_search` or `member_search`
30
+ 4. `role_create` if the business wants a reusable role and no good exact role exists
31
+ 5. `app_flow_apply`
32
+
33
+ If `app_flow_apply` reports `FLOW_DEPENDENCY_MISSING`, fix schema first.
34
+ If it reports `FLOW_ASSIGNEE_REQUIRED`, resolve roles or members first and retry with canonical `assignees.*`.
35
+
36
+ ## Add or update views
37
+
38
+ 1. `app_get_fields`
39
+ 2. `app_get_views`
40
+ 3. `app_views_apply`
41
+
42
+ For both workflow and view work, prefer `suggested_next_call` over re-guessing arguments after a validation failure.
43
+
44
+ ## Final readback
45
+
46
+ Prefer these fields after writes:
47
+
48
+ - `app_get.tag_ids`
49
+ - `app_get.publish_status`
50
+ - `app_get_layout.unplaced_fields`
51
+ - `app_get_views.views`
52
+ - `app_get_flow.nodes`
@@ -0,0 +1,99 @@
1
+ # Tool Selection
2
+
3
+ Use the smallest v2 builder tool chain that can finish the task.
4
+
5
+ ## Default path
6
+
7
+ `summary read -> apply -> publish_verify`
8
+
9
+ Public builder `apply` tools already perform server-side planning, normalization, and dependency checks internally. Do not route normal public builder work through explicit `*_plan` tools.
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
+
22
+ ## Resolve
23
+
24
+ - `package_get`: read one known package by `package_id`; it reads package `baseInfo` first and may warn `PACKAGE_DETAIL_READ_DEGRADED` when the richer detail endpoint needs package edit/add-app permission. Treat that warning as degraded detail, not as package-read failure.
25
+ - `package_apply`: create or update one package; use `create_if_missing=true` only after explicit user intent; layout/group/order changes require package edit permission because they call the backend package ordering route
26
+ - `member_search`: resolve named people from the directory
27
+ - `role_search`: resolve reusable roles from the directory
28
+ - `role_create`: create a reusable role when the business owner wants role-based routing
29
+ - `app_resolve`: locate an existing app by exactly one selector mode: `app_key`, or `app_name + package_id`; by-name resolution checks package detail/current visible apps before using broader admin-style app search, so a `/app/item` permission miss is not a frontend-visible-app failure
30
+
31
+ ## Summary reads
32
+
33
+ - `app_get`: overall app config health, publish state, counts, and builder editability
34
+ - `app_get_fields`: field names, types, required flags, section ids
35
+ - `app_get_layout`: sections, rows, unplaced fields
36
+ - `app_get_views`: current view names, types, columns, group-by
37
+ - `app_get_flow`: workflow enabled state, nodes, transitions
38
+ - `app_get_charts`: current chart ids, names, types, order
39
+ - `chart_get`: one chart's base/config detail; base info is read through the Qingflow/qflow visible route first, and config may degrade from chart data when the CHART_SEE config endpoint is unavailable. Treat degraded config as a read-mode warning, not as proof the user cannot see the chart.
40
+ - `portal_get`: current portal config detail and component inventory
41
+
42
+ ## Apply tools
43
+
44
+ These execute normalized patches. Some app apply tools publish by default and still accept `publish=false`; custom button and associated-resource apply publish after at least one write succeeds and do not expose that switch.
45
+
46
+ - `app_schema_apply`: create app shell or change fields
47
+ - `app_layout_apply`: merge or replace layout
48
+ - `app_flow_apply`: replace workflow
49
+ - `app_views_apply`: use `patch_views` for existing-view parameter replacement; use `upsert_views` for creation or full target config; remove views by key; new views default associated report/view display to visible with `limit_type="all"`
50
+ - `app_custom_buttons_apply`: use `patch_buttons` for existing-button parameter replacement; use `upsert_buttons` for creation or full target config; configure add-data field mappings/default values; bind buttons to header/detail/list view positions; `placement=list` maps to the backend `INSIDE` row/list button position; merge-mode view configs require `buttons`; use `view_configs[].mode="replace"` or `buttons=[]` to clear a view's custom button bindings. For child-record creation linked to the current source record, map `source_field: "数据ID"` to the target relation field.
51
+ - `app_associated_resources_apply`: attach existing BI reports/views to the Qingflow app associated-resource pool and per-view display area; it does not create or edit QingBI report bodies/configs. Permission is split like the backend: resource pool writes use EditAppAuth, while `view_configs` uses the view config/DataManageAuth path. Use `patch_resources` for existing associated-resource parameter replacement; use `upsert_resources` for creation or full target config; `view_configs`, remove, and reorder may reference existing resources by internal `associated_item_id` or by `chart_id`/`chart_key`/`view_key`; use `match_mappings` for associated view/report filters; publishes after successful writes; omit raw `sourceType`, and use `report_source="dataset"` only to attach an existing BI dataset report. Before `upsert_resources`, read `app_get.associated_resources` and reuse an existing matching `target_app_key + view_key/chart_key`; repeated upsert can create duplicates because `client_key` is only valid inside one apply call.
52
+ - `app_charts_apply`: create/edit/remove/reorder app-source QingBI report bodies/configs with `dataSourceType=qingflow`; it does not create/edit dataset BI reports and does not attach reports to Qingflow app associated-resource display. Use `patch_charts` for existing-chart parameter replacement; use `upsert_charts` for creation or full target config; supports `target/table` aliases plus QingBI chart types such as `summary`, `columnar`, `area`, `funnel`, `radar`, `scatter`, `dualaxes`, and `map`; charts are immediate-live and do not publish; use `chart_id` when names are not unique
53
+ - `portal_apply`: create or replace-update portal pages; use `dash_key` for update mode or `package_id + dash_name` for create mode; create mode only prechecks package add_app, matching backend portal creation; edit mode may omit `sections` for base-info-only updates; when sections are supplied they still use replace semantics
54
+
55
+ For object-level updates, the safe partial syntax is `patch_*` with the object's real selector field plus `set` and optional `unset`. `selector` is only a concept, not a literal key. Examples: `patch_views: [{"view_key": "VIEW_KEY", "set": {...}}]`, `patch_buttons: [{"button_id": 1001, "set": {...}}]`, `patch_resources: [{"associated_item_id": 123, "set": {...}}]`, `patch_charts: [{"chart_id": 456, "set": {...}}]`. The tool reads the current backend config, merges the patch, then submits the full backend payload internally. Do not send a partial `upsert_*` and expect missing required fields to be preserved.
56
+
57
+ ## Explicit post-apply tools
58
+
59
+ - `app_publish_verify`: explicit final publish verification when the user asks for live confirmation
60
+
61
+ ## Decision shortcuts
62
+
63
+ - Create one app inside an existing package:
64
+ `package_get -> app_resolve -> app_schema_apply`
65
+ - Create a brand new package, then create one app in it:
66
+ `package_apply(create_if_missing=true) -> app_schema_apply`
67
+ - Create a brand new multi-app system/package:
68
+ `package_apply(create_if_missing=true) -> app_schema_apply(apps[])`
69
+ - Update fields on an existing app:
70
+ `app_resolve -> app_get_fields -> app_schema_apply`
71
+ - Tidy layout:
72
+ `app_get_fields -> app_get_layout -> builder_tool_contract (if shape is unclear) -> app_layout_apply`
73
+ - Add workflow:
74
+ `builder_tool_contract -> app_get_fields -> app_get_flow -> role_search/member_search -> app_flow_apply -> app_get_flow`
75
+ - Add views:
76
+ `builder_tool_contract -> app_get_fields -> app_get_views -> app_views_apply.patch_views/upsert_views -> app_get_views`
77
+ - Add QingBI charts:
78
+ `builder_tool_contract -> app_get_fields -> app_get_charts -> app_charts_apply.patch_charts/upsert_charts -> app_get_charts`
79
+ - Show an existing QingBI chart inside a Qingflow app/view:
80
+ `app_get -> app_associated_resources_apply.upsert_resources/patch_resources + view_configs -> app_get`
81
+ - Create or update a portal:
82
+ `builder_tool_contract -> portal_get -> portal_apply -> portal_get`
83
+
84
+ ## Avoid
85
+
86
+ - Do not handcraft raw Qingflow schema payloads
87
+ - Do not rely on internal `solution_*` tools in public builder flows
88
+ - Do not create a new package without first asking the user to confirm package creation
89
+ - Do not regress to `package_create` or `package_attach_app` as the public default story
90
+ - Do not treat a package/system name as `app_name` when the user clearly wants multiple apps inside it
91
+ - Do not compress multiple business objects into one app with several text fields
92
+ - Do not skip summary reads before flow or view work
93
+ - Do not emit `column_names`; always use `columns`
94
+ - Do not model layout shape with `fields`, `field_ids`, or top-level `columns`; custom layout sections should be `title + rows`
95
+ - Do not reuse internal flow keys such as `role_entries` or `editable_que_ids` in public builder calls
96
+ - Do not pass natural-language preset guesses such as `default_approval`; map them to canonical preset values first
97
+ - Do not omit assignees on approval/fill/copy nodes
98
+ - 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`
99
+ - Do not guess role ids, member ids, or editable field ids; resolve names first
@@ -0,0 +1,158 @@
1
+ # Update Flow
2
+
3
+ Use this when the app already exists and the task is only about workflow.
4
+
5
+ ## Minimal sequence
6
+
7
+ 1. `builder_tool_contract(tool_name="app_flow_apply")`
8
+ 2. `app_get_fields`
9
+ 3. `app_get_flow`
10
+ 4. `role_search` or `member_search`
11
+ 5. `role_create` if the user wants a reusable directory role and no good role exists
12
+ 6. start from a canonical preset when possible
13
+ 7. patch the skeleton instead of freehanding a full graph
14
+ 8. reuse preset node ids when patching:
15
+ - `basic_approval` -> patch `approve_1`
16
+ - `basic_fill_then_approve` -> patch `fill_1` and `approve_1`
17
+ Do not add a second approval/fill node with a new id unless you are intentionally replacing the skeleton.
18
+ The MCP now auto-aligns the simplest single-node preset overrides, but still prefer explicit preset ids so the merged graph stays predictable.
19
+ 9. `app_flow_apply`
20
+ 10. `app_get_flow` when apply returns `partial_success` or the user asked for verification
21
+
22
+ If you are unsure about presets or node shapes, call `builder_tool_contract(tool_name="app_flow_apply")` before guessing.
23
+
24
+ ## Example
25
+
26
+ Canonical preset mapping:
27
+
28
+ - “默认审批/基础审批/普通审批” -> `basic_approval`
29
+ - “先填报再审批/提交后审批” -> `basic_fill_then_approve`
30
+
31
+ Apply a simple approval flow with a role assignee and node-level editable fields:
32
+
33
+ ```json
34
+ {
35
+ "tool_name": "app_flow_apply",
36
+ "arguments": {
37
+ "profile": "default",
38
+ "app_key": "APP_123",
39
+ "preset": "basic_approval",
40
+ "publish": true,
41
+ "nodes": [
42
+ {
43
+ "id": "approve_1",
44
+ "type": "approve",
45
+ "name": "部门审批",
46
+ "assignees": {
47
+ "role_names": ["项目经理"]
48
+ },
49
+ "permissions": {
50
+ "editable_fields": ["状态", "审批意见"]
51
+ }
52
+ }
53
+ ]
54
+ }
55
+ }
56
+ ```
57
+
58
+ For flexible business requirements, do not jump straight to a full custom graph. Use this safer pattern:
59
+
60
+ 1. build a base skeleton from a preset
61
+ 2. identify the business-specific changes
62
+ 3. patch nodes/transitions explicitly
63
+
64
+ Public flow building is intentionally limited to linear workflows. Use only:
65
+
66
+ - `start`
67
+ - `approve`
68
+ - `fill`
69
+ - `copy`
70
+ - `webhook`
71
+ - `end`
72
+
73
+ Do not generate `branch` or `condition` nodes through `app_flow_apply`. The backend workflow route is not front-end stable for those node types, and MCP now returns `FLOW_NODE_TYPE_UNSUPPORTED` instead of writing a visually broken flow.
74
+ After `app_flow_apply` returns blocking issues or canonical arguments, prefer reusing its `suggested_next_call.arguments` directly. Do not rewrite the result into internal fields such as `role_entries` or `editable_que_ids`.
75
+ When you patch a preset, patch the preset node itself. Do not leave the preset approval node unassigned while adding a second custom approval node.
76
+
77
+ ## Common failures
78
+
79
+ ### `FLOW_ASSIGNEE_REQUIRED`
80
+
81
+ Approval, fill, and copy nodes must declare at least one assignee.
82
+
83
+ If this happens after using a preset, check for this specific mistake first:
84
+
85
+ - the preset created `approve_1` or `fill_1`
86
+ - your patch created a different node id instead of patching that preset node
87
+ - the original preset node remained in the graph without assignees
88
+
89
+ Preferred fix order:
90
+
91
+ 1. `role_search`
92
+ 2. `member_search` only if the user explicitly named members
93
+ 3. `role_create` if the business needs a reusable role
94
+ 4. patch the preset node id itself with canonical `assignees.*`
95
+ 5. retry `app_flow_apply`
96
+
97
+ ### `FLOW_DEPENDENCY_MISSING`
98
+
99
+ The workflow depends on fields that do not exist yet, usually `status`. Fix schema first.
100
+
101
+ Preferred recovery:
102
+
103
+ 1. use the returned `suggested_next_call`
104
+ 2. apply the minimal schema patch
105
+ 3. rerun `app_get_fields`
106
+ 4. rerun `app_flow_apply`
107
+
108
+ ### `INVALID_FLOW_EDGE`
109
+
110
+ One or more transitions reference unknown nodes or create an invalid graph.
111
+
112
+ ### `UNKNOWN_FLOW_FIELD`
113
+
114
+ The workflow referenced a field name that does not exist, often in:
115
+
116
+ - `permissions.editable_fields`
117
+
118
+ Call `app_get_fields` and retry with the exact field names returned by the app.
119
+
120
+ ### `FLOW_NODE_TYPE_UNSUPPORTED`
121
+
122
+ The public workflow builder only supports linear flows. Remove `branch` and `condition` nodes and redesign the flow with stable sequential nodes instead of retrying the same graph.
123
+
124
+ ### `STATUS_FIELD_REQUIRED`
125
+
126
+ The app has no explicit status field recognized by the internal workflow compiler. Add one with `app_schema_apply`, then retry.
127
+
128
+ ### `FLOW_STAGE_CONTEXT_MISSING`
129
+
130
+ Internal flow stage context was missing or invalid. Re-run `app_flow_apply` with the normalized arguments, and do not switch to hidden `solution_*` tools.
131
+
132
+ ### `VALIDATION_ERROR`
133
+
134
+ Do not keep guessing preset names or node shapes. First:
135
+
136
+ 1. inspect `suggested_next_call`
137
+ 2. reuse `canonical_arguments` if present
138
+ 3. check `allowed_values`
139
+ 4. retry with canonical preset or canonical node types
140
+ 5. for workflow actors and permissions, always convert to:
141
+ - `assignees.role_names`
142
+ - `assignees.member_names`
143
+ - `permissions.editable_fields`
144
+
145
+ Do not copy internal keys from old plan outputs or logs, including:
146
+
147
+ - `role_entries`
148
+ - `editable_que_ids`
149
+
150
+ ## Notes
151
+
152
+ - `mode=replace` is the only supported flow apply mode
153
+ - `app_flow_apply` publishes by default
154
+ - Prefer roles over explicit members unless the user explicitly asks for named members
155
+ - `basic_approval` and `basic_fill_then_approve` are skeletons, not complete business workflows
156
+ - Report results precisely:
157
+ - “基础流程骨架已创建” when only the preset landed
158
+ - “业务定制规则已补齐” only after the patch phase is complete