@josephyan/qingflow-cli 1.1.4 → 1.1.6

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 (154) hide show
  1. package/README.md +7 -3
  2. package/docs/local-agent-install.md +57 -6
  3. package/entry_point.py +1 -1
  4. package/npm/bin/qingflow-skills.mjs +5 -0
  5. package/npm/bin/qingflow.mjs +1 -34
  6. package/npm/lib/runtime.mjs +21 -101
  7. package/npm/scripts/postinstall.mjs +1 -10
  8. package/package.json +3 -2
  9. package/pyproject.toml +1 -1
  10. package/skills/qingflow-cli/SKILL.md +58 -44
  11. package/skills/qingflow-cli/manifest.yaml +1 -1
  12. package/skills/qingflow-cli/reference/00-INDEX.md +35 -0
  13. package/skills/qingflow-cli/reference/builder/10-build-single-app.md +38 -0
  14. package/skills/qingflow-cli/reference/builder/20-build-complete-system.md +39 -0
  15. package/skills/qingflow-cli/reference/{QINGFLOW_CLI_SCHEMA_APPLY_FIELD_TYPES_AND_SCENARIOS.md → builder/30-schema-fields.md} +52 -10
  16. package/skills/qingflow-cli/reference/builder/40-layout.md +52 -0
  17. package/skills/qingflow-cli/reference/{QINGFLOW_CLI_BUILDER_VIEWS_WORKFLOW.md → builder/50-views.md} +39 -15
  18. package/skills/qingflow-cli/reference/{QINGFLOW_CLI_BUILDER_CHARTS_WORKFLOW.md → builder/60-charts.md} +36 -13
  19. package/skills/qingflow-cli/reference/{QINGFLOW_CLI_BUILDER_PORTAL_WORKFLOW.md → builder/70-portal.md} +36 -13
  20. package/skills/qingflow-cli/reference/builder/80-buttons-associated-resources.md +41 -0
  21. package/skills/qingflow-cli/reference/builder/90-workflow.md +34 -0
  22. package/skills/qingflow-cli/reference/builder/99-publish-verify.md +46 -0
  23. package/skills/qingflow-cli/reference/builder/README.md +41 -0
  24. package/skills/qingflow-cli/reference/builder/code-integrations/README.md +130 -0
  25. package/skills/qingflow-cli/reference/builder/code-integrations/code-block.md +66 -0
  26. package/skills/qingflow-cli/reference/builder/code-integrations/q-linker.md +77 -0
  27. package/skills/qingflow-cli/reference/{QINGFLOW_CLI_BUILDER_APP_DELIVERY_WORKFLOW.md → builder/reference/app-delivery-sop.md} +26 -16
  28. package/skills/qingflow-cli/reference/builder/reference/legacy-playbooks/README.md +293 -0
  29. package/skills/qingflow-cli/reference/builder/reference/legacy-playbooks/build-complete-system.md +809 -0
  30. package/skills/qingflow-cli/reference/builder/reference/legacy-playbooks/build-single-app.md +830 -0
  31. package/skills/qingflow-cli/reference/builder/reference/legacy-playbooks/complete-system-development-guide.md +123 -0
  32. package/skills/qingflow-cli/reference/builder/reference/legacy-playbooks/create-app.md +182 -0
  33. package/skills/qingflow-cli/reference/builder/reference/legacy-playbooks/environments.md +63 -0
  34. package/skills/qingflow-cli/reference/builder/reference/legacy-playbooks/flow-actors-and-permissions.md +142 -0
  35. package/skills/qingflow-cli/reference/builder/reference/legacy-playbooks/gotchas.md +108 -0
  36. package/skills/qingflow-cli/reference/builder/reference/legacy-playbooks/match-rules.md +114 -0
  37. package/skills/qingflow-cli/reference/builder/reference/legacy-playbooks/public-surface-sync.md +75 -0
  38. package/skills/qingflow-cli/reference/builder/reference/legacy-playbooks/single-app-development-guide.md +58 -0
  39. package/skills/qingflow-cli/reference/builder/reference/legacy-playbooks/solution-playbooks.md +52 -0
  40. package/skills/qingflow-cli/reference/builder/reference/legacy-playbooks/tool-selection.md +107 -0
  41. package/skills/qingflow-cli/reference/builder/reference/legacy-playbooks/update-flow.md +7 -0
  42. package/skills/qingflow-cli/reference/builder/reference/legacy-playbooks/update-layout.md +7 -0
  43. package/skills/qingflow-cli/reference/builder/reference/legacy-playbooks/update-schema.md +7 -0
  44. package/skills/qingflow-cli/reference/builder/reference/legacy-playbooks/update-views.md +7 -0
  45. package/skills/qingflow-cli/reference/builder/workflow/01-overview.md +45 -0
  46. package/skills/qingflow-cli/reference/builder/workflow/02-update-mode.md +53 -0
  47. package/skills/qingflow-cli/reference/builder/workflow/03-flow-patterns.md +57 -0
  48. package/skills/qingflow-cli/reference/builder/workflow/04-stage1-business-modeling.md +131 -0
  49. package/skills/qingflow-cli/reference/builder/workflow/05-stage2-members-roles.md +29 -0
  50. package/skills/qingflow-cli/reference/builder/workflow/06-stage3-build-spec.md +165 -0
  51. package/skills/qingflow-cli/reference/builder/workflow/07-stage4-validate-spec.md +33 -0
  52. package/skills/qingflow-cli/reference/builder/workflow/08-stage5-apply-verify.md +51 -0
  53. package/skills/qingflow-cli/reference/builder/workflow/09-stage6-summary.md +88 -0
  54. package/skills/qingflow-cli/reference/builder/workflow/10-node-config-reference.md +93 -0
  55. package/skills/qingflow-cli/reference/builder/workflow/11-troubleshooting.md +15 -0
  56. package/skills/qingflow-cli/reference/builder/workflow/README.md +88 -0
  57. package/skills/qingflow-cli/reference/builder/workflow/workflow-schema.json +1754 -0
  58. package/skills/qingflow-cli/reference/{QINGFLOW_CLI_ADMIN_CHEATSHEET.md → core/QINGFLOW_CLI_ADMIN_CHEATSHEET.md} +3 -3
  59. package/skills/qingflow-cli/reference/{QINGFLOW_CLI_DATA_RETRIEVAL_WORKFLOW.md → core/QINGFLOW_CLI_DATA_RETRIEVAL_WORKFLOW.md} +6 -6
  60. package/skills/qingflow-cli/reference/{QINGFLOW_CLI_EXPLORATION_REPORT.md → core/QINGFLOW_CLI_EXPLORATION_REPORT.md} +2 -2
  61. package/skills/qingflow-cli/reference/{QINGFLOW_CLI_FIELD_DATA_TYPES.md → core/QINGFLOW_CLI_FIELD_DATA_TYPES.md} +11 -11
  62. package/skills/qingflow-cli/reference/{QINGFLOW_CLI_MEMBER_CHEATSHEET.md → core/QINGFLOW_CLI_MEMBER_CHEATSHEET.md} +4 -4
  63. package/skills/qingflow-cli/reference/{QINGFLOW_CLI_ONE_SHOT_CHEATSHEET.md → core/QINGFLOW_CLI_ONE_SHOT_CHEATSHEET.md} +4 -4
  64. package/skills/qingflow-cli/reference/{QINGFLOW_CLI_RECORD_CREATE_WORKFLOW.md → record/QINGFLOW_CLI_RECORD_CREATE_WORKFLOW.md} +3 -3
  65. package/skills/qingflow-cli/reference/record/QINGFLOW_CLI_RECORD_DELETE_WORKFLOW.md +31 -0
  66. package/skills/qingflow-cli/reference/{QINGFLOW_CLI_RECORD_IMPORT_WORKFLOW.md → record/QINGFLOW_CLI_RECORD_IMPORT_WORKFLOW.md} +4 -4
  67. package/skills/qingflow-cli/reference/{QINGFLOW_CLI_RECORD_UPDATE_WORKFLOW.md → record/QINGFLOW_CLI_RECORD_UPDATE_WORKFLOW.md} +7 -7
  68. package/skills/qingflow-cli/reference/record/analysis/README.md +130 -0
  69. package/skills/qingflow-cli/reference/record/analysis/analysis-gotchas.md +91 -0
  70. package/skills/qingflow-cli/reference/record/analysis/analysis-patterns.md +112 -0
  71. package/skills/qingflow-cli/reference/record/analysis/business-context.md +74 -0
  72. package/skills/qingflow-cli/reference/record/analysis/confidence-reporting.md +69 -0
  73. package/skills/qingflow-cli/reference/record/analysis/data-access-playbook.md +106 -0
  74. package/skills/qingflow-cli/reference/record/analysis/pandas-recipes.md +172 -0
  75. package/skills/qingflow-cli/reference/record/analysis/report-format.md +76 -0
  76. package/skills/qingflow-cli/reference/record/insert/README.md +75 -0
  77. package/skills/qingflow-cli/reference/{QINGFLOW_CLI_TASK_CONTEXT_WORKFLOW.md → task/QINGFLOW_CLI_TASK_CONTEXT_WORKFLOW.md} +5 -5
  78. package/skills/qingflow-cli/reference/task/ops/README.md +131 -0
  79. package/skills/qingflow-cli/reference/task/ops/environments.md +43 -0
  80. package/skills/qingflow-cli/reference/task/ops/workflow-usage.md +26 -0
  81. package/skills/qingflow-cli/scripts/validate_system_build_summary.py +124 -0
  82. package/skills/qingflow-cli/scripts/workflow/diff_flow_spec.py +275 -0
  83. package/skills/qingflow-cli/scripts/workflow/validate_flow_spec.py +605 -0
  84. package/skills/qingflow-mcp-setup/SKILL.md +115 -0
  85. package/skills/qingflow-mcp-setup/agents/openai.yaml +4 -0
  86. package/skills/qingflow-mcp-setup/references/claude-desktop.md +34 -0
  87. package/skills/qingflow-mcp-setup/references/environments.md +62 -0
  88. package/skills/qingflow-mcp-setup/references/generic-stdio.md +32 -0
  89. package/skills/qingflow-mcp-setup/scripts/check_local_server.sh +38 -0
  90. package/src/qingflow_mcp/__init__.py +1 -1
  91. package/src/qingflow_mcp/__main__.py +6 -2
  92. package/src/qingflow_mcp/builder_facade/models.py +282 -102
  93. package/src/qingflow_mcp/builder_facade/service.py +4192 -935
  94. package/src/qingflow_mcp/cli/commands/builder.py +316 -298
  95. package/src/qingflow_mcp/cli/commands/chart.py +1 -1
  96. package/src/qingflow_mcp/cli/commands/common.py +12 -3
  97. package/src/qingflow_mcp/cli/commands/exports.py +2 -2
  98. package/src/qingflow_mcp/cli/commands/imports.py +3 -3
  99. package/src/qingflow_mcp/cli/commands/portal.py +2 -2
  100. package/src/qingflow_mcp/cli/commands/record.py +101 -27
  101. package/src/qingflow_mcp/cli/commands/task.py +28 -47
  102. package/src/qingflow_mcp/cli/commands/view.py +1 -1
  103. package/src/qingflow_mcp/cli/context.py +0 -3
  104. package/src/qingflow_mcp/cli/formatters.py +784 -16
  105. package/src/qingflow_mcp/cli/main.py +117 -33
  106. package/src/qingflow_mcp/errors.py +43 -2
  107. package/src/qingflow_mcp/public_surface.py +26 -17
  108. package/src/qingflow_mcp/response_trim.py +81 -17
  109. package/src/qingflow_mcp/server.py +14 -12
  110. package/src/qingflow_mcp/server_app_builder.py +65 -21
  111. package/src/qingflow_mcp/server_app_user.py +22 -16
  112. package/src/qingflow_mcp/session_store.py +11 -7
  113. package/src/qingflow_mcp/solution/compiler/__init__.py +3 -1
  114. package/src/qingflow_mcp/solution/compiler/workflow_compiler.py +173 -0
  115. package/src/qingflow_mcp/solution/executor.py +245 -18
  116. package/src/qingflow_mcp/tools/ai_builder_tools.py +1780 -406
  117. package/src/qingflow_mcp/tools/app_tools.py +184 -43
  118. package/src/qingflow_mcp/tools/approval_tools.py +197 -35
  119. package/src/qingflow_mcp/tools/auth_tools.py +92 -16
  120. package/src/qingflow_mcp/tools/code_block_tools.py +298 -40
  121. package/src/qingflow_mcp/tools/custom_button_tools.py +64 -10
  122. package/src/qingflow_mcp/tools/directory_tools.py +236 -72
  123. package/src/qingflow_mcp/tools/export_tools.py +244 -34
  124. package/src/qingflow_mcp/tools/feedback_tools.py +9 -0
  125. package/src/qingflow_mcp/tools/file_tools.py +9 -3
  126. package/src/qingflow_mcp/tools/import_tools.py +336 -49
  127. package/src/qingflow_mcp/tools/navigation_tools.py +91 -12
  128. package/src/qingflow_mcp/tools/package_tools.py +118 -6
  129. package/src/qingflow_mcp/tools/portal_tools.py +39 -3
  130. package/src/qingflow_mcp/tools/qingbi_report_tools.py +116 -7
  131. package/src/qingflow_mcp/tools/record_tools.py +1141 -356
  132. package/src/qingflow_mcp/tools/resource_read_tools.py +188 -39
  133. package/src/qingflow_mcp/tools/role_tools.py +80 -9
  134. package/src/qingflow_mcp/tools/solution_tools.py +59 -45
  135. package/src/qingflow_mcp/tools/task_context_tools.py +662 -158
  136. package/src/qingflow_mcp/tools/task_tools.py +113 -29
  137. package/src/qingflow_mcp/tools/view_tools.py +106 -3
  138. package/src/qingflow_mcp/tools/workflow_tools.py +48 -4
  139. package/src/qingflow_mcp/tools/workspace_tools.py +71 -3
  140. /package/skills/qingflow-cli/reference/{QINGFLOW_CLI_BUILDER_MATCH_RULES.md → builder/reference/match-rules.md} +0 -0
  141. /package/skills/qingflow-cli/reference/{QINGFLOW_CLI_BUILDER_WORKSPACE_ICONS.md → builder/reference/workspace-icons.md} +0 -0
  142. /package/skills/qingflow-cli/reference/{charts_remove.example.json → examples/charts/charts_remove.example.json} +0 -0
  143. /package/skills/qingflow-cli/reference/{charts_reorder.example.json → examples/charts/charts_reorder.example.json} +0 -0
  144. /package/skills/qingflow-cli/reference/{charts_upsert_bar.example.json → examples/charts/charts_upsert_bar.example.json} +0 -0
  145. /package/skills/qingflow-cli/reference/{charts_upsert_dashboard_starter.example.json → examples/charts/charts_upsert_dashboard_starter.example.json} +0 -0
  146. /package/skills/qingflow-cli/reference/{charts_upsert_minimal.example.json → examples/charts/charts_upsert_minimal.example.json} +0 -0
  147. /package/skills/qingflow-cli/reference/{portal_sections_all_types.example.json → examples/portal/portal_sections_all_types.example.json} +0 -0
  148. /package/skills/qingflow-cli/reference/{portal_sections_five_types.example.json → examples/portal/portal_sections_five_types.example.json} +0 -0
  149. /package/skills/qingflow-cli/reference/{portal_sections_standard_workbench.example.json → examples/portal/portal_sections_standard_workbench.example.json} +0 -0
  150. /package/skills/qingflow-cli/reference/{_batch_schema_complex.json → examples/schema/_batch_schema_complex.json} +0 -0
  151. /package/skills/qingflow-cli/reference/{_batch_schema_scalar.json → examples/schema/_batch_schema_scalar.json} +0 -0
  152. /package/skills/qingflow-cli/reference/{schema_add_fields_minimal.example.json → examples/schema/schema_add_fields_minimal.example.json} +0 -0
  153. /package/skills/qingflow-cli/reference/{schema_apply_add_fields_all_types.json → examples/schema/schema_apply_add_fields_all_types.json} +0 -0
  154. /package/skills/qingflow-cli/reference/{views_upsert_table_minimal.example.json → examples/views/views_upsert_table_minimal.example.json} +0 -0
