bpmax-cli 0.1.44 → 0.2.1-beta.10

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 (276) hide show
  1. package/README.md +79 -5
  2. package/dist/bin.js +14430 -2672
  3. package/dist/bin.js.map +1 -1
  4. package/package.json +1 -1
  5. package/scripts/install-skills.mjs +98 -0
  6. package/skills/bpmax-ai-taskbook/SKILL.md +230 -0
  7. package/skills/bpmax-ai-taskbook/agents/openai.yaml +3 -0
  8. package/skills/bpmax-ai-taskbook/references/taskbook-template.md +68 -0
  9. package/skills/bpmax-api-platform-editor/SKILL.md +321 -0
  10. package/skills/bpmax-api-platform-editor/agents/openai.yaml +4 -0
  11. package/skills/bpmax-api-platform-editor/references/api-doc-debug-workflow.md +34 -0
  12. package/skills/bpmax-api-platform-editor/references/api-proxy-shape.md +41 -0
  13. package/skills/bpmax-api-platform-editor/references/instance-config-shape.md +41 -0
  14. package/skills/bpmax-api-platform-editor/references/platform-api-map.md +52 -0
  15. package/skills/bpmax-api-platform-editor/references/runtime-workflow.md +32 -0
  16. package/skills/bpmax-api-platform-editor/scripts/api_platform_editor_common.py +1276 -0
  17. package/skills/bpmax-api-platform-editor/scripts/build_submit_payload.py +64 -0
  18. package/skills/bpmax-api-platform-editor/scripts/capture_write_contract.py +40 -0
  19. package/skills/bpmax-api-platform-editor/scripts/export_layer_bundle.py +212 -0
  20. package/skills/bpmax-api-platform-editor/scripts/record_doc_debug_acceptance.py +62 -0
  21. package/skills/bpmax-api-platform-editor/scripts/submit_and_verify_layer.py +75 -0
  22. package/skills/bpmax-api-platform-editor/tests/test_api_platform_editor.py +287 -0
  23. package/skills/bpmax-approval-matrix/SKILL.md +90 -0
  24. package/skills/bpmax-auth/SKILL.md +6 -17
  25. package/skills/bpmax-blueprint-doc-workflow/SKILL.md +87 -0
  26. package/skills/bpmax-blueprint-doc-workflow/agents/openai.yaml +4 -0
  27. package/skills/bpmax-blueprint-doc-workflow/references/blueprint-structure.md +60 -0
  28. package/skills/bpmax-blueprint-doc-workflow/references/per-flow-required-structure.md +98 -0
  29. package/skills/bpmax-blueprint-doc-workflow/references/sample-forbidden-term.xml +12 -0
  30. package/skills/bpmax-blueprint-doc-workflow/references/sample-mermaid-codeblock.xml +12 -0
  31. package/skills/bpmax-blueprint-doc-workflow/references/sample-missing-boundary.xml +10 -0
  32. package/skills/bpmax-blueprint-doc-workflow/references/sample-missing-whiteboard.xml +10 -0
  33. package/skills/bpmax-blueprint-doc-workflow/references/sample-pass.xml +55 -0
  34. package/skills/bpmax-blueprint-doc-workflow/scripts/lint_blueprint_doc.py +257 -0
  35. package/skills/bpmax-builder-shared/SKILL.md +44 -0
  36. package/skills/bpmax-builder-shared/base_url.py +81 -0
  37. package/skills/bpmax-builder-shared/runtime-script-site-matrix.json +71 -0
  38. package/skills/bpmax-builder-shared/runtime-script-site-matrix.md +34 -0
  39. package/skills/bpmax-builder-shared/runtime-script-template-catalog.md +123 -0
  40. package/skills/bpmax-builder-shared/runtime_script_rules.py +272 -0
  41. package/skills/bpmax-builder-shared/skill_audit.py +374 -0
  42. package/skills/bpmax-builder-shared/template_script_hard_rules.py +280 -0
  43. package/skills/bpmax-builder-shared/tests/test_base_url.py +80 -0
  44. package/skills/bpmax-builder-shared/tests/test_runtime_script_rules.py +115 -0
  45. package/skills/bpmax-builder-shared/tests/test_skill_audit.py +231 -0
  46. package/skills/bpmax-builder-shared/tests/test_template_script_hard_rules.py +281 -0
  47. package/skills/bpmax-cli/SKILL.md +5 -0
  48. package/skills/bpmax-config-latest/SKILL.md +71 -0
  49. package/skills/bpmax-console-template-editor/SKILL.md +536 -0
  50. package/skills/bpmax-console-template-editor/agents/openai.yaml +4 -0
  51. package/skills/bpmax-console-template-editor/references/filter-integration.md +60 -0
  52. package/skills/bpmax-console-template-editor/references/lessons-from-resume-dashboard.md +114 -0
  53. package/skills/bpmax-console-template-editor/references/local-temp-workflow.md +69 -0
  54. package/skills/bpmax-console-template-editor/references/module-catalog.md +100 -0
  55. package/skills/bpmax-console-template-editor/references/runtime-page-shape.md +91 -0
  56. package/skills/bpmax-console-template-editor/references/template-shape.md +149 -0
  57. package/skills/bpmax-console-template-editor/scripts/build_submit_payload.py +38 -0
  58. package/skills/bpmax-console-template-editor/scripts/confirm_console_template.py +33 -0
  59. package/skills/bpmax-console-template-editor/scripts/console_template_editor_common.py +964 -0
  60. package/skills/bpmax-console-template-editor/scripts/export_console_template.py +99 -0
  61. package/skills/bpmax-console-template-editor/scripts/lint_console_template.py +46 -0
  62. package/skills/bpmax-console-template-editor/scripts/submit_console_template.py +99 -0
  63. package/skills/bpmax-console-template-editor/tests/test_console_template_editor.py +383 -0
  64. package/skills/bpmax-dataset-field-template-editor/SKILL.md +606 -0
  65. package/skills/bpmax-dataset-field-template-editor/references/create-request-gotchas.md +25 -0
  66. package/skills/bpmax-dataset-field-template-editor/references/field-classify-mapping.md +35 -0
  67. package/skills/bpmax-dataset-field-template-editor/references/nested-field-patterns.md +24 -0
  68. package/skills/bpmax-dataset-field-template-editor/references/runtime-verified-field-page-shape.md +61 -0
  69. package/skills/bpmax-dataset-field-template-editor/references/virtual-field-patterns.md +27 -0
  70. package/skills/bpmax-dataset-field-template-editor/references/work-file-to-submit-mapping.md +127 -0
  71. package/skills/bpmax-dataset-field-template-editor/scripts/build_submit_payload.py +67 -0
  72. package/skills/bpmax-dataset-field-template-editor/scripts/confirm_dataset_field.py +37 -0
  73. package/skills/bpmax-dataset-field-template-editor/scripts/dataset_field_editor_common.py +784 -0
  74. package/skills/bpmax-dataset-field-template-editor/scripts/export_dataset_field.py +62 -0
  75. package/skills/bpmax-dataset-field-template-editor/scripts/init_create_dataset_field.py +104 -0
  76. package/skills/bpmax-dataset-field-template-editor/scripts/inspect_dataset_field_runtime.py +83 -0
  77. package/skills/bpmax-dataset-field-template-editor/scripts/lint_dataset_field_semantics.py +35 -0
  78. package/skills/bpmax-dataset-field-template-editor/scripts/submit_dataset_field.py +95 -0
  79. package/skills/bpmax-dataset-field-template-editor/tests/test_dataset_field_editor.py +709 -0
  80. package/skills/bpmax-dataset-field-template-editor/tests/test_init_create_dataset_field.py +59 -0
  81. package/skills/bpmax-dataset-template-editor/SKILL.md +789 -0
  82. package/skills/bpmax-dataset-template-editor/references/custom-key-usage-patterns.md +18 -0
  83. package/skills/bpmax-dataset-template-editor/references/dataset-script-runtime-matrix.md +73 -0
  84. package/skills/bpmax-dataset-template-editor/references/pre-process-script-authoring-guide.md +186 -0
  85. package/skills/bpmax-dataset-template-editor/references/pre-process-script-example-catalog.md +106 -0
  86. package/skills/bpmax-dataset-template-editor/references/runtime-gotchas.md +28 -0
  87. package/skills/bpmax-dataset-template-editor/references/runtime-verified-dataset-page-shape.md +47 -0
  88. package/skills/bpmax-dataset-template-editor/references/ui-to-backend-field-map.md +23 -0
  89. package/skills/bpmax-dataset-template-editor/references/work-file-to-submit-mapping.md +97 -0
  90. package/skills/bpmax-dataset-template-editor/scripts/basic_table_audit.py +65 -0
  91. package/skills/bpmax-dataset-template-editor/scripts/build_submit_payload.py +38 -0
  92. package/skills/bpmax-dataset-template-editor/scripts/dataset_editor_common.py +650 -0
  93. package/skills/bpmax-dataset-template-editor/scripts/export_dataset.py +155 -0
  94. package/skills/bpmax-dataset-template-editor/scripts/lint_dataset_template.py +42 -0
  95. package/skills/bpmax-dataset-template-editor/scripts/resolve_dataset.py +43 -0
  96. package/skills/bpmax-dataset-template-editor/scripts/scan_custom_key_references.py +27 -0
  97. package/skills/bpmax-dataset-template-editor/scripts/submit_dataset.py +115 -0
  98. package/skills/bpmax-dataset-template-editor/scripts/verify_dataset_list.py +52 -0
  99. package/skills/bpmax-dataset-template-editor/scripts/verify_publish_health.py +39 -0
  100. package/skills/bpmax-dataset-template-editor/tests/test_dataset_editor.py +373 -0
  101. package/skills/bpmax-e2e-flow-config-orchestrator/SKILL.md +227 -0
  102. package/skills/bpmax-e2e-flow-config-orchestrator/agents/openai.yaml +4 -0
  103. package/skills/bpmax-e2e-flow-config-orchestrator/references/orchestration-matrix.md +63 -0
  104. package/skills/bpmax-e2e-flow-test-operator/SKILL.md +564 -0
  105. package/skills/bpmax-e2e-flow-test-operator/agents/openai.yaml +5 -0
  106. package/skills/bpmax-e2e-flow-test-operator/profiles/negative_sale.json +97 -0
  107. package/skills/bpmax-e2e-flow-test-operator/profiles/negative_sale_final_v2.json +105 -0
  108. package/skills/bpmax-e2e-flow-test-operator/profiles/negative_sale_main.json +36 -0
  109. package/skills/bpmax-e2e-flow-test-operator/profiles/negative_sale_region.json +40 -0
  110. package/skills/bpmax-e2e-flow-test-operator/references/ai-test-suite.md +355 -0
  111. package/skills/bpmax-e2e-flow-test-operator/references/browser-only-checkpoints.md +41 -0
  112. package/skills/bpmax-e2e-flow-test-operator/references/failure-update-loop.md +17 -0
  113. package/skills/bpmax-e2e-flow-test-operator/references/filter-field-discovery.md +40 -0
  114. package/skills/bpmax-e2e-flow-test-operator/references/minimal-test-loop.md +24 -0
  115. package/skills/bpmax-e2e-flow-test-operator/references/negative-sale-api-matrix.md +75 -0
  116. package/skills/bpmax-e2e-flow-test-operator/references/profile-schema.md +109 -0
  117. package/skills/bpmax-e2e-flow-test-operator/references/skill-experience-coverage-matrix.md +29 -0
  118. package/skills/bpmax-e2e-flow-test-operator/references/stale-runtime-and-clean-sample-rules.md +54 -0
  119. package/skills/bpmax-e2e-flow-test-operator/references/state-schema.md +83 -0
  120. package/skills/bpmax-e2e-flow-test-operator/scripts/bpmax_session.py +287 -0
  121. package/skills/bpmax-e2e-flow-test-operator/scripts/dealer_sample_on_shelf_plan.json +59 -0
  122. package/skills/bpmax-e2e-flow-test-operator/scripts/dealer_sample_on_shelf_runner.py +687 -0
  123. package/skills/bpmax-e2e-flow-test-operator/scripts/e2e_doc.py +121 -0
  124. package/skills/bpmax-e2e-flow-test-operator/scripts/e2e_state.py +288 -0
  125. package/skills/bpmax-e2e-flow-test-operator/scripts/flow_api_matrix.py +161 -0
  126. package/skills/bpmax-e2e-flow-test-operator/scripts/flow_filter_fields.py +138 -0
  127. package/skills/bpmax-e2e-flow-test-operator/scripts/flow_form_runtime.py +396 -0
  128. package/skills/bpmax-e2e-flow-test-operator/scripts/flow_runner.py +341 -0
  129. package/skills/bpmax-e2e-flow-test-operator/scripts/flow_test_profile.py +185 -0
  130. package/skills/bpmax-e2e-flow-test-operator/tests/test_negative_sale_api_tools.py +138 -0
  131. package/skills/bpmax-feishu-chat-flow-plugin-editor/SKILL.md +69 -0
  132. package/skills/bpmax-feishu-chat-flow-plugin-editor/agents/openai.yaml +4 -0
  133. package/skills/bpmax-feishu-chat-flow-plugin-editor/references/config-checklist.md +42 -0
  134. package/skills/bpmax-feishu-chat-flow-plugin-editor/references/config-recipes.md +38 -0
  135. package/skills/bpmax-feishu-chat-flow-plugin-editor/references/config-shape.md +86 -0
  136. package/skills/bpmax-feishu-chat-flow-plugin-editor/references/gate-lint.md +68 -0
  137. package/skills/bpmax-feishu-chat-flow-plugin-editor/references/hoocoo-patterns.md +39 -0
  138. package/skills/bpmax-feishu-chat-flow-plugin-editor/references/runtime-behavior.md +41 -0
  139. package/skills/bpmax-feishu-chat-flow-plugin-editor/references/script-authoring.md +110 -0
  140. package/skills/bpmax-feishu-chat-flow-plugin-editor/scripts/lint_feishu_chat_plugin.py +278 -0
  141. package/skills/bpmax-feishu-chat-flow-plugin-editor/tests/test_lint_feishu_chat_plugin.py +203 -0
  142. package/skills/bpmax-filter-template-editor/SKILL.md +564 -0
  143. package/skills/bpmax-filter-template-editor/references/experience-coverage-matrix.md +38 -0
  144. package/skills/bpmax-filter-template-editor/references/filter-and-flow-binding.md +57 -0
  145. package/skills/bpmax-filter-template-editor/references/filter-content-schema.md +141 -0
  146. package/skills/bpmax-filter-template-editor/references/filter-request-shape.md +287 -0
  147. package/skills/bpmax-filter-template-editor/references/filter-runtime-patterns.md +115 -0
  148. package/skills/bpmax-filter-template-editor/references/runtime-verified-filter-page-shape.md +94 -0
  149. package/skills/bpmax-filter-template-editor/scripts/build_submit_payload.py +25 -0
  150. package/skills/bpmax-filter-template-editor/scripts/confirm_filter_template.py +22 -0
  151. package/skills/bpmax-filter-template-editor/scripts/export_filter_template.py +57 -0
  152. package/skills/bpmax-filter-template-editor/scripts/filter_template_editor_common.py +348 -0
  153. package/skills/bpmax-filter-template-editor/scripts/init_create_filter_template.py +8 -0
  154. package/skills/bpmax-filter-template-editor/scripts/lint_filter_template_semantics.py +26 -0
  155. package/skills/bpmax-filter-template-editor/scripts/submit_filter_template.py +62 -0
  156. package/skills/bpmax-filter-template-editor/tests/test_filter_template_editor.py +231 -0
  157. package/skills/bpmax-flow-template-editor/SKILL.md +1148 -0
  158. package/skills/bpmax-flow-template-editor/agents/openai.yaml +4 -0
  159. package/skills/bpmax-flow-template-editor/references/before-next-step-script-runtime-gotchas.md +62 -0
  160. package/skills/bpmax-flow-template-editor/references/config-surfaces-and-placeholders.md +270 -0
  161. package/skills/bpmax-flow-template-editor/references/diff-strategy.md +67 -0
  162. package/skills/bpmax-flow-template-editor/references/editor-runtime-vs-draft.md +25 -0
  163. package/skills/bpmax-flow-template-editor/references/flow-template-api-workflow.md +174 -0
  164. package/skills/bpmax-flow-template-editor/references/intent-model.md +117 -0
  165. package/skills/bpmax-flow-template-editor/references/lessons-from-price-plan-flow.md +147 -0
  166. package/skills/bpmax-flow-template-editor/references/local-temp-workflow.md +97 -0
  167. package/skills/bpmax-flow-template-editor/references/matrix-flow-form-nav-collaboration.md +168 -0
  168. package/skills/bpmax-flow-template-editor/references/payload-checklist.md +133 -0
  169. package/skills/bpmax-flow-template-editor/references/project-create-runtime-gotchas.md +106 -0
  170. package/skills/bpmax-flow-template-editor/references/requirement-to-node-mapping.md +149 -0
  171. package/skills/bpmax-flow-template-editor/references/runtime-verified-flow-detail-shape.md +41 -0
  172. package/skills/bpmax-flow-template-editor/references/runtime-verified-meta-fields.md +155 -0
  173. package/skills/bpmax-flow-template-editor/references/runtime-verified-node-fields.md +179 -0
  174. package/skills/bpmax-flow-template-editor/references/save-draft-request-shape.md +91 -0
  175. package/skills/bpmax-flow-template-editor/references/script-review-hard-rules.md +96 -0
  176. package/skills/bpmax-flow-template-editor/references/work-file-to-submit-mapping.md +57 -0
  177. package/skills/bpmax-flow-template-editor/scripts/build_submit_payload.py +69 -0
  178. package/skills/bpmax-flow-template-editor/scripts/confirm_flow_template.py +52 -0
  179. package/skills/bpmax-flow-template-editor/scripts/export_flow_template.py +114 -0
  180. package/skills/bpmax-flow-template-editor/scripts/flow_template_editor_common.py +1084 -0
  181. package/skills/bpmax-flow-template-editor/scripts/submit_flow_template.py +159 -0
  182. package/skills/bpmax-flow-template-editor/tests/test_flow_template_editor.py +636 -0
  183. package/skills/bpmax-form-template-editor/SKILL.md +1160 -0
  184. package/skills/bpmax-form-template-editor/agents/openai.yaml +4 -0
  185. package/skills/bpmax-form-template-editor/references/form-template-api-workflow.md +203 -0
  186. package/skills/bpmax-form-template-editor/references/local-temp-workflow.md +125 -0
  187. package/skills/bpmax-form-template-editor/references/payload-checklist.md +77 -0
  188. package/skills/bpmax-form-template-editor/references/sub-form-patterns.md +49 -0
  189. package/skills/bpmax-form-template-editor/scripts/build_submit_payload.py +37 -0
  190. package/skills/bpmax-form-template-editor/scripts/check_form_template_consistency.py +145 -0
  191. package/skills/bpmax-form-template-editor/scripts/confirm_form_template.py +67 -0
  192. package/skills/bpmax-form-template-editor/scripts/export_form_template.py +91 -0
  193. package/skills/bpmax-form-template-editor/scripts/form_template_editor_common.py +1762 -0
  194. package/skills/bpmax-form-template-editor/scripts/lint_form_template_semantics.py +30 -0
  195. package/skills/bpmax-form-template-editor/scripts/record_runtime_acceptance.py +67 -0
  196. package/skills/bpmax-form-template-editor/scripts/submit_form_template.py +163 -0
  197. package/skills/bpmax-form-template-editor/tests/test_form_template_editor.py +1292 -0
  198. package/skills/bpmax-list-template-editor/SKILL.md +478 -0
  199. package/skills/bpmax-list-template-editor/agents/openai.yaml +4 -0
  200. package/skills/bpmax-list-template-editor/references/browser-page-contract.md +81 -0
  201. package/skills/bpmax-list-template-editor/references/content-config-shape.md +165 -0
  202. package/skills/bpmax-list-template-editor/references/dataset-field-mapping.md +60 -0
  203. package/skills/bpmax-list-template-editor/references/list-template-api-workflow.md +108 -0
  204. package/skills/bpmax-list-template-editor/references/local-temp-workflow.md +102 -0
  205. package/skills/bpmax-list-template-editor/references/payload-checklist.md +47 -0
  206. package/skills/bpmax-list-template-editor/references/runtime-verified-workflow.md +147 -0
  207. package/skills/bpmax-list-template-editor/references/special-formats.md +411 -0
  208. package/skills/bpmax-list-template-editor/scripts/build_submit_payload.py +37 -0
  209. package/skills/bpmax-list-template-editor/scripts/confirm_list_template.py +33 -0
  210. package/skills/bpmax-list-template-editor/scripts/export_list_template.py +89 -0
  211. package/skills/bpmax-list-template-editor/scripts/fetch_data_set.py +34 -0
  212. package/skills/bpmax-list-template-editor/scripts/lint_list_template_semantics.py +54 -0
  213. package/skills/bpmax-list-template-editor/scripts/list_template_editor_common.py +955 -0
  214. package/skills/bpmax-list-template-editor/scripts/record_acceptance.py +55 -0
  215. package/skills/bpmax-list-template-editor/scripts/submit_list_template.py +117 -0
  216. package/skills/bpmax-list-template-editor/tests/test_list_template_editor_common.py +441 -0
  217. package/skills/bpmax-memory-protocol/SKILL.md +72 -0
  218. package/skills/bpmax-nav-config-editor/SKILL.md +350 -0
  219. package/skills/bpmax-nav-config-editor/agents/openai.yaml +4 -0
  220. package/skills/bpmax-nav-config-editor/references/api-workflow.md +70 -0
  221. package/skills/bpmax-nav-config-editor/references/config-shape.md +78 -0
  222. package/skills/bpmax-nav-config-editor/references/icon-selection.md +83 -0
  223. package/skills/bpmax-nav-config-editor/references/path-mapping-rules.md +51 -0
  224. package/skills/bpmax-nav-config-editor/references/payload-checklist.md +41 -0
  225. package/skills/bpmax-nav-config-editor/references/runtime-probing.md +47 -0
  226. package/skills/bpmax-nav-config-editor/scripts/build_submit_payload.py +34 -0
  227. package/skills/bpmax-nav-config-editor/scripts/confirm_nav_config.py +32 -0
  228. package/skills/bpmax-nav-config-editor/scripts/export_nav_config.py +56 -0
  229. package/skills/bpmax-nav-config-editor/scripts/lint_nav_config_semantics.py +33 -0
  230. package/skills/bpmax-nav-config-editor/scripts/nav_config_editor_common.py +812 -0
  231. package/skills/bpmax-nav-config-editor/scripts/submit_nav_config.py +44 -0
  232. package/skills/bpmax-nav-config-editor/scripts/verify_nav_config.py +33 -0
  233. package/skills/bpmax-nav-config-editor/tests/test_nav_config_editor.py +358 -0
  234. package/skills/bpmax-nav-config-editor/tests/test_nav_config_editor_common.py +138 -0
  235. package/skills/bpmax-nav-config-editor/tests/test_nav_config_lint.py +58 -0
  236. package/skills/bpmax-nav-config-editor/tests/test_nav_config_submit_verify.py +51 -0
  237. package/skills/bpmax-plugin-config/SKILL.md +42 -0
  238. package/skills/bpmax-project/SKILL.md +17 -3
  239. package/skills/bpmax-project-detail-template-editor/SKILL.md +355 -0
  240. package/skills/bpmax-project-detail-template-editor/agents/openai.yaml +4 -0
  241. package/skills/bpmax-project-detail-template-editor/references/local-temp-workflow.md +59 -0
  242. package/skills/bpmax-project-detail-template-editor/references/module-catalog-and-config-notes.md +120 -0
  243. package/skills/bpmax-project-detail-template-editor/references/payload-checklist.md +33 -0
  244. package/skills/bpmax-project-detail-template-editor/references/project-detail-template-api-workflow.md +44 -0
  245. package/skills/bpmax-project-detail-template-editor/scripts/build_submit_payload.py +30 -0
  246. package/skills/bpmax-project-detail-template-editor/scripts/confirm_project_detail_template.py +33 -0
  247. package/skills/bpmax-project-detail-template-editor/scripts/export_project_detail_template.py +87 -0
  248. package/skills/bpmax-project-detail-template-editor/scripts/lint_project_detail_template_semantics.py +37 -0
  249. package/skills/bpmax-project-detail-template-editor/scripts/project_detail_template_editor_common.py +507 -0
  250. package/skills/bpmax-project-detail-template-editor/scripts/submit_project_detail_template.py +120 -0
  251. package/skills/bpmax-project-detail-template-editor/tests/test_project_detail_template_editor.py +369 -0
  252. package/skills/bpmax-role-editor/SKILL.md +251 -0
  253. package/skills/bpmax-role-editor/references/api-workflow.md +30 -0
  254. package/skills/bpmax-role-editor/references/runtime-page-shape.md +18 -0
  255. package/skills/bpmax-role-editor/references/work-file-mapping.md +32 -0
  256. package/skills/bpmax-role-editor/scripts/build_submit_payload.py +38 -0
  257. package/skills/bpmax-role-editor/scripts/confirm_role.py +33 -0
  258. package/skills/bpmax-role-editor/scripts/export_role.py +163 -0
  259. package/skills/bpmax-role-editor/scripts/lint_role_semantics.py +38 -0
  260. package/skills/bpmax-role-editor/scripts/role_editor_common.py +1231 -0
  261. package/skills/bpmax-role-editor/scripts/submit_role.py +144 -0
  262. package/skills/bpmax-role-editor/tests/test_role_editor.py +343 -0
  263. package/skills/bpmax-shared/SKILL.md +1 -1
  264. package/skills/bpmax-user-mock-operator/SKILL.md +106 -0
  265. package/skills/bpmax-user-mock-operator/agents/openai.yaml +4 -0
  266. package/skills/bpmax-user-mock-operator/scripts/switch_user_identity.py +37 -0
  267. package/skills/bpmax-user-mock-operator/scripts/user_mock_operator_common.py +136 -0
  268. package/skills/bpmax-user-mock-operator/tests/test_user_mock_operator.py +138 -0
  269. package/skills/bpmax-workspace-editor/SKILL.md +78 -0
  270. package/skills/bpmax-workspace-editor/agents/openai.yaml +4 -0
  271. package/skills/form-control-library/SKILL.md +82 -0
  272. package/skills/form-control-library/agents/openai.yaml +4 -0
  273. package/skills/form-control-library/references/form-controls.md +199 -0
  274. package/skills/form-control-library/references/form-template-submit-schema.md +180 -0
  275. package/skills/form-control-library/references/group-select-runtime.md +191 -0
  276. package/skills/form-control-library/scripts/rebuild_form_control_library.py +55 -0