@@ -0,0 +1,123 @@
1
+ # Complete System Development Guide
2
+
3
+ Use this when the user asks for a system, app package, workspace module set, or several related apps/forms.
4
+ Do not compress several business objects into one app.
5
+
6
+ ## Recommended Completeness
7
+
8
+ Required:
9
+
10
+ - package exists or is created through `package_apply`
11
+ - core business objects are modeled as separate apps
12
+ - all new apps are created in one multi-app `app_schema_apply(package_id=..., apps=[...])`
13
+ - every app has stable `client_key`, `app_name`, `icon`, `color`, and one readable `as_data_title: true`
14
+ - no app creates platform system fields such as `数据ID`, `编号`, `申请人`, `申请时间`, `创建人`, `创建时间`, `提交人`, `提交时间`, `更新时间`, `更新人`, `当前流程状态`, `当前处理人`, `当前处理节点`, or `流程标题`
15
+ - same-call relations use `target_app_ref` to point to another `apps[].client_key`
16
+ - basic operating views exist for each core app
17
+ - package/apps/fields/relations are read back before repair or retry
18
+
19
+ Strongly recommended:
20
+
21
+ - cross-app relation fields for the main business links
22
+ - core metric charts and BI charts using semantic `metric`, `metrics`, `group_by`, and `where`
23
+ - a standard portal: business entry area, core metrics, BI charts, then concrete data views
24
+ - portal grid/business-entry sections contain real `config.items[]`, not empty containers
25
+
26
+ Workflow preflight:
27
+
28
+ - If an app will have approval/fill/copy workflow nodes, create an explicit business status `select` field in schema first, such as `状态`, `处理状态`, `审批状态`, `工单状态`, or `流程阶段`.
29
+ - Do not create platform workflow system fields such as `当前流程状态`, `当前处理人`, `当前处理节点`, or `流程标题`.
30
+ - If `app_flow_apply` returns `FLOW_DEPENDENCY_MISSING`, fix schema with the returned `suggested_next_call`, read fields back, then retry the flow. Do not skip the workflow silently.
31
+
32
+ Optional:
33
+
34
+ - workflow, reminders, buttons, associated resources, sample data, roles, and permissions when the user asks for them or the business process clearly depends on them
35
+
36
+ ## Standard Path
37
+
38
+ 1. Resolve or create package: `package_get` / `package_apply`.
39
+ 2. Draft all apps and relations with stable `client_key` values.
40
+ 3. Run one multi-app `app_schema_apply` with `apps[]`.
41
+ 4. If write result is uncertain, run readback before retrying.
42
+ 5. For each app, apply layout and views.
43
+ 6. Create charts before portals when the portal needs metrics or BI sections. Submit chart upserts in batches of 4-8; if `CHART_UPSERT_BATCH_TOO_LARGE` appears, execute `details.suggested_batch_payloads[]` one at a time.
44
+ 7. Create portal only after referenced apps, views, and charts are known.
45
+ 8. Add workflows/buttons/associated resources when they are part of the requested business process.
46
+ 9. Before the final response, write the complete-system delivery summary file described below.
47
+
48
+ ## Field Modeling Rules
49
+
50
+ - Use agent-friendly field types in drafts: `text`, `multiline`, `select`, `multi_select`, `number`, `amount`, `date`, `datetime`, `member`, `department`, `attachment`, `relation`. The tool normalizes aliases such as `multiline -> long_text` and `select -> single_select`.
51
+ - Create only business fields. Do not create platform system fields listed in Required; reference them only where a tool explicitly supports system fields, such as button `source_field: "数据ID"`.
52
+ - Use `number` for ratios, completion rates, scores, percentages, durations, and quantities that may need decimals. Use `amount` only for currency/money semantics. This prevents sample data from producing decimal values for a field that the backend treats as integer money.
53
+ - For select fields, define the option set during schema design. Later sample data must use only those option labels or ids.
54
+
55
+ ## View Query Rules
56
+
57
+ - Use `filters` for fixed saved filters that apply when the view opens.
58
+ - Use `query_conditions` only for the frontend query panel layout. It is not another filter DSL and it does not express OR.
59
+ - `query_conditions.rows` should contain query-panel fields such as text, long text, number, amount, date/datetime, select, member, department, phone, email, or boolean.
60
+ - Do not put relation, attachment, subtable/subfield, address, Q-Linker, or code-block fields in `query_conditions`.
61
+ - For current-record related views/reports, use `app_associated_resources_apply.match_mappings`, not `query_conditions`.
62
+
63
+ ## Delivery Summary File
64
+
65
+ For complete-system builds, create or update one local JSON file before the final response:
66
+
67
+ `tmp/qingflow_system_build_summary.json`
68
+
69
+ Use this file as the structured source of truth for the final report. Include at least:
70
+
71
+ ```json
72
+ {
73
+ "package_id": 0,
74
+ "package_name": "",
75
+ "portal_dash_key": "",
76
+ "portal_live_status": "verified | unverified | not_created",
77
+ "front_end_visible": true,
78
+ "apps": [
79
+ {
80
+ "app_key": "",
81
+ "app_name": "",
82
+ "fields_count": 0,
83
+ "views_count": 0,
84
+ "flows_count": 0,
85
+ "charts_count": 0,
86
+ "publish_verify_status": "verified | unverified | failed"
87
+ }
88
+ ],
89
+ "warnings": [],
90
+ "partial_items": [],
91
+ "needs_followup": []
92
+ }
93
+ ```
94
+
95
+ Rules:
96
+
97
+ - Populate IDs and counts from readback, not from intended payload only.
98
+ - If a required resource is not verified, put it in `partial_items` or `needs_followup` instead of reporting the system as fully complete.
99
+ - If the user later adds a data-entry task, keep that separate from the system-build summary unless the user explicitly wants one combined report.
100
+ - The final response should match this file: completed resources, unverified items, frontend visibility, and follow-up needs must not contradict the JSON.
101
+ - When running from the CLI repo or a test harness, validate the file with:
102
+ `python scripts/validate_system_build_summary.py tmp/qingflow_system_build_summary.json`.
103
+
104
+ ## Recovery Rules
105
+
106
+ - Timeout, `partial_success`, `write_executed=true`, `safe_to_retry=false`, or incomplete readback means `write_may_have_succeeded`.
107
+ - Next action is always `readback_before_retry`: read package, resolve intended apps, then read fields/relations.
108
+ - Retry only verified missing apps, fields, or relations.
109
+ - Do not rebuild the system as separate single-app creates.
110
+ - Do not create `V2`, `测试`, timestamp, or random-suffix apps to bypass duplicate names.
111
+
112
+ ## Portal Template
113
+
114
+ - Top area: one business entry grid plus one todo/common/frequent component when useful.
115
+ - Metrics: one row of 4-6 indicator/target cards with portal section `role: "metric"`; recommended height 5.
116
+ - BI charts: one row of 2-3 charts, 1-2 rows; recommended height 7.
117
+ - Data views: one row of 1-2 concrete views, 1-2 rows; recommended height 11.
118
+
119
+ ## Stop Conditions
120
+
121
+ - If the user only asked for one app, switch to the single-app guide.
122
+ - If required package/app/field/relation readback contradicts the intended model, repair the specific missing slice before building dependent resources.
123
+ - If a public tool cannot express a needed business feature, state the gap and ask before using any fallback or submitting feedback.
@@ -0,0 +1,182 @@
1
+ # Create App
2
+
3
+ Use this when the user wants one new app inside an existing package.
4
+ This playbook follows the current public builder surface, not legacy package helper tools.
5
+
6
+ Do not use this playbook when the user is really asking for a system/package with multiple forms or modules. In that case:
7
+
8
+ 1. read or create the package through `package_get` / `package_apply`
9
+ 2. create each app separately
10
+ 3. keep package ownership on the public `package_id` path instead of a separate attach step
11
+ 4. add relation fields between apps
12
+
13
+ Hierarchy reminder:
14
+
15
+ - package -> app -> field -> relation
16
+ - another business object is another app, not a text field
17
+
18
+ If creating a brand new package would help, ask the user to confirm package creation first. After confirmation, create it through `package_apply(create_if_missing=true, package_name=...)`.
19
+
20
+ ## Minimal sequence
21
+
22
+ 1. `package_get` if `package_id` is already known; otherwise derive the package from related readback or ask the user for the id
23
+ 2. `app_resolve`
24
+ 3. `app_schema_apply`
25
+ 4. `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_get` or `package_apply(create_if_missing=true, package_name=...)`
40
+ 2. for a multi-app system, run one `app_schema_apply` with `apps[]`
41
+ 3. use `apps[].client_key` plus relation field `target_app_ref` when one new app references another new app
42
+
43
+ ## Example
44
+
45
+ Create a new package only after the user confirms package creation:
46
+
47
+ > CLI-only note: this is the payload from former internal surface `package_apply`. Execute it through the matching `qingflow` CLI command and `--*-file` flags from SKILL.md / builder reference; do not call internal tool JSON.
48
+
49
+ ```json
50
+ {
51
+ "package_name": "研发项目管理",
52
+ "create_if_missing": true
53
+ }
54
+ ```
55
+
56
+ Read the package when `package_id` is already known:
57
+
58
+ > CLI-only note: this is the payload from former internal surface `package_get`. Execute it through the matching `qingflow` CLI command and `--*-file` flags from SKILL.md / builder reference; do not call internal tool JSON.
59
+
60
+ ```json
61
+ {
62
+ "package_id": 1218950
63
+ }
64
+ ```
65
+
66
+ Apply schema for a new app:
67
+
68
+ > CLI-only note: this is the payload from former internal surface `app_schema_apply`. Execute it through the matching `qingflow` CLI command and `--*-file` flags from SKILL.md / builder reference; do not call internal tool JSON.
69
+
70
+ ```json
71
+ {
72
+ "app_name": "客户订单",
73
+ "package_id": 1218950,
74
+ "create_if_missing": true,
75
+ "publish": true,
76
+ "add_fields": [
77
+ {
78
+ "name": "订单编号",
79
+ "type": "text",
80
+ "required": true,
81
+ "as_data_title": true
82
+ },
83
+ {
84
+ "name": "客户名称",
85
+ "type": "text",
86
+ "required": true
87
+ },
88
+ {
89
+ "name": "订单封面",
90
+ "type": "attachment",
91
+ "as_data_cover": true
92
+ },
93
+ {
94
+ "name": "订单金额",
95
+ "type": "amount"
96
+ },
97
+ {
98
+ "name": "状态",
99
+ "type": "single_select",
100
+ "options": [
101
+ "草稿",
102
+ "进行中",
103
+ "已完成"
104
+ ],
105
+ "required": true
106
+ }
107
+ ],
108
+ "update_fields": [],
109
+ "remove_fields": []
110
+ }
111
+ ```
112
+
113
+ Apply schema for multiple apps in one call:
114
+
115
+ > CLI-only note: this is the payload from former internal surface `app_schema_apply`. Execute it through the matching `qingflow` CLI command and `--*-file` flags from SKILL.md / builder reference; do not call internal tool JSON.
116
+
117
+ ```json
118
+ {
119
+ "package_id": 1218950,
120
+ "create_if_missing": true,
121
+ "publish": true,
122
+ "apps": [
123
+ {
124
+ "client_key": "customer",
125
+ "app_name": "客户",
126
+ "add_fields": [
127
+ {
128
+ "name": "客户名称",
129
+ "type": "text",
130
+ "required": true,
131
+ "as_data_title": true
132
+ }
133
+ ]
134
+ },
135
+ {
136
+ "client_key": "order",
137
+ "app_name": "订单",
138
+ "add_fields": [
139
+ {
140
+ "name": "订单编号",
141
+ "type": "text",
142
+ "required": true,
143
+ "as_data_title": true
144
+ },
145
+ {
146
+ "name": "关联客户",
147
+ "type": "relation",
148
+ "target_app_ref": "customer",
149
+ "display_field": {
150
+ "name": "客户名称"
151
+ },
152
+ "visible_fields": [
153
+ {
154
+ "name": "客户名称"
155
+ }
156
+ ]
157
+ }
158
+ ]
159
+ }
160
+ ]
161
+ }
162
+ ```
163
+
164
+ Data title is required: mark exactly one top-level field with `as_data_title: true`. Data cover is optional and only valid on a top-level `attachment` field.
165
+
166
+ ## Common failures
167
+
168
+ ### `APP_NOT_FOUND`
169
+
170
+ Expected on create. Continue with `create_if_missing=true`.
171
+
172
+ ### `CREATE_APP_ROUTE_NOT_FOUND`
173
+
174
+ The create route did not resolve in the current backend route context. Re-run `workspace_select`, then retry the same `app_schema_apply`.
175
+
176
+ ### Hierarchy modeling mistake
177
+
178
+ 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:
179
+
180
+ - one package
181
+ - many apps
182
+ - relation fields between those apps
@@ -0,0 +1,63 @@
1
+ # Environment Switching
2
+
3
+ Use this reference before any builder-side write, repair, or verification flow.
4
+
5
+ ## Step 1: Resolve the active environment
6
+
7
+ Decide explicitly whether the task targets:
8
+
9
+ - `test`: build validation, mock data, trial package creation, safe iteration
10
+ - `prod`: formal business system changes in the live environment
11
+
12
+ If the user did not specify an environment, default to `prod`.
13
+
14
+ ## Test Environment
15
+
16
+ Use test for:
17
+
18
+ - first application of a new `SolutionSpec`
19
+ - trying `solution_build_all(..., verify=true)`
20
+ - package initialization and schema evolution experiments
21
+ - mock data creation, with at least `5` records per relevant entity unless the user asks for fewer
22
+
23
+ Builder behavior in test:
24
+
25
+ - `preflight` or `plan` is still preferred, but fast `apply` is acceptable when the user explicitly wants an end-to-end smoke test
26
+ - package creation is acceptable
27
+ - verify should read back apps, views, portal, navigation, and sample records
28
+
29
+ Known current test backend:
30
+
31
+ - use an explicitly provided non-production backend
32
+
33
+ ## Production Environment
34
+
35
+ Use production for:
36
+
37
+ - changes to real business systems
38
+ - additive modifications to live packages and apps
39
+ - controlled rollout of approved solution specs
40
+
41
+ Builder behavior in prod:
42
+
43
+ - always identify the target package or app set before changing anything
44
+ - default to `preflight` or `plan` before any `apply`
45
+ - additive requirements should modify the existing package with ordinary tools by default
46
+ - if creating a new package seems necessary in prod, ask the user to confirm package creation first
47
+ - do not seed mock data unless the user explicitly approves it for production
48
+ - verify is mandatory after writes
49
+
50
+ Production guardrails:
51
+
52
+ - restate the target workspace and target package before any write
53
+ - call out whether the action creates, mutates, or deletes builder-side configuration
54
+ - if a safer read-only inspection can answer the request, do that first
55
+
56
+ ## Reporting Rule
57
+
58
+ For builder work, always report:
59
+
60
+ - active environment
61
+ - target workspace
62
+ - whether the operation is `plan`, `apply`, `repair`, or `verify`
63
+ - whether it touches an existing package or creates a new one
@@ -0,0 +1,142 @@
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_get_fields`
21
+ 2. `app_get_flow`
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
+ > CLI-only note: this is the payload from former internal surface `app_flow_apply`. Execute it through the matching `qingflow` CLI command and `--*-file` flags from SKILL.md / builder reference; do not call internal tool JSON.
32
+
33
+ ```json
34
+ {
35
+ "app_key": "APP_123",
36
+ "preset": "basic_approval",
37
+ "nodes": [
38
+ {
39
+ "id": "approve_1",
40
+ "type": "approve",
41
+ "name": "部门审批",
42
+ "assignees": {
43
+ "role_names": [
44
+ "项目经理"
45
+ ]
46
+ }
47
+ }
48
+ ]
49
+ }
50
+ ```
51
+
52
+ ### Route to explicit members when the user names people
53
+
54
+ > CLI-only note: this is the payload from former internal surface `app_flow_apply`. Execute it through the matching `qingflow` CLI command and `--*-file` flags from SKILL.md / builder reference; do not call internal tool JSON.
55
+
56
+ ```json
57
+ {
58
+ "app_key": "APP_123",
59
+ "preset": "basic_approval",
60
+ "nodes": [
61
+ {
62
+ "id": "approve_1",
63
+ "type": "approve",
64
+ "name": "部门审批",
65
+ "assignees": {
66
+ "member_names": [
67
+ "严琪东",
68
+ "张三"
69
+ ]
70
+ }
71
+ }
72
+ ]
73
+ }
74
+ ```
75
+
76
+ ### Let one node edit selected fields only
77
+
78
+ > CLI-only note: this is the payload from former internal surface `app_flow_apply`. Execute it through the matching `qingflow` CLI command and `--*-file` flags from SKILL.md / builder reference; do not call internal tool JSON.
79
+
80
+ ```json
81
+ {
82
+ "app_key": "APP_123",
83
+ "mode": "replace",
84
+ "publish": true,
85
+ "nodes": [
86
+ {
87
+ "id": "start",
88
+ "type": "start",
89
+ "name": "发起"
90
+ },
91
+ {
92
+ "id": "approve_1",
93
+ "type": "approve",
94
+ "name": "部门审批",
95
+ "assignees": {
96
+ "role_names": [
97
+ "项目经理"
98
+ ]
99
+ },
100
+ "permissions": {
101
+ "editable_fields": [
102
+ "状态",
103
+ "审批意见",
104
+ "项目负责人"
105
+ ]
106
+ }
107
+ },
108
+ {
109
+ "id": "end",
110
+ "type": "end",
111
+ "name": "结束"
112
+ }
113
+ ],
114
+ "transitions": [
115
+ {
116
+ "from": "start",
117
+ "to": "approve_1"
118
+ },
119
+ {
120
+ "from": "approve_1",
121
+ "to": "end"
122
+ }
123
+ ]
124
+ }
125
+ ```
126
+
127
+ ## Common recovery
128
+
129
+ ### `ROLE_NOT_FOUND` / `AMBIGUOUS_ROLE`
130
+
131
+ - retry with `role_search`
132
+ - if the business wants a reusable route and no exact role exists, create one with `role_create`
133
+
134
+ ### `MEMBER_NOT_FOUND` / `AMBIGUOUS_MEMBER`
135
+
136
+ - retry with `member_search`
137
+ - do not guess user ids
138
+
139
+ ### `UNKNOWN_FLOW_FIELD`
140
+
141
+ - reread fields with `app_get_fields`
142
+ - only pass real current field names to `permissions.editable_fields`
@@ -0,0 +1,108 @@
1
+ # Builder Gotchas
2
+
3
+ ## Auth and workspace
4
+
5
+ - `auth_*` success does not mean a workspace is selected
6
+ - Re-run `workspace_select` after auth changes or route changes
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
+ ## Publish
22
+
23
+ - Always pass `publish: true` explicitly on `app_schema_apply`, `app_layout_apply`, `app_flow_apply`, `app_views_apply`, and `portal_apply` — do not rely on the default
24
+ - Pass `publish: false` on those five tools 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 a `publish` parameter
26
+ - `app_charts_apply` is immediate-live and has no publish step
27
+ - `app_publish_verify` is for explicit final verification, not the default next step after every write
28
+
29
+ ## BI Reports
30
+
31
+ - Use `app_charts_apply` for QingBI report body/config creation or updates.
32
+ - 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.
33
+ - `app_charts_apply` currently creates/updates app-source BI reports only (`dataSourceType=qingflow`); dataset BI reports can only be attached when they already exist.
34
+ - Creating a chart with `app_charts_apply` does not automatically show it in the Qingflow app UI; attach it separately if display is required.
35
+ - `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`.
36
+
37
+ ## Custom buttons
38
+
39
+ - 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.
40
+ - 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.
41
+ - For add-data buttons, prefer semantic `trigger_add_data_config.target_app_key`, `field_mappings`, and `default_values`.
42
+ - 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.
43
+ - `field_mappings.source_field` can use source app fields and supported system fields such as `数据ID` (`field_id=-17`) and `编号` (`field_id=0`).
44
+ - To fill a target relation field with the current source record, map `{"source_field": "数据ID", "target_field": "目标引用字段"}`. Use `default_values` only for static constants.
45
+ - For field type compatibility, read `references/match-rules.md`.
46
+ - Default button placements are `header` and `detail`; these map to the frontend's header and detail button areas.
47
+ - `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.
48
+ - 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`.
49
+ - 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.
50
+ - 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.
51
+ - `placement=list` configures row/list buttons. The tool maps it to the backend `INSIDE` button position, not a raw `LIST` config type.
52
+
53
+ ## Associated resources
54
+
55
+ - Before creating an associated view/report, check `app_get.associated_resources` for the same `target_app_key + view_key/chart_key`.
56
+ - If the resource already exists, use `patch_resources` with its `associated_item_id`; do not call `upsert_resources` again.
57
+ - 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.
58
+ - `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.
59
+ - Repeated `upsert_resources` without `associated_item_id` can create multiple app-level associated items pointing to the same view/report.
60
+
61
+ ## Readback scope
62
+
63
+ - Prefer summary reads over large raw payloads
64
+ - Use `app_get_fields` before schema or view work
65
+ - Use `app_get_layout` before layout work
66
+ - Use `app_get_flow` before workflow work
67
+ - Use `app_get_views` before view work
68
+
69
+ ## Partial update discipline
70
+
71
+ - Existing views, custom buttons, associated resources, and charts support the same public partial pattern: `patch_*[].set` plus optional `patch_*[].unset`.
72
+ - The backend may still save a full payload. The CLI patch path is responsible for reading current config and preserving fields the user did not mention.
73
+ - 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.
74
+ - `app_layout_apply(mode=merge)` is already a safe layout merge path; `mode=replace` is full layout replacement.
75
+ - `portal_apply` without `sections` is base-info-only. Supplying `sections` replaces the portal sections list.
76
+ - `app_flow_apply` is intentionally replace-only for the public linear workflow graph.
77
+
78
+ ## Workflow dependencies
79
+
80
+ - Approval-style flows usually require an explicit status field
81
+ - Approval, fill, and copy nodes also require at least one assignee
82
+ - Prefer roles over explicit members unless the user explicitly names people
83
+ - Resolve assignees with `role_search` / `member_search` before flow apply
84
+ - Use `permissions.editable_fields` for node-level editable field permissions; do not guess field ids
85
+ - 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.
86
+ - If `app_flow_apply` reports `FLOW_DEPENDENCY_MISSING`, fix schema first
87
+ - Do not switch to hidden `solution_*` tools from public builder flows
88
+
89
+ ## Retry discipline
90
+
91
+ - If a write returns `partial_success`, read back before retrying
92
+ - Do not repeat create steps after `app_key` already exists
93
+ - For backend rejects, keep the retry narrow: retry only the failed tool, not the whole chain
94
+ - For `VALIDATION_ERROR`, do not keep guessing. Reuse `suggested_next_call`, `canonical_arguments`, `allowed_keys`, and `allowed_values` first.
95
+ - 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 `qingflow --json builder contract(app_layout_apply)`.
96
+ - For flow work, do not replay internal keys from old logs or plan outputs. Public builder calls should stay on:
97
+ - `assignees.role_ids` / `assignees.member_uids` / `assignees.member_emails`
98
+ - `permissions.editable_fields`
99
+ - 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.
100
+ - 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.
101
+ - 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.
102
+ - 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.
103
+ - If duplicate view names exist, do not retry by name. Read the exact `view_key` and target that one.
104
+ - If a view or flow write fails, report the smallest next action:
105
+ - wrong key -> switch to canonical key
106
+ - unsupported preset -> switch to allowed canonical preset
107
+ - backend reject -> re-read summary and retry only the failed patch
108
+ - Do not translate abstract user phrases like “灵活流程” or “默认视图” directly into CLI arguments. First convert them to a preset or explicit patch plan.