@@ -0,0 +1,955 @@
1
+ #!/usr/bin/env python3
2
+ from __future__ import annotations
3
+
4
+ import copy
5
+ import hashlib
6
+ import json
7
+ import os
8
+ import sys
9
+ import ssl
10
+ import urllib.error
11
+ import urllib.parse
12
+ import urllib.request
13
+ from dataclasses import dataclass
14
+ from datetime import datetime, timezone
15
+ from difflib import unified_diff
16
+ from pathlib import Path
17
+ from typing import Any, Dict, Iterable, Optional
18
+
19
+
20
+ SHARED_SKILL_ROOT = Path(__file__).resolve().parents[2] / "bpmax-builder-shared"
21
+ if str(SHARED_SKILL_ROOT) not in sys.path:
22
+ sys.path.insert(0, str(SHARED_SKILL_ROOT))
23
+ from base_url import DEFAULT_BASE_URL, resolve_base_url
24
+
25
+ DEFAULT_LANGUAGE = "zhCN"
26
+ REPO_ROOT = Path(__file__).resolve().parents[4]
27
+ TMP_ROOT = REPO_ROOT / ".codex" / "tmp" / "list-template-editor"
28
+ TMP_SUBDIRS = ("raw", "work", "meta", "submit", "diffs", "result")
29
+ ALLOWED_COLUMN_KEYS = {
30
+ "title",
31
+ "props",
32
+ "createElement",
33
+ "icon",
34
+ "iconColor",
35
+ "isSort",
36
+ "sortConf",
37
+ "preset",
38
+ }
39
+ FORBIDDEN_FORM_KEYS = {
40
+ "rule",
41
+ "value",
42
+ "field",
43
+ "field_type",
44
+ "validateMap",
45
+ "form_rule_id",
46
+ "form_template_id",
47
+ "template_id",
48
+ }
49
+ DEFAULT_ICON_COLOR = "#D6DCE5"
50
+ ALLOWED_ICON_COLORS = {
51
+ DEFAULT_ICON_COLOR,
52
+ "#D6DCE5",
53
+ "#d6dce5",
54
+ }
55
+ HIGH_RISK_REASONS = {
56
+ "script_column",
57
+ "badge_column",
58
+ "icon_column",
59
+ "avatar_column",
60
+ "visual_tuning",
61
+ "action_column",
62
+ "image_preview_column",
63
+ "data_set_switch",
64
+ }
65
+
66
+ from template_script_hard_rules import scan_named_script_surfaces
67
+
68
+
69
+ def utc_now_iso() -> str:
70
+ return datetime.now(timezone.utc).isoformat()
71
+
72
+
73
+ def ensure_tmp_dirs() -> None:
74
+ for part in TMP_SUBDIRS:
75
+ (TMP_ROOT / part).mkdir(parents=True, exist_ok=True)
76
+
77
+
78
+ def paths_for(stem: str) -> Dict[str, Path]:
79
+ ensure_tmp_dirs()
80
+ return {
81
+ "raw": TMP_ROOT / "raw" / f"{stem}.json",
82
+ "work": TMP_ROOT / "work" / f"{stem}.json",
83
+ "meta": TMP_ROOT / "meta" / f"{stem}.json",
84
+ "submit": TMP_ROOT / "submit" / f"{stem}.json",
85
+ "work_diff": TMP_ROOT / "diffs" / f"{stem}.work.diff.txt",
86
+ "submit_diff": TMP_ROOT / "diffs" / f"{stem}.submit.diff.txt",
87
+ "response": TMP_ROOT / "result" / f"{stem}.response.json",
88
+ "readback": TMP_ROOT / "result" / f"{stem}.readback.json",
89
+ "readback_diff": TMP_ROOT / "result" / f"{stem}.readback.diff.txt",
90
+ "verify": TMP_ROOT / "result" / f"{stem}.verify.json",
91
+ "semantic_lint": TMP_ROOT / "result" / f"{stem}.semantic-lint.json",
92
+ "data_set_list": TMP_ROOT / "result" / f"{stem}.data-set-list.json",
93
+ "acceptance": TMP_ROOT / "result" / f"{stem}.acceptance.json",
94
+ }
95
+
96
+
97
+ def dump_json(path: Path, payload: Any) -> None:
98
+ path.parent.mkdir(parents=True, exist_ok=True)
99
+ path.write_text(json.dumps(payload, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
100
+
101
+
102
+ def load_json(path: Path) -> Any:
103
+ return json.loads(path.read_text(encoding="utf-8"))
104
+
105
+
106
+ def file_sha256(path: Path) -> str:
107
+ return hashlib.sha256(path.read_bytes()).hexdigest()
108
+
109
+
110
+ def load_meta(path: Path) -> Dict[str, Any]:
111
+ if not path.exists():
112
+ return {}
113
+ payload = load_json(path)
114
+ if not isinstance(payload, dict):
115
+ raise SystemExit(f"invalid meta file, expected object: {path}")
116
+ return payload
117
+
118
+
119
+ def stable_json_lines(payload: Any) -> list[str]:
120
+ return (json.dumps(payload, ensure_ascii=False, indent=2, sort_keys=True) + "\n").splitlines(keepends=True)
121
+
122
+
123
+ def write_diff(path: Path, before: Any, after: Any, before_label: str, after_label: str) -> None:
124
+ diff = unified_diff(
125
+ stable_json_lines(before),
126
+ stable_json_lines(after),
127
+ fromfile=before_label,
128
+ tofile=after_label,
129
+ )
130
+ path.parent.mkdir(parents=True, exist_ok=True)
131
+ text = "".join(diff)
132
+ path.write_text(text or "# no diff\n", encoding="utf-8")
133
+
134
+
135
+ def create_stem(workspace: str, sample_template_id: Any | None = None, flow_type: str | None = None) -> str:
136
+ if sample_template_id not in (None, ""):
137
+ return f"create-{workspace}-{sample_template_id}"
138
+ if flow_type:
139
+ return f"create-{workspace}-{flow_type}"
140
+ raise SystemExit("create stem requires sample template id or flow type")
141
+
142
+
143
+ def normalize_whitespace(value: str) -> str:
144
+ return " ".join(str(value).strip().split())
145
+
146
+
147
+ def parse_content(value: Any) -> Dict[str, Any]:
148
+ if isinstance(value, dict):
149
+ payload = copy.deepcopy(value)
150
+ elif isinstance(value, str) and value.strip():
151
+ try:
152
+ payload = json.loads(value)
153
+ except json.JSONDecodeError as exc:
154
+ raise SystemExit(f"content is not valid JSON: {exc}") from exc
155
+ else:
156
+ payload = {}
157
+ if not isinstance(payload, dict):
158
+ raise SystemExit("content payload must be an object")
159
+ payload.setdefault("level", 0)
160
+ payload.setdefault("config", [])
161
+ if not isinstance(payload["config"], list):
162
+ raise SystemExit("content.config must be an array")
163
+ return payload
164
+
165
+
166
+ def serialize_content(content: Dict[str, Any]) -> str:
167
+ normalized = parse_content(content)
168
+ return json.dumps(normalized, ensure_ascii=False, separators=(",", ":"))
169
+
170
+
171
+ def extract_template_refs(value: Any) -> set[str]:
172
+ refs: set[str] = set()
173
+ if isinstance(value, dict):
174
+ template = value.get("$template")
175
+ if isinstance(template, str):
176
+ refs.update(_extract_ctx_refs_from_template(template))
177
+ for inner in value.values():
178
+ refs.update(extract_template_refs(inner))
179
+ elif isinstance(value, list):
180
+ for item in value:
181
+ refs.update(extract_template_refs(item))
182
+ return refs
183
+
184
+
185
+ def _extract_ctx_refs_from_template(template: str) -> set[str]:
186
+ import re
187
+
188
+ refs = set()
189
+ for match in re.finditer(r"\bctx\.([A-Za-z_][A-Za-z0-9_]*)", template):
190
+ key = match.group(1)
191
+ if key and not key.startswith("$"):
192
+ refs.add(key)
193
+ return refs
194
+
195
+
196
+ def detect_column_risks(column: Dict[str, Any]) -> set[str]:
197
+ reasons: set[str] = set()
198
+ create_element = column.get("createElement") or {}
199
+ props = column.get("props") or {}
200
+ if column.get("icon"):
201
+ reasons.add("icon_column")
202
+ if _contains_avatar_renderer(column):
203
+ reasons.add("avatar_column")
204
+ if props.get("showOverflowTooltip") or props.get("width") or props.get("minWidth"):
205
+ reasons.add("visual_tuning")
206
+ if create_element.get("is") == "imagePreview":
207
+ reasons.add("image_preview_column")
208
+ if create_element.get("is") == "ColorBackgroundText":
209
+ reasons.add("badge_column")
210
+ if _is_action_column(column):
211
+ reasons.add("action_column")
212
+ refs = extract_template_refs(column)
213
+ if refs:
214
+ reasons.add("script_column")
215
+ if _contains_html_like_template(column):
216
+ reasons.add("badge_column")
217
+ return reasons
218
+
219
+
220
+ def _is_action_column(column: Dict[str, Any]) -> bool:
221
+ create_element = column.get("createElement") or {}
222
+ children = create_element.get("children")
223
+ if not isinstance(children, list) or not children:
224
+ return False
225
+ if create_element.get("is") not in (None, ""):
226
+ return False
227
+ return all(_looks_like_action_node(item) for item in children)
228
+
229
+
230
+ def _looks_like_action_node(value: Any) -> bool:
231
+ if not isinstance(value, dict):
232
+ return False
233
+ node_type = value.get("is")
234
+ if node_type in {"el-button", "router-link", "nuxt-link", "a"}:
235
+ return True
236
+ children = value.get("children")
237
+ if isinstance(children, dict):
238
+ return _looks_like_action_node(children)
239
+ return False
240
+
241
+
242
+ def _is_valid_ri_icon(value: Any) -> bool:
243
+ return isinstance(value, str) and normalize_whitespace(value) == value and value.startswith("ri ri_")
244
+
245
+
246
+ def _extract_action_button_icon_candidates(value: Any) -> list[str]:
247
+ candidates: list[str] = []
248
+ if isinstance(value, dict):
249
+ attribute = value.get("attribute")
250
+ if isinstance(attribute, dict):
251
+ props = attribute.get("props")
252
+ if isinstance(props, dict):
253
+ icon = props.get("icon")
254
+ if isinstance(icon, str) and icon:
255
+ candidates.append(icon)
256
+ class_name = attribute.get("class")
257
+ if value.get("is") == "i" and isinstance(class_name, str) and class_name:
258
+ candidates.append(class_name)
259
+ for inner in value.values():
260
+ candidates.extend(_extract_action_button_icon_candidates(inner))
261
+ elif isinstance(value, list):
262
+ for item in value:
263
+ candidates.extend(_extract_action_button_icon_candidates(item))
264
+ return candidates
265
+
266
+
267
+ def _contains_avatar_renderer(value: Any) -> bool:
268
+ if isinstance(value, dict):
269
+ node_type = value.get("is")
270
+ if node_type == "el-avatar":
271
+ return True
272
+ if node_type == "img":
273
+ attribute = value.get("attribute") or {}
274
+ attrs = attribute.get("attrs") or {}
275
+ alt = attrs.get("alt") or attribute.get("alt") or value.get("alt")
276
+ src = attrs.get("src") or (attribute.get("props") or {}).get("src")
277
+ src_text = json.dumps(src, ensure_ascii=False).lower() if src is not None else ""
278
+ if alt == "avatar" or "avatar" in src_text:
279
+ return True
280
+ return any(_contains_avatar_renderer(inner) for inner in value.values())
281
+ if isinstance(value, list):
282
+ return any(_contains_avatar_renderer(item) for item in value)
283
+ return False
284
+
285
+
286
+ def _looks_like_people_column(title: str, column: Dict[str, Any]) -> bool:
287
+ title_text = str(title or "").strip()
288
+ title_lower = title_text.lower()
289
+ excluded_title_keywords = ("用户id", "用户 id", "user id", "userid", "人员管理", "人数", "人员数量")
290
+ if any(keyword in title_lower for keyword in excluded_title_keywords):
291
+ return False
292
+
293
+ chinese_title_keywords = (
294
+ "负责人",
295
+ "申请人",
296
+ "发起人",
297
+ "创建人",
298
+ "处理人",
299
+ "审批人",
300
+ "经办人",
301
+ "用户",
302
+ "人员",
303
+ "经理",
304
+ )
305
+ english_title_keywords = ("owner", "manager", "assignee", "creator", "applicant", "reviewer")
306
+ if any(keyword in title_text for keyword in chinese_title_keywords) or any(
307
+ keyword in title_lower for keyword in english_title_keywords
308
+ ):
309
+ return True
310
+
311
+ template_text = json.dumps(column, ensure_ascii=False).lower()
312
+ template_keywords = ("__project_owner", "bind_user", "avatar", "owner.name", "user.name")
313
+ return any(keyword in template_text for keyword in template_keywords)
314
+
315
+
316
+ def _contains_html_like_template(value: Any) -> bool:
317
+ if isinstance(value, dict):
318
+ template = value.get("$template")
319
+ if isinstance(template, str):
320
+ lowered = template.lower()
321
+ if "<span" in lowered or "<div" in lowered or "<label" in lowered:
322
+ return True
323
+ return any(_contains_html_like_template(inner) for inner in value.values())
324
+ if isinstance(value, list):
325
+ return any(_contains_html_like_template(item) for item in value)
326
+ return False
327
+
328
+
329
+ def detail_to_work_payload(
330
+ detail: Dict[str, Any],
331
+ *,
332
+ mode: str,
333
+ sample_template_id: Any | None = None,
334
+ ) -> Dict[str, Any]:
335
+ if mode not in ("edit", "create"):
336
+ raise SystemExit(f"unsupported work payload mode: {mode}")
337
+ return {
338
+ "id": detail.get("id") if mode == "edit" else None,
339
+ "mode": mode,
340
+ "sampleTemplateId": sample_template_id,
341
+ "basic": {
342
+ "name": detail.get("name", ""),
343
+ "desc": detail.get("desc", ""),
344
+ "data_set_id": detail.get("data_set_id"),
345
+ "flow_type": detail.get("flow_type", ""),
346
+ "flow_key": detail.get("flow_key", ""),
347
+ "type": detail.get("type"),
348
+ "status": detail.get("status", 1),
349
+ },
350
+ "content": parse_content(detail.get("content")),
351
+ "meta": {
352
+ "templateUuid": detail.get("uuid"),
353
+ "updateTime": detail.get("update_time"),
354
+ "sourceTemplateId": detail.get("id"),
355
+ "sourceSampleTemplateId": sample_template_id,
356
+ "previousDataSetId": detail.get("data_set_id"),
357
+ "riskHints": sorted(
358
+ {
359
+ risk
360
+ for column in parse_content(detail.get("content")).get("config", [])
361
+ if isinstance(column, dict)
362
+ for risk in detect_column_risks(column)
363
+ }
364
+ ),
365
+ },
366
+ }
367
+
368
+
369
+ def build_create_raw_payload(sample_detail: Dict[str, Any], *, sample_template_id: Any) -> Dict[str, Any]:
370
+ return {
371
+ "mode": "create-skeleton-export",
372
+ "sampleTemplateId": sample_template_id,
373
+ "sampleDetail": sample_detail,
374
+ }
375
+
376
+
377
+ def build_submit_payload(work: Dict[str, Any]) -> Dict[str, Any]:
378
+ mode = work.get("mode")
379
+ if mode not in ("edit", "create"):
380
+ raise SystemExit("work payload missing valid mode")
381
+ basic = work.get("basic")
382
+ if not isinstance(basic, dict):
383
+ raise SystemExit("work payload missing basic section")
384
+ content = work.get("content")
385
+ if not isinstance(content, dict):
386
+ raise SystemExit("work payload missing content object")
387
+ normalized_content = parse_content(content)
388
+ required_basic = ("name", "data_set_id", "flow_type", "type")
389
+ missing = [key for key in required_basic if basic.get(key) in (None, "")]
390
+ if missing:
391
+ raise SystemExit("work payload missing required basic fields: " + ", ".join(missing))
392
+ payload = {
393
+ "name": basic.get("name", ""),
394
+ "desc": basic.get("desc", ""),
395
+ "data_set_id": basic.get("data_set_id"),
396
+ "flow_type": basic.get("flow_type", ""),
397
+ "flow_key": basic.get("flow_key", ""),
398
+ "type": basic.get("type"),
399
+ "content": serialize_content(normalized_content),
400
+ }
401
+ if mode == "create":
402
+ payload["status"] = basic.get("status", 1)
403
+ return payload
404
+
405
+
406
+ def data_set_field_map(data_sets: Iterable[Dict[str, Any]]) -> Dict[int, Dict[str, Dict[str, Any]]]:
407
+ result: Dict[int, Dict[str, Dict[str, Any]]] = {}
408
+ for item in data_sets:
409
+ if not isinstance(item, dict):
410
+ continue
411
+ data_set_id = item.get("id")
412
+ if not isinstance(data_set_id, int):
413
+ continue
414
+ fields: Dict[str, Dict[str, Any]] = {}
415
+ for field in item.get("dataSetFields") or []:
416
+ if not isinstance(field, dict):
417
+ continue
418
+ key = field.get("key")
419
+ if isinstance(key, str) and key:
420
+ fields[key] = field
421
+ result[data_set_id] = fields
422
+ return result
423
+
424
+
425
+ def lint_list_template_semantics(
426
+ work_payload: Dict[str, Any],
427
+ *,
428
+ data_sets: Optional[list[Dict[str, Any]]] = None,
429
+ submit_payload: Optional[Dict[str, Any]] = None,
430
+ ) -> Dict[str, Any]:
431
+ payload = submit_payload or build_submit_payload(work_payload)
432
+ report: Dict[str, Any] = {
433
+ "ok": True,
434
+ "errors": [],
435
+ "style_errors": [],
436
+ "warnings": [],
437
+ "highRiskAcceptanceRequired": False,
438
+ "highRiskReasons": [],
439
+ "checks": {},
440
+ }
441
+
442
+ content = parse_content(payload.get("content"))
443
+ config = content.get("config") or []
444
+ report["checks"]["configCount"] = len(config)
445
+
446
+ data_set_id = payload.get("data_set_id")
447
+ data_sets = data_sets or []
448
+ data_set_ids = {item.get("id") for item in data_sets if isinstance(item, dict)}
449
+ fields_by_data_set = data_set_field_map(data_sets)
450
+ current_field_map = fields_by_data_set.get(data_set_id, {})
451
+
452
+ if data_sets and data_set_id not in data_set_ids:
453
+ report["errors"].append(f"data_set_id does not exist in live data set list: {data_set_id}")
454
+
455
+ previous_data_set_id = ((work_payload.get("meta") or {}).get("previousDataSetId"))
456
+ if previous_data_set_id not in (None, data_set_id):
457
+ report["highRiskReasons"].append("data_set_switch")
458
+
459
+ ordinary_icon_columns = 0
460
+ ordinary_column_count = 0
461
+ referenced_keys: set[str] = set()
462
+ column_reports = []
463
+ for idx, column in enumerate(config):
464
+ if not isinstance(column, dict):
465
+ report["errors"].append(f"content.config[{idx}] is not an object")
466
+ continue
467
+ title = column.get("title") or f"column[{idx}]"
468
+ extra_keys = sorted(set(column.keys()) - ALLOWED_COLUMN_KEYS)
469
+ if extra_keys:
470
+ report["errors"].append(f"{title}: unsupported column keys: {', '.join(extra_keys)}")
471
+ forbidden_keys = sorted(set(column.keys()) & FORBIDDEN_FORM_KEYS)
472
+ if forbidden_keys:
473
+ report["errors"].append(f"{title}: forbidden form-template keys present: {', '.join(forbidden_keys)}")
474
+
475
+ create_element = column.get("createElement")
476
+ if create_element is not None and not isinstance(create_element, dict):
477
+ report["errors"].append(f"{title}: createElement must be an object")
478
+ children = (create_element or {}).get("children")
479
+ if isinstance(children, dict) and "$template" in children:
480
+ if children.get("eval") is not True:
481
+ report["errors"].append(f"{title}: template children must set eval=true")
482
+ refs = extract_template_refs(column)
483
+ referenced_keys.update(refs)
484
+
485
+ is_action_column = _is_action_column(column)
486
+ icon = column.get("icon")
487
+ if is_action_column:
488
+ if icon:
489
+ report["style_errors"].append(f"{title}: action columns must not set column-level icon; move icons into each action button")
490
+ if column.get("iconColor") not in (None, ""):
491
+ report["style_errors"].append(f"{title}: action columns must not set column-level iconColor; style icons on each action button instead")
492
+ if not isinstance(children, list) or not children:
493
+ report["style_errors"].append(f"{title}: action columns must provide action buttons")
494
+ else:
495
+ for action_idx, action_item in enumerate(children):
496
+ if not isinstance(action_item, dict):
497
+ report["errors"].append(f"{title}: action child[{action_idx}] must be an object")
498
+ continue
499
+ icon_candidates = _extract_action_button_icon_candidates(action_item)
500
+ if not icon_candidates:
501
+ report["style_errors"].append(
502
+ f"{title}: action child[{action_idx}] must provide a button-level icon before text"
503
+ )
504
+ elif not any(_is_valid_ri_icon(candidate) for candidate in icon_candidates):
505
+ report["style_errors"].append(
506
+ f"{title}: action child[{action_idx}] icons must use full class format 'ri ri_*'"
507
+ )
508
+ if icon:
509
+ if not is_action_column:
510
+ ordinary_icon_columns += 1
511
+ if not _is_valid_ri_icon(icon):
512
+ report["style_errors"].append(f"{title}: icon must use full class format 'ri ri_*'")
513
+ icon_color = column.get("iconColor")
514
+ if icon_color and icon_color not in ALLOWED_ICON_COLORS:
515
+ report["style_errors"].append(f"{title}: iconColor must use approved palette")
516
+ if not is_action_column:
517
+ ordinary_column_count += 1
518
+
519
+ props = column.get("props") or {}
520
+ if not isinstance(props, dict):
521
+ report["errors"].append(f"{title}: props must be an object")
522
+ props = {}
523
+ width = props.get("width")
524
+ min_width = props.get("minWidth")
525
+ if (width and not min_width) or (min_width and not width and str(min_width).endswith("px") and "时间" not in str(title)):
526
+ report["style_errors"].append(f"{title}: fixed width columns must set both props.width and props.minWidth")
527
+ if _is_long_text_title(str(title)) and props.get("showOverflowTooltip") is not True:
528
+ report["style_errors"].append(f"{title}: long text columns must enable showOverflowTooltip")
529
+
530
+ if _looks_like_date_column(str(title)):
531
+ template_text = json.dumps(column, ensure_ascii=False)
532
+ if "slice(0, 10)" not in template_text and "YYYY-MM-DD" not in template_text:
533
+ report["style_errors"].append(f"{title}: date columns should normalize to YYYY-MM-DD")
534
+
535
+ if _contains_html_like_template(column) and (create_element or {}).get("is") != "ColorBackgroundText":
536
+ report["style_errors"].append(f"{title}: HTML-like badge templates must use verified component/structure")
537
+ if _looks_like_people_column(str(title), column) and not _contains_avatar_renderer(column):
538
+ report["style_errors"].append(f"{title}: people columns must render avatar, not name-only text")
539
+
540
+ reasons = detect_column_risks(column)
541
+ column_reports.append({"title": title, "refs": sorted(refs), "risks": sorted(reasons)})
542
+ report["highRiskReasons"].extend(reasons)
543
+
544
+ if ordinary_column_count > 0 and ordinary_icon_columns < 1:
545
+ report["style_errors"].append("ordinary data columns must include at least 1 icon column")
546
+ if ordinary_icon_columns > 3:
547
+ report["style_errors"].append("ordinary data columns must not exceed 3 icon columns")
548
+
549
+ missing_refs = sorted(key for key in referenced_keys if current_field_map and key not in current_field_map and not _allow_builtin_ctx_key(key))
550
+ if missing_refs:
551
+ report["errors"].append("template references fields not present in current data set: " + ", ".join(missing_refs))
552
+ non_dataset_runtime_refs = sorted(key for key in missing_refs if key in {"metaForm", "current_step"})
553
+ if non_dataset_runtime_refs:
554
+ report["warnings"].append(
555
+ "detected refs that often come from project/sub or other non-ES runtime payloads, not the live data_set field list: "
556
+ + ", ".join(non_dataset_runtime_refs)
557
+ )
558
+
559
+ hard_rule_report = scan_named_script_surfaces(
560
+ [
561
+ {"path": "content.config", "value": config},
562
+ {"path": "content.customQuery", "value": content.get("customQuery")},
563
+ {"path": "content.beforeSearch", "value": content.get("beforeSearch")},
564
+ {"path": "content.tabFilters", "value": content.get("tabFilters")},
565
+ ]
566
+ )
567
+ report["checks"]["scriptHardRules"] = hard_rule_report["findings"]
568
+ report["errors"].extend(hard_rule_report["errors"])
569
+
570
+ report["checks"]["columns"] = column_reports
571
+ report["checks"]["referencedFieldKeys"] = sorted(referenced_keys)
572
+ report["highRiskReasons"] = sorted(set(reason for reason in report["highRiskReasons"] if reason in HIGH_RISK_REASONS))
573
+ report["highRiskAcceptanceRequired"] = bool(report["highRiskReasons"])
574
+ report["ok"] = not report["errors"] and not report["style_errors"]
575
+ return report
576
+
577
+
578
+ def _allow_builtin_ctx_key(key: str) -> bool:
579
+ return key.startswith("__") or key in {"name", "status", "id"}
580
+
581
+
582
+ def _is_long_text_title(title: str) -> bool:
583
+ keywords = ("名称", "原因", "说明", "备注", "描述", "地址")
584
+ return any(keyword in title for keyword in keywords)
585
+
586
+
587
+ def _looks_like_date_column(title: str) -> bool:
588
+ keywords = ("时间", "日期", "开始", "结束", "生效")
589
+ return any(keyword in title for keyword in keywords)
590
+
591
+
592
+ def summarize_verification(submit_payload: Dict[str, Any], readback_detail: Dict[str, Any]) -> Dict[str, Any]:
593
+ checks: Dict[str, Dict[str, Any]] = {}
594
+ ok = True
595
+ for key in ("name", "desc", "data_set_id", "flow_type", "flow_key", "type"):
596
+ expected = submit_payload.get(key)
597
+ actual = readback_detail.get(key)
598
+ match = expected == actual
599
+ checks[key] = {"match": match, "expected": expected, "actual": actual}
600
+ ok = ok and match
601
+
602
+ expected_content = parse_content(submit_payload.get("content"))
603
+ actual_content = parse_content(readback_detail.get("content"))
604
+ content_match = expected_content == actual_content
605
+ checks["content"] = {
606
+ "match": content_match,
607
+ "expectedSummary": {
608
+ "level": expected_content.get("level"),
609
+ "configCount": len(expected_content.get("config") or []),
610
+ },
611
+ "actualSummary": {
612
+ "level": actual_content.get("level"),
613
+ "configCount": len(actual_content.get("config") or []),
614
+ },
615
+ }
616
+ ok = ok and content_match
617
+ return {
618
+ "ok": ok,
619
+ "checks": checks,
620
+ "submittedColumnTitles": [
621
+ item.get("title")
622
+ for item in expected_content.get("config") or []
623
+ if isinstance(item, dict)
624
+ ],
625
+ "readbackColumnTitles": [
626
+ item.get("title")
627
+ for item in actual_content.get("config") or []
628
+ if isinstance(item, dict)
629
+ ],
630
+ }
631
+
632
+
633
+ def ensure_meta_shape(meta: Dict[str, Any], stem: str) -> Dict[str, Any]:
634
+ payload = dict(meta)
635
+ payload.setdefault("stem", stem)
636
+ payload.setdefault("status", "exported")
637
+ payload.setdefault("mode", None)
638
+ payload.setdefault("templateId", None)
639
+ payload.setdefault("sampleTemplateId", None)
640
+ payload.setdefault("workspace", None)
641
+ payload.setdefault("language", DEFAULT_LANGUAGE)
642
+ payload.setdefault("requestUrl", None)
643
+ payload.setdefault("rawSha256", None)
644
+ payload.setdefault("workSha256", None)
645
+ payload.setdefault("submitSha256", None)
646
+ payload.setdefault("exportedAt", None)
647
+ payload.setdefault("submitBuiltAt", None)
648
+ payload.setdefault("workConfirmedAt", None)
649
+ payload.setdefault("workConfirmedBy", None)
650
+ payload.setdefault("submitConfirmedAt", None)
651
+ payload.setdefault("submitConfirmedBy", None)
652
+ payload.setdefault("lintPassed", False)
653
+ payload.setdefault("lintSha256", None)
654
+ payload.setdefault("lintedAt", None)
655
+ payload.setdefault("highRiskAcceptanceRequired", False)
656
+ payload.setdefault("highRiskReasons", [])
657
+ payload.setdefault("editorPageAccepted", False)
658
+ payload.setdefault("listPageAccepted", False)
659
+ return payload
660
+
661
+
662
+ def write_export_meta(
663
+ path: Path,
664
+ *,
665
+ stem: str,
666
+ mode: str,
667
+ template_id: Any,
668
+ template_uuid: Any,
669
+ sample_template_id: Any,
670
+ workspace: str,
671
+ language: str,
672
+ request_url: str,
673
+ raw_path: Path,
674
+ work_path: Path,
675
+ ) -> Dict[str, Any]:
676
+ payload = ensure_meta_shape(load_meta(path), stem)
677
+ payload.update(
678
+ {
679
+ "mode": mode,
680
+ "templateId": template_id,
681
+ "templateUuid": template_uuid,
682
+ "sampleTemplateId": sample_template_id,
683
+ "workspace": workspace,
684
+ "language": language,
685
+ "requestUrl": request_url,
686
+ "rawSha256": file_sha256(raw_path),
687
+ "workSha256": file_sha256(work_path),
688
+ "submitSha256": None,
689
+ "exportedAt": utc_now_iso(),
690
+ "submitBuiltAt": None,
691
+ "workConfirmedAt": None,
692
+ "workConfirmedBy": None,
693
+ "submitConfirmedAt": None,
694
+ "submitConfirmedBy": None,
695
+ "lintPassed": False,
696
+ "lintSha256": None,
697
+ "lintedAt": None,
698
+ "highRiskAcceptanceRequired": False,
699
+ "highRiskReasons": [],
700
+ "editorPageAccepted": False,
701
+ "listPageAccepted": False,
702
+ "status": "exported",
703
+ }
704
+ )
705
+ dump_json(path, payload)
706
+ return payload
707
+
708
+
709
+ def update_confirmation_state(
710
+ meta_path: Path,
711
+ *,
712
+ stem: str,
713
+ actor: str,
714
+ stage: str,
715
+ work_path: Path,
716
+ submit_path: Optional[Path] = None,
717
+ ) -> Dict[str, Any]:
718
+ payload = ensure_meta_shape(load_meta(meta_path), stem)
719
+ payload["workSha256"] = file_sha256(work_path)
720
+ now = utc_now_iso()
721
+ if stage == "work":
722
+ payload["workConfirmedAt"] = now
723
+ payload["workConfirmedBy"] = actor
724
+ payload["submitConfirmedAt"] = None
725
+ payload["submitConfirmedBy"] = None
726
+ payload["submitSha256"] = None
727
+ payload["submitBuiltAt"] = None
728
+ payload["lintPassed"] = False
729
+ payload["lintSha256"] = None
730
+ payload["lintedAt"] = None
731
+ payload["status"] = "work_confirmed"
732
+ elif stage == "submit":
733
+ if submit_path is None or not submit_path.exists():
734
+ raise SystemExit("submit confirmation requires an existing submit file")
735
+ if payload.get("status") != "submit_built":
736
+ raise SystemExit("submit confirmation requires a fresh submit build")
737
+ if payload.get("workSha256") != file_sha256(work_path):
738
+ raise SystemExit("work file changed after confirmation; reconfirm work before submit")
739
+ if payload.get("lintPassed") is not True:
740
+ raise SystemExit("submit confirmation requires a successful lint run")
741
+ if payload.get("lintSha256") != file_sha256(submit_path):
742
+ raise SystemExit("submit confirmation requires lint to match current submit payload")
743
+ payload["submitSha256"] = file_sha256(submit_path)
744
+ payload["submitConfirmedAt"] = now
745
+ payload["submitConfirmedBy"] = actor
746
+ payload["status"] = "submit_confirmed"
747
+ else:
748
+ raise SystemExit(f"unsupported confirmation stage: {stage}")
749
+ dump_json(meta_path, payload)
750
+ return payload
751
+
752
+
753
+ def update_build_meta(meta_path: Path, *, stem: str, work_path: Path, submit_path: Path) -> Dict[str, Any]:
754
+ payload = ensure_meta_shape(load_meta(meta_path), stem)
755
+ current_work_sha = file_sha256(work_path)
756
+ if payload.get("status") != "work_confirmed":
757
+ raise SystemExit("build blocked: confirm work file before building submit payload")
758
+ if payload.get("workSha256") != current_work_sha:
759
+ raise SystemExit("build blocked: work file changed after confirmation; reconfirm work first")
760
+ payload["workSha256"] = current_work_sha
761
+ payload["submitSha256"] = file_sha256(submit_path)
762
+ payload["submitBuiltAt"] = utc_now_iso()
763
+ payload["submitConfirmedAt"] = None
764
+ payload["submitConfirmedBy"] = None
765
+ payload["lintPassed"] = False
766
+ payload["lintSha256"] = None
767
+ payload["lintedAt"] = None
768
+ payload["status"] = "submit_built"
769
+ dump_json(meta_path, payload)
770
+ return payload
771
+
772
+
773
+ def update_lint_meta(
774
+ meta_path: Path,
775
+ *,
776
+ stem: str,
777
+ submit_path: Path,
778
+ report: Dict[str, Any],
779
+ ) -> Dict[str, Any]:
780
+ payload = ensure_meta_shape(load_meta(meta_path), stem)
781
+ if payload.get("status") != "submit_built":
782
+ raise SystemExit("lint blocked: build submit payload before lint")
783
+ payload["lintPassed"] = bool(report.get("ok"))
784
+ payload["lintSha256"] = file_sha256(submit_path)
785
+ payload["lintedAt"] = utc_now_iso()
786
+ payload["highRiskAcceptanceRequired"] = bool(report.get("highRiskAcceptanceRequired"))
787
+ payload["highRiskReasons"] = sorted(report.get("highRiskReasons") or [])
788
+ dump_json(meta_path, payload)
789
+ return payload
790
+
791
+
792
+ def ensure_submission_allowed(meta_path: Path, work_path: Path, submit_path: Path) -> Dict[str, Any]:
793
+ if not meta_path.exists():
794
+ raise SystemExit("missing meta confirmation file")
795
+ raw_meta = load_meta(meta_path)
796
+ meta = ensure_meta_shape(raw_meta, raw_meta.get("stem", "unknown"))
797
+ required = (
798
+ "mode",
799
+ "workspace",
800
+ "workSha256",
801
+ "submitSha256",
802
+ "workConfirmedAt",
803
+ "submitConfirmedAt",
804
+ "status",
805
+ )
806
+ missing = [key for key in required if not meta.get(key)]
807
+ if missing:
808
+ raise SystemExit(f"meta confirmation incomplete: missing {', '.join(missing)}")
809
+ if meta.get("status") != "submit_confirmed":
810
+ raise SystemExit("submission blocked: current status is not submit_confirmed")
811
+ if meta.get("workSha256") != file_sha256(work_path):
812
+ raise SystemExit("submission blocked: work file changed after confirmation")
813
+ if meta.get("submitSha256") != file_sha256(submit_path):
814
+ raise SystemExit("submission blocked: submit file changed after confirmation")
815
+ if meta.get("lintPassed") is not True:
816
+ raise SystemExit("submission blocked: lint has not passed")
817
+ if meta.get("lintSha256") != file_sha256(submit_path):
818
+ raise SystemExit("submission blocked: lint result is stale for current submit payload")
819
+ submit_built_at = meta.get("submitBuiltAt")
820
+ work_confirmed_at = meta.get("workConfirmedAt")
821
+ if submit_built_at and work_confirmed_at and submit_built_at < work_confirmed_at:
822
+ raise SystemExit("submission blocked: submit payload predates work confirmation")
823
+ return meta
824
+
825
+
826
+ def build_acceptance_payload(
827
+ *,
828
+ readback_ok: bool,
829
+ editor_page_accepted: bool,
830
+ list_page_accepted: bool,
831
+ high_risk_required: bool,
832
+ high_risk_reasons: list[str],
833
+ ) -> Dict[str, Any]:
834
+ ok = bool(readback_ok and editor_page_accepted and (list_page_accepted if high_risk_required else True))
835
+ return {
836
+ "readbackAccepted": bool(readback_ok),
837
+ "editorPageAccepted": bool(editor_page_accepted),
838
+ "listPageAccepted": bool(list_page_accepted),
839
+ "highRiskAcceptanceRequired": bool(high_risk_required),
840
+ "highRiskReasons": sorted(set(high_risk_reasons)),
841
+ "ok": ok,
842
+ }
843
+
844
+
845
+ def update_acceptance_meta(
846
+ meta_path: Path,
847
+ *,
848
+ stem: str,
849
+ editor_page_accepted: Optional[bool] = None,
850
+ list_page_accepted: Optional[bool] = None,
851
+ ) -> Dict[str, Any]:
852
+ payload = ensure_meta_shape(load_meta(meta_path), stem)
853
+ if editor_page_accepted is not None:
854
+ payload["editorPageAccepted"] = bool(editor_page_accepted)
855
+ if list_page_accepted is not None:
856
+ payload["listPageAccepted"] = bool(list_page_accepted)
857
+ dump_json(meta_path, payload)
858
+ return payload
859
+
860
+
861
+ def extract_template_id(payload: Any) -> int | None:
862
+ if payload is None or isinstance(payload, bool):
863
+ return None
864
+ if isinstance(payload, int):
865
+ return payload
866
+ if isinstance(payload, str) and payload.isdigit():
867
+ return int(payload)
868
+ if isinstance(payload, dict):
869
+ for key in ("id", "template_id"):
870
+ value = payload.get(key)
871
+ if isinstance(value, int):
872
+ return value
873
+ if isinstance(value, str) and value.isdigit():
874
+ return int(value)
875
+ if "data" in payload:
876
+ return extract_template_id(payload.get("data"))
877
+ return None
878
+
879
+
880
+ @dataclass
881
+ class ApiClient:
882
+ base_url: str
883
+ workspace: str
884
+ language: str
885
+ cookie_header: str
886
+ timeout: float
887
+ insecure: bool = False
888
+
889
+ def _build_url(self, path: str) -> str:
890
+ suffix = f"$workspace={urllib.parse.quote(self.workspace)}&$language={urllib.parse.quote(self.language)}"
891
+ joiner = "&" if "?" in path else "?"
892
+ return self.base_url.rstrip("/") + path + joiner + suffix
893
+
894
+ def request(self, method: str, path: str, body: Optional[dict] = None) -> dict:
895
+ headers = {
896
+ "content-type": "application/json",
897
+ "cookie": self.cookie_header,
898
+ "accept": "application/json, text/plain, */*",
899
+ }
900
+ data = None if body is None else json.dumps(body, ensure_ascii=False).encode("utf-8")
901
+ req = urllib.request.Request(self._build_url(path), data=data, headers=headers, method=method)
902
+ context = ssl._create_unverified_context() if self.insecure else None
903
+ try:
904
+ with urllib.request.urlopen(req, timeout=self.timeout, context=context) as resp:
905
+ raw = resp.read().decode("utf-8", "replace")
906
+ except urllib.error.HTTPError as err:
907
+ raw = err.read().decode("utf-8", "replace")
908
+ raise SystemExit(f"HTTP {err.code} {path}: {raw}") from err
909
+ except urllib.error.URLError as err:
910
+ raise SystemExit(f"Request failed {path}: {err}") from err
911
+ payload = json.loads(raw)
912
+ if payload.get("code") != 0:
913
+ raise SystemExit(f"API error {path}: {payload}")
914
+ return payload
915
+
916
+ def get_flow_page_template(self, template_id: Any) -> dict:
917
+ return self.request("GET", f"/api/flow_page_template/{template_id}")
918
+
919
+ def create_flow_page_template(self, body: Dict[str, Any]) -> dict:
920
+ return self.request("POST", "/api/flow_page_template", body)
921
+
922
+ def update_flow_page_template(self, template_id: Any, body: Dict[str, Any]) -> dict:
923
+ return self.request("PUT", f"/api/flow_page_template/{template_id}", body)
924
+
925
+ def get_data_set_list(self, *, flow_type: str, flow_key: str = "") -> list[Dict[str, Any]]:
926
+ payload = self.request("GET", f"/bpmax/data-set?flow_type={urllib.parse.quote(flow_type)}&flow_key={urllib.parse.quote(flow_key)}")
927
+ data = payload.get("data")
928
+ if not isinstance(data, list):
929
+ raise SystemExit("unexpected /bpmax/data-set response: data is not a list")
930
+ return data
931
+
932
+
933
+ def resolve_cookie_header(value: Optional[str]) -> str:
934
+ cookie = value or os.environ.get("BPMAX_COOKIE_HEADER", "")
935
+ if not cookie:
936
+ raise SystemExit("missing cookie header: pass --cookie-header or set BPMAX_COOKIE_HEADER")
937
+ return cookie
938
+
939
+
940
+ def resolve_workspace(value: Optional[str]) -> str:
941
+ workspace = value or os.environ.get("BPMAX_WORKSPACE", "")
942
+ if not workspace:
943
+ raise SystemExit("missing workspace: pass --workspace or set BPMAX_WORKSPACE")
944
+ return workspace
945
+
946
+
947
+ def build_client(args: Any) -> ApiClient:
948
+ return ApiClient(
949
+ base_url=resolve_base_url(getattr(args, "base_url", None)),
950
+ workspace=resolve_workspace(getattr(args, "workspace", None)),
951
+ language=getattr(args, "language", DEFAULT_LANGUAGE),
952
+ cookie_header=resolve_cookie_header(getattr(args, "cookie_header", None)),
953
+ timeout=float(getattr(args, "timeout", 30)),
954
+ insecure=bool(getattr(args, "insecure", False)),
955
+ )