bpmax-cli 0.1.44-beta.8 → 0.1.44

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 (258) hide show
  1. package/README.md +5 -3
  2. package/dist/bin.js +466 -4578
  3. package/dist/bin.js.map +1 -1
  4. package/package.json +1 -1
  5. package/scripts/install-skills.mjs +0 -98
  6. package/skills/bpmax-auth/SKILL.md +17 -6
  7. package/skills/bpmax-cli/SKILL.md +0 -2
  8. package/skills/bpmax-project/SKILL.md +2 -1
  9. package/skills/bpmax-shared/SKILL.md +1 -1
  10. package/skills/bpmax-api-platform-editor/SKILL.md +0 -321
  11. package/skills/bpmax-api-platform-editor/agents/openai.yaml +0 -4
  12. package/skills/bpmax-api-platform-editor/references/api-doc-debug-workflow.md +0 -34
  13. package/skills/bpmax-api-platform-editor/references/api-proxy-shape.md +0 -41
  14. package/skills/bpmax-api-platform-editor/references/instance-config-shape.md +0 -41
  15. package/skills/bpmax-api-platform-editor/references/platform-api-map.md +0 -52
  16. package/skills/bpmax-api-platform-editor/references/runtime-workflow.md +0 -32
  17. package/skills/bpmax-api-platform-editor/scripts/api_platform_editor_common.py +0 -1276
  18. package/skills/bpmax-api-platform-editor/scripts/build_submit_payload.py +0 -64
  19. package/skills/bpmax-api-platform-editor/scripts/capture_write_contract.py +0 -40
  20. package/skills/bpmax-api-platform-editor/scripts/export_layer_bundle.py +0 -212
  21. package/skills/bpmax-api-platform-editor/scripts/record_doc_debug_acceptance.py +0 -62
  22. package/skills/bpmax-api-platform-editor/scripts/submit_and_verify_layer.py +0 -75
  23. package/skills/bpmax-api-platform-editor/tests/test_api_platform_editor.py +0 -287
  24. package/skills/bpmax-builder-shared/SKILL.md +0 -44
  25. package/skills/bpmax-builder-shared/base_url.py +0 -81
  26. package/skills/bpmax-builder-shared/runtime-script-site-matrix.json +0 -71
  27. package/skills/bpmax-builder-shared/runtime-script-site-matrix.md +0 -34
  28. package/skills/bpmax-builder-shared/runtime-script-template-catalog.md +0 -123
  29. package/skills/bpmax-builder-shared/runtime_script_rules.py +0 -272
  30. package/skills/bpmax-builder-shared/skill_audit.py +0 -374
  31. package/skills/bpmax-builder-shared/template_script_hard_rules.py +0 -280
  32. package/skills/bpmax-builder-shared/tests/test_base_url.py +0 -80
  33. package/skills/bpmax-builder-shared/tests/test_runtime_script_rules.py +0 -115
  34. package/skills/bpmax-builder-shared/tests/test_skill_audit.py +0 -231
  35. package/skills/bpmax-builder-shared/tests/test_template_script_hard_rules.py +0 -281
  36. package/skills/bpmax-config-latest/SKILL.md +0 -71
  37. package/skills/bpmax-console-template-editor/SKILL.md +0 -536
  38. package/skills/bpmax-console-template-editor/agents/openai.yaml +0 -4
  39. package/skills/bpmax-console-template-editor/references/filter-integration.md +0 -60
  40. package/skills/bpmax-console-template-editor/references/lessons-from-resume-dashboard.md +0 -114
  41. package/skills/bpmax-console-template-editor/references/local-temp-workflow.md +0 -69
  42. package/skills/bpmax-console-template-editor/references/module-catalog.md +0 -100
  43. package/skills/bpmax-console-template-editor/references/runtime-page-shape.md +0 -91
  44. package/skills/bpmax-console-template-editor/references/template-shape.md +0 -149
  45. package/skills/bpmax-console-template-editor/scripts/build_submit_payload.py +0 -38
  46. package/skills/bpmax-console-template-editor/scripts/confirm_console_template.py +0 -33
  47. package/skills/bpmax-console-template-editor/scripts/console_template_editor_common.py +0 -964
  48. package/skills/bpmax-console-template-editor/scripts/export_console_template.py +0 -99
  49. package/skills/bpmax-console-template-editor/scripts/lint_console_template.py +0 -46
  50. package/skills/bpmax-console-template-editor/scripts/submit_console_template.py +0 -99
  51. package/skills/bpmax-console-template-editor/tests/test_console_template_editor.py +0 -383
  52. package/skills/bpmax-dataset-field-template-editor/SKILL.md +0 -600
  53. package/skills/bpmax-dataset-field-template-editor/references/create-request-gotchas.md +0 -25
  54. package/skills/bpmax-dataset-field-template-editor/references/field-classify-mapping.md +0 -35
  55. package/skills/bpmax-dataset-field-template-editor/references/nested-field-patterns.md +0 -24
  56. package/skills/bpmax-dataset-field-template-editor/references/runtime-verified-field-page-shape.md +0 -61
  57. package/skills/bpmax-dataset-field-template-editor/references/virtual-field-patterns.md +0 -27
  58. package/skills/bpmax-dataset-field-template-editor/references/work-file-to-submit-mapping.md +0 -127
  59. package/skills/bpmax-dataset-field-template-editor/scripts/build_submit_payload.py +0 -67
  60. package/skills/bpmax-dataset-field-template-editor/scripts/confirm_dataset_field.py +0 -37
  61. package/skills/bpmax-dataset-field-template-editor/scripts/dataset_field_editor_common.py +0 -784
  62. package/skills/bpmax-dataset-field-template-editor/scripts/export_dataset_field.py +0 -62
  63. package/skills/bpmax-dataset-field-template-editor/scripts/init_create_dataset_field.py +0 -104
  64. package/skills/bpmax-dataset-field-template-editor/scripts/inspect_dataset_field_runtime.py +0 -83
  65. package/skills/bpmax-dataset-field-template-editor/scripts/lint_dataset_field_semantics.py +0 -35
  66. package/skills/bpmax-dataset-field-template-editor/scripts/submit_dataset_field.py +0 -95
  67. package/skills/bpmax-dataset-field-template-editor/tests/test_dataset_field_editor.py +0 -709
  68. package/skills/bpmax-dataset-field-template-editor/tests/test_init_create_dataset_field.py +0 -59
  69. package/skills/bpmax-dataset-template-editor/SKILL.md +0 -779
  70. package/skills/bpmax-dataset-template-editor/references/custom-key-usage-patterns.md +0 -18
  71. package/skills/bpmax-dataset-template-editor/references/dataset-script-runtime-matrix.md +0 -73
  72. package/skills/bpmax-dataset-template-editor/references/pre-process-script-authoring-guide.md +0 -186
  73. package/skills/bpmax-dataset-template-editor/references/pre-process-script-example-catalog.md +0 -106
  74. package/skills/bpmax-dataset-template-editor/references/runtime-gotchas.md +0 -28
  75. package/skills/bpmax-dataset-template-editor/references/runtime-verified-dataset-page-shape.md +0 -47
  76. package/skills/bpmax-dataset-template-editor/references/ui-to-backend-field-map.md +0 -23
  77. package/skills/bpmax-dataset-template-editor/references/work-file-to-submit-mapping.md +0 -97
  78. package/skills/bpmax-dataset-template-editor/scripts/basic_table_audit.py +0 -65
  79. package/skills/bpmax-dataset-template-editor/scripts/build_submit_payload.py +0 -38
  80. package/skills/bpmax-dataset-template-editor/scripts/dataset_editor_common.py +0 -650
  81. package/skills/bpmax-dataset-template-editor/scripts/export_dataset.py +0 -155
  82. package/skills/bpmax-dataset-template-editor/scripts/lint_dataset_template.py +0 -42
  83. package/skills/bpmax-dataset-template-editor/scripts/resolve_dataset.py +0 -43
  84. package/skills/bpmax-dataset-template-editor/scripts/scan_custom_key_references.py +0 -27
  85. package/skills/bpmax-dataset-template-editor/scripts/submit_dataset.py +0 -115
  86. package/skills/bpmax-dataset-template-editor/scripts/verify_dataset_list.py +0 -52
  87. package/skills/bpmax-dataset-template-editor/scripts/verify_publish_health.py +0 -39
  88. package/skills/bpmax-dataset-template-editor/tests/test_dataset_editor.py +0 -373
  89. package/skills/bpmax-e2e-flow-config-orchestrator/SKILL.md +0 -177
  90. package/skills/bpmax-e2e-flow-config-orchestrator/agents/openai.yaml +0 -4
  91. package/skills/bpmax-e2e-flow-config-orchestrator/references/orchestration-matrix.md +0 -60
  92. package/skills/bpmax-e2e-flow-test-operator/SKILL.md +0 -394
  93. package/skills/bpmax-e2e-flow-test-operator/agents/openai.yaml +0 -5
  94. package/skills/bpmax-e2e-flow-test-operator/profiles/negative_sale.json +0 -97
  95. package/skills/bpmax-e2e-flow-test-operator/profiles/negative_sale_final_v2.json +0 -105
  96. package/skills/bpmax-e2e-flow-test-operator/profiles/negative_sale_main.json +0 -36
  97. package/skills/bpmax-e2e-flow-test-operator/profiles/negative_sale_region.json +0 -40
  98. package/skills/bpmax-e2e-flow-test-operator/references/browser-only-checkpoints.md +0 -41
  99. package/skills/bpmax-e2e-flow-test-operator/references/failure-update-loop.md +0 -17
  100. package/skills/bpmax-e2e-flow-test-operator/references/filter-field-discovery.md +0 -40
  101. package/skills/bpmax-e2e-flow-test-operator/references/minimal-test-loop.md +0 -24
  102. package/skills/bpmax-e2e-flow-test-operator/references/negative-sale-api-matrix.md +0 -75
  103. package/skills/bpmax-e2e-flow-test-operator/references/profile-schema.md +0 -107
  104. package/skills/bpmax-e2e-flow-test-operator/references/skill-experience-coverage-matrix.md +0 -29
  105. package/skills/bpmax-e2e-flow-test-operator/references/stale-runtime-and-clean-sample-rules.md +0 -54
  106. package/skills/bpmax-e2e-flow-test-operator/references/state-schema.md +0 -83
  107. package/skills/bpmax-e2e-flow-test-operator/scripts/bpmax_session.py +0 -287
  108. package/skills/bpmax-e2e-flow-test-operator/scripts/dealer_sample_on_shelf_plan.json +0 -59
  109. package/skills/bpmax-e2e-flow-test-operator/scripts/dealer_sample_on_shelf_runner.py +0 -687
  110. package/skills/bpmax-e2e-flow-test-operator/scripts/e2e_doc.py +0 -121
  111. package/skills/bpmax-e2e-flow-test-operator/scripts/e2e_state.py +0 -288
  112. package/skills/bpmax-e2e-flow-test-operator/scripts/flow_api_matrix.py +0 -161
  113. package/skills/bpmax-e2e-flow-test-operator/scripts/flow_filter_fields.py +0 -138
  114. package/skills/bpmax-e2e-flow-test-operator/scripts/flow_form_runtime.py +0 -396
  115. package/skills/bpmax-e2e-flow-test-operator/scripts/flow_runner.py +0 -341
  116. package/skills/bpmax-e2e-flow-test-operator/scripts/flow_test_profile.py +0 -185
  117. package/skills/bpmax-e2e-flow-test-operator/tests/test_negative_sale_api_tools.py +0 -138
  118. package/skills/bpmax-feishu-chat-flow-plugin-editor/SKILL.md +0 -69
  119. package/skills/bpmax-feishu-chat-flow-plugin-editor/agents/openai.yaml +0 -4
  120. package/skills/bpmax-feishu-chat-flow-plugin-editor/references/config-checklist.md +0 -42
  121. package/skills/bpmax-feishu-chat-flow-plugin-editor/references/config-recipes.md +0 -38
  122. package/skills/bpmax-feishu-chat-flow-plugin-editor/references/config-shape.md +0 -86
  123. package/skills/bpmax-feishu-chat-flow-plugin-editor/references/gate-lint.md +0 -68
  124. package/skills/bpmax-feishu-chat-flow-plugin-editor/references/hoocoo-patterns.md +0 -39
  125. package/skills/bpmax-feishu-chat-flow-plugin-editor/references/runtime-behavior.md +0 -41
  126. package/skills/bpmax-feishu-chat-flow-plugin-editor/references/script-authoring.md +0 -110
  127. package/skills/bpmax-feishu-chat-flow-plugin-editor/scripts/lint_feishu_chat_plugin.py +0 -278
  128. package/skills/bpmax-feishu-chat-flow-plugin-editor/tests/test_lint_feishu_chat_plugin.py +0 -203
  129. package/skills/bpmax-filter-template-editor/SKILL.md +0 -564
  130. package/skills/bpmax-filter-template-editor/references/experience-coverage-matrix.md +0 -38
  131. package/skills/bpmax-filter-template-editor/references/filter-and-flow-binding.md +0 -57
  132. package/skills/bpmax-filter-template-editor/references/filter-content-schema.md +0 -141
  133. package/skills/bpmax-filter-template-editor/references/filter-request-shape.md +0 -287
  134. package/skills/bpmax-filter-template-editor/references/filter-runtime-patterns.md +0 -115
  135. package/skills/bpmax-filter-template-editor/references/runtime-verified-filter-page-shape.md +0 -94
  136. package/skills/bpmax-filter-template-editor/scripts/build_submit_payload.py +0 -25
  137. package/skills/bpmax-filter-template-editor/scripts/confirm_filter_template.py +0 -22
  138. package/skills/bpmax-filter-template-editor/scripts/export_filter_template.py +0 -57
  139. package/skills/bpmax-filter-template-editor/scripts/filter_template_editor_common.py +0 -348
  140. package/skills/bpmax-filter-template-editor/scripts/init_create_filter_template.py +0 -8
  141. package/skills/bpmax-filter-template-editor/scripts/lint_filter_template_semantics.py +0 -26
  142. package/skills/bpmax-filter-template-editor/scripts/submit_filter_template.py +0 -62
  143. package/skills/bpmax-filter-template-editor/tests/test_filter_template_editor.py +0 -231
  144. package/skills/bpmax-flow-template-editor/SKILL.md +0 -1058
  145. package/skills/bpmax-flow-template-editor/agents/openai.yaml +0 -4
  146. package/skills/bpmax-flow-template-editor/references/before-next-step-script-runtime-gotchas.md +0 -62
  147. package/skills/bpmax-flow-template-editor/references/config-surfaces-and-placeholders.md +0 -270
  148. package/skills/bpmax-flow-template-editor/references/diff-strategy.md +0 -67
  149. package/skills/bpmax-flow-template-editor/references/editor-runtime-vs-draft.md +0 -25
  150. package/skills/bpmax-flow-template-editor/references/flow-template-api-workflow.md +0 -174
  151. package/skills/bpmax-flow-template-editor/references/intent-model.md +0 -117
  152. package/skills/bpmax-flow-template-editor/references/lessons-from-price-plan-flow.md +0 -147
  153. package/skills/bpmax-flow-template-editor/references/local-temp-workflow.md +0 -97
  154. package/skills/bpmax-flow-template-editor/references/matrix-flow-form-nav-collaboration.md +0 -165
  155. package/skills/bpmax-flow-template-editor/references/payload-checklist.md +0 -133
  156. package/skills/bpmax-flow-template-editor/references/project-create-runtime-gotchas.md +0 -54
  157. package/skills/bpmax-flow-template-editor/references/requirement-to-node-mapping.md +0 -149
  158. package/skills/bpmax-flow-template-editor/references/runtime-verified-flow-detail-shape.md +0 -41
  159. package/skills/bpmax-flow-template-editor/references/runtime-verified-meta-fields.md +0 -155
  160. package/skills/bpmax-flow-template-editor/references/runtime-verified-node-fields.md +0 -179
  161. package/skills/bpmax-flow-template-editor/references/save-draft-request-shape.md +0 -91
  162. package/skills/bpmax-flow-template-editor/references/script-review-hard-rules.md +0 -93
  163. package/skills/bpmax-flow-template-editor/references/work-file-to-submit-mapping.md +0 -57
  164. package/skills/bpmax-flow-template-editor/scripts/build_submit_payload.py +0 -69
  165. package/skills/bpmax-flow-template-editor/scripts/confirm_flow_template.py +0 -52
  166. package/skills/bpmax-flow-template-editor/scripts/export_flow_template.py +0 -114
  167. package/skills/bpmax-flow-template-editor/scripts/flow_template_editor_common.py +0 -1084
  168. package/skills/bpmax-flow-template-editor/scripts/submit_flow_template.py +0 -159
  169. package/skills/bpmax-flow-template-editor/tests/test_flow_template_editor.py +0 -636
  170. package/skills/bpmax-form-template-editor/SKILL.md +0 -1099
  171. package/skills/bpmax-form-template-editor/agents/openai.yaml +0 -4
  172. package/skills/bpmax-form-template-editor/references/form-template-api-workflow.md +0 -203
  173. package/skills/bpmax-form-template-editor/references/local-temp-workflow.md +0 -125
  174. package/skills/bpmax-form-template-editor/references/payload-checklist.md +0 -77
  175. package/skills/bpmax-form-template-editor/references/sub-form-patterns.md +0 -49
  176. package/skills/bpmax-form-template-editor/scripts/build_submit_payload.py +0 -37
  177. package/skills/bpmax-form-template-editor/scripts/check_form_template_consistency.py +0 -145
  178. package/skills/bpmax-form-template-editor/scripts/confirm_form_template.py +0 -67
  179. package/skills/bpmax-form-template-editor/scripts/export_form_template.py +0 -91
  180. package/skills/bpmax-form-template-editor/scripts/form_template_editor_common.py +0 -1762
  181. package/skills/bpmax-form-template-editor/scripts/lint_form_template_semantics.py +0 -30
  182. package/skills/bpmax-form-template-editor/scripts/record_runtime_acceptance.py +0 -67
  183. package/skills/bpmax-form-template-editor/scripts/submit_form_template.py +0 -163
  184. package/skills/bpmax-form-template-editor/tests/test_form_template_editor.py +0 -1292
  185. package/skills/bpmax-list-template-editor/SKILL.md +0 -468
  186. package/skills/bpmax-list-template-editor/agents/openai.yaml +0 -4
  187. package/skills/bpmax-list-template-editor/references/browser-page-contract.md +0 -81
  188. package/skills/bpmax-list-template-editor/references/content-config-shape.md +0 -148
  189. package/skills/bpmax-list-template-editor/references/dataset-field-mapping.md +0 -60
  190. package/skills/bpmax-list-template-editor/references/list-template-api-workflow.md +0 -103
  191. package/skills/bpmax-list-template-editor/references/local-temp-workflow.md +0 -102
  192. package/skills/bpmax-list-template-editor/references/payload-checklist.md +0 -47
  193. package/skills/bpmax-list-template-editor/references/runtime-verified-workflow.md +0 -140
  194. package/skills/bpmax-list-template-editor/references/special-formats.md +0 -394
  195. package/skills/bpmax-list-template-editor/scripts/build_submit_payload.py +0 -37
  196. package/skills/bpmax-list-template-editor/scripts/confirm_list_template.py +0 -33
  197. package/skills/bpmax-list-template-editor/scripts/export_list_template.py +0 -89
  198. package/skills/bpmax-list-template-editor/scripts/fetch_data_set.py +0 -34
  199. package/skills/bpmax-list-template-editor/scripts/lint_list_template_semantics.py +0 -54
  200. package/skills/bpmax-list-template-editor/scripts/list_template_editor_common.py +0 -955
  201. package/skills/bpmax-list-template-editor/scripts/record_acceptance.py +0 -55
  202. package/skills/bpmax-list-template-editor/scripts/submit_list_template.py +0 -117
  203. package/skills/bpmax-list-template-editor/tests/test_list_template_editor_common.py +0 -441
  204. package/skills/bpmax-memory-protocol/SKILL.md +0 -72
  205. package/skills/bpmax-nav-config-editor/SKILL.md +0 -347
  206. package/skills/bpmax-nav-config-editor/agents/openai.yaml +0 -4
  207. package/skills/bpmax-nav-config-editor/references/api-workflow.md +0 -68
  208. package/skills/bpmax-nav-config-editor/references/config-shape.md +0 -78
  209. package/skills/bpmax-nav-config-editor/references/icon-selection.md +0 -83
  210. package/skills/bpmax-nav-config-editor/references/path-mapping-rules.md +0 -46
  211. package/skills/bpmax-nav-config-editor/references/payload-checklist.md +0 -41
  212. package/skills/bpmax-nav-config-editor/references/runtime-probing.md +0 -47
  213. package/skills/bpmax-nav-config-editor/scripts/build_submit_payload.py +0 -34
  214. package/skills/bpmax-nav-config-editor/scripts/confirm_nav_config.py +0 -32
  215. package/skills/bpmax-nav-config-editor/scripts/export_nav_config.py +0 -56
  216. package/skills/bpmax-nav-config-editor/scripts/lint_nav_config_semantics.py +0 -33
  217. package/skills/bpmax-nav-config-editor/scripts/nav_config_editor_common.py +0 -812
  218. package/skills/bpmax-nav-config-editor/scripts/submit_nav_config.py +0 -44
  219. package/skills/bpmax-nav-config-editor/scripts/verify_nav_config.py +0 -33
  220. package/skills/bpmax-nav-config-editor/tests/test_nav_config_editor.py +0 -358
  221. package/skills/bpmax-nav-config-editor/tests/test_nav_config_editor_common.py +0 -138
  222. package/skills/bpmax-nav-config-editor/tests/test_nav_config_lint.py +0 -58
  223. package/skills/bpmax-nav-config-editor/tests/test_nav_config_submit_verify.py +0 -51
  224. package/skills/bpmax-project-detail-template-editor/SKILL.md +0 -329
  225. package/skills/bpmax-project-detail-template-editor/agents/openai.yaml +0 -4
  226. package/skills/bpmax-project-detail-template-editor/references/local-temp-workflow.md +0 -59
  227. package/skills/bpmax-project-detail-template-editor/references/module-catalog-and-config-notes.md +0 -47
  228. package/skills/bpmax-project-detail-template-editor/references/payload-checklist.md +0 -33
  229. package/skills/bpmax-project-detail-template-editor/references/project-detail-template-api-workflow.md +0 -44
  230. package/skills/bpmax-project-detail-template-editor/scripts/build_submit_payload.py +0 -30
  231. package/skills/bpmax-project-detail-template-editor/scripts/confirm_project_detail_template.py +0 -33
  232. package/skills/bpmax-project-detail-template-editor/scripts/export_project_detail_template.py +0 -87
  233. package/skills/bpmax-project-detail-template-editor/scripts/lint_project_detail_template_semantics.py +0 -37
  234. package/skills/bpmax-project-detail-template-editor/scripts/project_detail_template_editor_common.py +0 -507
  235. package/skills/bpmax-project-detail-template-editor/scripts/submit_project_detail_template.py +0 -120
  236. package/skills/bpmax-project-detail-template-editor/tests/test_project_detail_template_editor.py +0 -369
  237. package/skills/bpmax-role-editor/SKILL.md +0 -251
  238. package/skills/bpmax-role-editor/references/api-workflow.md +0 -30
  239. package/skills/bpmax-role-editor/references/runtime-page-shape.md +0 -18
  240. package/skills/bpmax-role-editor/references/work-file-mapping.md +0 -32
  241. package/skills/bpmax-role-editor/scripts/build_submit_payload.py +0 -38
  242. package/skills/bpmax-role-editor/scripts/confirm_role.py +0 -33
  243. package/skills/bpmax-role-editor/scripts/export_role.py +0 -163
  244. package/skills/bpmax-role-editor/scripts/lint_role_semantics.py +0 -38
  245. package/skills/bpmax-role-editor/scripts/role_editor_common.py +0 -1231
  246. package/skills/bpmax-role-editor/scripts/submit_role.py +0 -144
  247. package/skills/bpmax-role-editor/tests/test_role_editor.py +0 -343
  248. package/skills/bpmax-user-mock-operator/SKILL.md +0 -106
  249. package/skills/bpmax-user-mock-operator/agents/openai.yaml +0 -4
  250. package/skills/bpmax-user-mock-operator/scripts/switch_user_identity.py +0 -37
  251. package/skills/bpmax-user-mock-operator/scripts/user_mock_operator_common.py +0 -136
  252. package/skills/bpmax-user-mock-operator/tests/test_user_mock_operator.py +0 -138
  253. package/skills/form-control-library/SKILL.md +0 -82
  254. package/skills/form-control-library/agents/openai.yaml +0 -4
  255. package/skills/form-control-library/references/form-controls.md +0 -199
  256. package/skills/form-control-library/references/form-template-submit-schema.md +0 -180
  257. package/skills/form-control-library/references/group-select-runtime.md +0 -191
  258. package/skills/form-control-library/scripts/rebuild_form_control_library.py +0 -55
@@ -1,812 +0,0 @@
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 re
9
- import ssl
10
- import sys
11
- import urllib.error
12
- import urllib.parse
13
- import urllib.request
14
- from dataclasses import dataclass
15
- from datetime import datetime, timezone
16
- from difflib import unified_diff
17
- from pathlib import Path
18
- from typing import Any, Dict, Mapping, Optional
19
-
20
-
21
- SHARED_SKILL_ROOT = Path(__file__).resolve().parents[2] / "bpmax-builder-shared"
22
- if str(SHARED_SKILL_ROOT) not in sys.path:
23
- sys.path.insert(0, str(SHARED_SKILL_ROOT))
24
- from base_url import DEFAULT_AGENTS_PATH, DEFAULT_BASE_URL, resolve_base_url
25
-
26
-
27
- DEFAULT_LANGUAGE = "zhCN"
28
- REPO_ROOT = Path(__file__).resolve().parents[4]
29
- AGENTS_PATH = DEFAULT_AGENTS_PATH if DEFAULT_AGENTS_PATH.exists() else REPO_ROOT / "AGENTS.md"
30
- TMP_ROOT = REPO_ROOT / ".codex" / "tmp" / "nav-config-editor"
31
- TMP_SUBDIRS = ("raw", "work", "meta", "submit", "diffs", "result")
32
- CONFIG_TYPES = ("navmenu", "shortcut", "navmenu_mobile", "shortcut_mobile")
33
- CONTENT_KEY_BY_TYPE = {
34
- "navmenu": "navConfig",
35
- "shortcut": "shortcutConfig",
36
- "navmenu_mobile": "navMobileConfig",
37
- "shortcut_mobile": "shortcutMobileConfig",
38
- }
39
- DEFAULT_NAMES = {
40
- "navmenu": "工作区导航",
41
- "shortcut": "工作区快捷入口",
42
- "navmenu_mobile": "移动导航",
43
- "shortcut_mobile": "移动快捷入口",
44
- }
45
- MOBILE_TYPES = {"navmenu_mobile", "shortcut_mobile"}
46
- SHORTCUT_TYPES = {"shortcut", "shortcut_mobile"}
47
- RI_ICON_PATTERN = re.compile(r"^ri ri_[A-Za-z0-9-]+$")
48
- EL_ICON_PATTERN = re.compile(r"^el-icon-[A-Za-z0-9-]+$")
49
- VALID_PERMISSION_TYPES = {"PERMISSION_POINT", "VISIBILITY_SCOPE"}
50
- VALID_VISIBILITY_VALUES = {"public", "self", "custom"}
51
-
52
-
53
- def utc_now_iso() -> str:
54
- return datetime.now(timezone.utc).isoformat()
55
-
56
-
57
- def ensure_tmp_dirs() -> None:
58
- for part in TMP_SUBDIRS:
59
- (TMP_ROOT / part).mkdir(parents=True, exist_ok=True)
60
-
61
-
62
- def paths_for(stem: str) -> Dict[str, Path]:
63
- ensure_tmp_dirs()
64
- return {
65
- "raw": TMP_ROOT / "raw" / f"{stem}.json",
66
- "work": TMP_ROOT / "work" / f"{stem}.json",
67
- "meta": TMP_ROOT / "meta" / f"{stem}.json",
68
- "submit": TMP_ROOT / "submit" / f"{stem}.json",
69
- "work_diff": TMP_ROOT / "diffs" / f"{stem}.work.diff.txt",
70
- "submit_diff": TMP_ROOT / "diffs" / f"{stem}.submit.diff.txt",
71
- "response": TMP_ROOT / "result" / f"{stem}.response.json",
72
- "readback": TMP_ROOT / "result" / f"{stem}.readback.json",
73
- "verify": TMP_ROOT / "result" / f"{stem}.verify.json",
74
- "lint": TMP_ROOT / "result" / f"{stem}.lint.json",
75
- }
76
-
77
-
78
- def dump_json(path: Path, payload: Any) -> None:
79
- path.parent.mkdir(parents=True, exist_ok=True)
80
- path.write_text(json.dumps(payload, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
81
-
82
-
83
- def load_json(path: Path) -> Any:
84
- return json.loads(path.read_text(encoding="utf-8"))
85
-
86
-
87
- def file_sha256(path: Path) -> str:
88
- return hashlib.sha256(path.read_bytes()).hexdigest()
89
-
90
-
91
- def stable_json_lines(payload: Any) -> list[str]:
92
- return (json.dumps(payload, ensure_ascii=False, indent=2, sort_keys=True) + "\n").splitlines(keepends=True)
93
-
94
-
95
- def write_diff(path: Path, before: Any, after: Any, before_label: str, after_label: str) -> None:
96
- diff = unified_diff(
97
- stable_json_lines(before),
98
- stable_json_lines(after),
99
- fromfile=before_label,
100
- tofile=after_label,
101
- )
102
- path.parent.mkdir(parents=True, exist_ok=True)
103
- path.write_text("".join(diff) or "# no diff\n", encoding="utf-8")
104
-
105
-
106
- def resolve_runtime_base_url(
107
- value: str | None,
108
- *,
109
- browser_origin: str | None = None,
110
- env: Mapping[str, str] | None = None,
111
- ) -> str:
112
- return resolve_base_url(
113
- value,
114
- browser_origin=browser_origin,
115
- env=env,
116
- agents_path=AGENTS_PATH,
117
- )
118
-
119
-
120
- def _parse_jsonish(value: Any) -> Any:
121
- if isinstance(value, str):
122
- text = value.strip()
123
- if not text:
124
- return {}
125
- return json.loads(text)
126
- return copy.deepcopy(value)
127
-
128
-
129
- def _normalize_scope_value(value: Any) -> str:
130
- if value in (None, "", {}):
131
- return ""
132
- payload = _parse_jsonish(value)
133
- if not isinstance(payload, dict):
134
- raise SystemExit("visibility_scope must be a JSON object string or object")
135
- config = payload.get("config") if isinstance(payload.get("config"), dict) else {}
136
- normalized = {
137
- "config": {
138
- "user": copy.deepcopy(config.get("user") if isinstance(config.get("user"), list) else []),
139
- "group": copy.deepcopy(config.get("group") if isinstance(config.get("group"), list) else []),
140
- "role": copy.deepcopy(config.get("role") if isinstance(config.get("role"), list) else []),
141
- }
142
- }
143
- return json.dumps(normalized, ensure_ascii=False, separators=(",", ":"))
144
-
145
-
146
- def _preserve_or_normalize_scope(value: Any) -> Any:
147
- if value in (None, "", {}):
148
- return ""
149
- if isinstance(value, dict):
150
- return _normalize_scope_value(value)
151
- if isinstance(value, str):
152
- text = value.strip()
153
- if not text:
154
- return ""
155
- try:
156
- return _normalize_scope_value(text)
157
- except (SystemExit, json.JSONDecodeError):
158
- return text
159
- return value
160
-
161
-
162
- def normalize_node(node: Any) -> dict[str, Any]:
163
- if not isinstance(node, dict):
164
- raise SystemExit("navigation node must be an object")
165
- payload = copy.deepcopy(node)
166
- payload.setdefault("id", "")
167
- payload.setdefault("name", "")
168
- payload.setdefault("icon", "")
169
- payload.setdefault("permission", "")
170
- payload.setdefault("path", "/")
171
- payload.setdefault("color", "")
172
- payload.setdefault("sub", [])
173
- payload.setdefault("permissionType", "PERMISSION_POINT")
174
- payload.setdefault("visibility", "public")
175
- payload.setdefault("visibility_scope", "")
176
- if not isinstance(payload["sub"], list):
177
- raise SystemExit("navigation node.sub must be an array")
178
- payload["sub"] = [normalize_node(item) for item in payload["sub"]]
179
- payload["name"] = str(payload.get("name") or "")
180
- payload["icon"] = str(payload.get("icon") or "")
181
- payload["permission"] = str(payload.get("permission") or "")
182
- payload["path"] = str(payload.get("path") or "")
183
- payload["color"] = str(payload.get("color") or "")
184
- payload["permissionType"] = str(payload.get("permissionType") or "PERMISSION_POINT")
185
- payload["visibility"] = str(payload.get("visibility") or "public")
186
- payload["visibility_scope"] = _preserve_or_normalize_scope(payload.get("visibility_scope"))
187
- return payload
188
-
189
-
190
- def _extract_items_and_flag(config_type: str, content: Any) -> tuple[list[dict[str, Any]], bool]:
191
- if config_type not in CONTENT_KEY_BY_TYPE:
192
- raise SystemExit(f"unsupported config type: {config_type}")
193
- payload = _parse_jsonish(content)
194
- if payload in (None, ""):
195
- payload = {}
196
- if not isinstance(payload, dict):
197
- raise SystemExit(f"{config_type} content must be an object")
198
- content_key = CONTENT_KEY_BY_TYPE[config_type]
199
- items = payload.get(content_key) or []
200
- if not isinstance(items, list):
201
- raise SystemExit(f"{config_type} content.{content_key} must be an array")
202
- enable_multi_level = payload.get("enableMultiLevel", False)
203
- if not isinstance(enable_multi_level, bool):
204
- raise SystemExit(f"{config_type} content.enableMultiLevel must be boolean when present")
205
- return [normalize_node(item) for item in items], enable_multi_level
206
-
207
-
208
- def _build_content(config_type: str, items: list[dict[str, Any]], enable_multi_level: bool) -> dict[str, Any]:
209
- return {
210
- CONTENT_KEY_BY_TYPE[config_type]: [normalize_node(item) for item in items],
211
- "enableMultiLevel": bool(enable_multi_level),
212
- }
213
-
214
-
215
- def _config_detail_to_work_entry(config_type: str, detail: Any) -> dict[str, Any]:
216
- detail_payload = detail if isinstance(detail, dict) else {}
217
- items, enable_multi_level = _extract_items_and_flag(config_type, detail_payload.get("content"))
218
- return {
219
- "id": detail_payload.get("id"),
220
- "guid": detail_payload.get("guid"),
221
- "type": config_type,
222
- "name": str(detail_payload.get("name") or DEFAULT_NAMES[config_type]).strip(),
223
- "items": items,
224
- "enableMultiLevel": enable_multi_level,
225
- "content": _build_content(config_type, items, enable_multi_level),
226
- }
227
-
228
-
229
- def _source_signature(items: list[dict[str, Any]], enable_multi_level: bool) -> str:
230
- return json.dumps(
231
- {
232
- "items": [normalize_node(item) for item in items],
233
- "enableMultiLevel": bool(enable_multi_level),
234
- },
235
- ensure_ascii=False,
236
- sort_keys=True,
237
- )
238
-
239
-
240
- def _read_config_sources(config_type: str, config_payload: dict[str, Any]) -> list[tuple[str, list[dict[str, Any]], bool]]:
241
- sources: list[tuple[str, list[dict[str, Any]], bool]] = []
242
- if isinstance(config_payload.get("items"), list):
243
- enable_multi_level = config_payload.get("enableMultiLevel", False)
244
- if not isinstance(enable_multi_level, bool):
245
- raise SystemExit(f"{config_type}.enableMultiLevel must be boolean")
246
- sources.append(
247
- (
248
- "items",
249
- [normalize_node(item) for item in config_payload.get("items", [])],
250
- enable_multi_level,
251
- )
252
- )
253
- if "content" in config_payload:
254
- items, enable_multi_level = _extract_items_and_flag(config_type, config_payload.get("content"))
255
- sources.append(("content", items, enable_multi_level))
256
- if not sources:
257
- raise SystemExit(f"{config_type} must define items or content")
258
- return sources
259
-
260
-
261
- def bundle_to_work_payload(raw_bundle: Dict[str, Any]) -> Dict[str, Any]:
262
- if not isinstance(raw_bundle, dict):
263
- raise SystemExit("raw nav bundle must be an object")
264
- raw_configs = raw_bundle.get("configs")
265
- if not isinstance(raw_configs, dict):
266
- raise SystemExit("raw nav bundle must contain configs object")
267
- configs: dict[str, Any] = {}
268
- for config_type in CONFIG_TYPES:
269
- configs[config_type] = _config_detail_to_work_entry(config_type, raw_configs.get(config_type) or {})
270
- payload = {
271
- "workspace": str(raw_bundle.get("workspace") or "").strip(),
272
- "language": str(raw_bundle.get("language") or DEFAULT_LANGUAGE).strip() or DEFAULT_LANGUAGE,
273
- "configs": configs,
274
- }
275
- if raw_bundle.get("baseUrl") not in (None, ""):
276
- payload["baseUrl"] = str(raw_bundle.get("baseUrl")).strip()
277
- if isinstance(raw_bundle.get("requestUrls"), dict):
278
- payload["requestUrls"] = copy.deepcopy(raw_bundle["requestUrls"])
279
- return payload
280
-
281
-
282
- def detail_to_work_payload(
283
- details_by_type: Dict[str, Any],
284
- *,
285
- workspace: str,
286
- language: str = DEFAULT_LANGUAGE,
287
- ) -> Dict[str, Any]:
288
- return bundle_to_work_payload(
289
- {
290
- "workspace": workspace,
291
- "language": language,
292
- "configs": details_by_type,
293
- }
294
- )
295
-
296
-
297
- def _extract_work_items(config_type: str, config_payload: dict[str, Any]) -> tuple[list[dict[str, Any]], bool]:
298
- sources = _read_config_sources(config_type, config_payload)
299
- signatures = {_source_signature(items, enable_multi_level) for _, items, enable_multi_level in sources}
300
- if len(signatures) > 1:
301
- raise SystemExit(f"{config_type} work payload drifted between items and content views")
302
- _, items, enable_multi_level = sources[0]
303
- return items, enable_multi_level
304
-
305
-
306
- def build_submit_payload(work_payload: Dict[str, Any]) -> Dict[str, Any]:
307
- configs = work_payload.get("configs")
308
- if not isinstance(configs, dict):
309
- raise SystemExit("work payload must contain configs object")
310
- submit_configs: dict[str, Any] = {}
311
- operations: list[dict[str, Any]] = []
312
- for config_type in CONFIG_TYPES:
313
- config = configs.get(config_type)
314
- if not isinstance(config, dict):
315
- raise SystemExit(f"missing config type: {config_type}")
316
- items, enable_multi_level = _extract_work_items(config_type, config)
317
- payload = {
318
- "type": config_type,
319
- "name": str(config.get("name") or DEFAULT_NAMES[config_type]).strip(),
320
- "content": _build_content(config_type, items, enable_multi_level),
321
- }
322
- config_id = config.get("id")
323
- config_guid = config.get("guid")
324
- if config_id not in (None, ""):
325
- payload["id"] = config_id
326
- if config_guid not in (None, ""):
327
- payload["guid"] = config_guid
328
- submit_configs[config_type] = payload
329
- method = "PUT" if config_id not in (None, "") else "POST"
330
- path = (
331
- f"/api/configuration/{config_id}?is_default_action=1"
332
- if method == "PUT"
333
- else "/api/configuration?is_default_action=1"
334
- )
335
- operations.append(
336
- {
337
- "type": config_type,
338
- "method": method,
339
- "path": path,
340
- "id": config_id,
341
- "payload": copy.deepcopy(payload),
342
- }
343
- )
344
- return {
345
- "workspace": str(work_payload.get("workspace") or "").strip(),
346
- "language": str(work_payload.get("language") or DEFAULT_LANGUAGE).strip() or DEFAULT_LANGUAGE,
347
- "configs": submit_configs,
348
- "operations": operations,
349
- }
350
-
351
-
352
- def build_submission_plan(submit_payload: Dict[str, Any]) -> list[dict[str, Any]]:
353
- operations = submit_payload.get("operations")
354
- if isinstance(operations, list) and operations:
355
- return copy.deepcopy(operations)
356
- return build_submit_payload(submit_payload).get("operations", [])
357
-
358
-
359
- def load_meta(path: Path) -> Dict[str, Any]:
360
- if not path.exists():
361
- return {}
362
- payload = load_json(path)
363
- if not isinstance(payload, dict):
364
- raise SystemExit(f"invalid meta file: {path}")
365
- return payload
366
-
367
-
368
- def ensure_meta_shape(meta: Dict[str, Any], *, stem: str, workspace: str = "") -> Dict[str, Any]:
369
- payload = dict(meta)
370
- payload.setdefault("stem", stem)
371
- payload.setdefault("workspace", workspace)
372
- payload.setdefault("status", "exported")
373
- payload.setdefault("lintOk", None)
374
- payload.setdefault("workConfirmedAt", None)
375
- payload.setdefault("workConfirmedBy", None)
376
- payload.setdefault("submitConfirmedAt", None)
377
- payload.setdefault("submitConfirmedBy", None)
378
- payload.setdefault("workSha256", None)
379
- payload.setdefault("submitSha256", None)
380
- return payload
381
-
382
-
383
- def _infer_workspace(meta: Dict[str, Any], work_path: Optional[Path]) -> str:
384
- if meta.get("workspace"):
385
- return str(meta.get("workspace") or "")
386
- if work_path is not None and work_path.exists():
387
- work_payload = load_json(work_path)
388
- if isinstance(work_payload, dict):
389
- return str(work_payload.get("workspace") or "")
390
- return ""
391
-
392
-
393
- def update_confirmation_state(
394
- meta_path: Path,
395
- *,
396
- stem: str,
397
- actor: str,
398
- stage: str,
399
- work_path: Path,
400
- submit_path: Optional[Path] = None,
401
- workspace: str = "",
402
- ) -> Dict[str, Any]:
403
- current = load_meta(meta_path)
404
- resolved_workspace = workspace or _infer_workspace(current, work_path)
405
- payload = ensure_meta_shape(current, stem=stem, workspace=resolved_workspace)
406
- now = utc_now_iso()
407
- if stage == "work":
408
- payload["workConfirmedAt"] = now
409
- payload["workConfirmedBy"] = actor
410
- payload["workSha256"] = file_sha256(work_path)
411
- payload["submitConfirmedAt"] = None
412
- payload["submitConfirmedBy"] = None
413
- payload["submitSha256"] = None
414
- payload["lintOk"] = None
415
- payload["lintCheckedAt"] = None
416
- payload["lintSha256"] = None
417
- payload["lintWorkSha256"] = None
418
- payload["lintSubmitSha256"] = None
419
- payload["status"] = "work_confirmed"
420
- elif stage == "submit":
421
- if submit_path is None:
422
- raise SystemExit("submit stage requires submit_path")
423
- payload["submitConfirmedAt"] = now
424
- payload["submitConfirmedBy"] = actor
425
- payload["submitSha256"] = file_sha256(submit_path)
426
- payload["status"] = "submit_confirmed"
427
- else:
428
- raise SystemExit(f"unsupported confirmation stage: {stage}")
429
- dump_json(meta_path, payload)
430
- return payload
431
-
432
-
433
- def ensure_build_allowed(meta_path: Path, work_path: Path) -> Dict[str, Any]:
434
- meta = load_meta(meta_path)
435
- if not meta.get("workConfirmedAt"):
436
- raise SystemExit("build blocked: work confirmation is required")
437
- current_work_sha = file_sha256(work_path)
438
- if meta.get("workSha256") != current_work_sha:
439
- raise SystemExit("build blocked: work file changed after confirmation")
440
- return meta
441
-
442
-
443
- def update_build_meta(
444
- meta_path: Path,
445
- *,
446
- stem: str,
447
- work_path: Path,
448
- submit_path: Path,
449
- workspace: str = "",
450
- ) -> Dict[str, Any]:
451
- current = load_meta(meta_path)
452
- resolved_workspace = workspace or _infer_workspace(current, work_path)
453
- payload = ensure_meta_shape(current, stem=stem, workspace=resolved_workspace)
454
- current_work_sha = file_sha256(work_path)
455
- payload["submitSha256"] = file_sha256(submit_path)
456
- if payload.get("workSha256") != current_work_sha:
457
- payload["workConfirmedAt"] = None
458
- payload["workConfirmedBy"] = None
459
- payload["submitConfirmedAt"] = None
460
- payload["submitConfirmedBy"] = None
461
- payload["workSha256"] = current_work_sha
462
- payload["submitConfirmedAt"] = None
463
- payload["submitConfirmedBy"] = None
464
- payload["lintOk"] = None
465
- payload["lintCheckedAt"] = None
466
- payload["lintSha256"] = None
467
- payload["lintWorkSha256"] = None
468
- payload["lintSubmitSha256"] = None
469
- payload["status"] = "submit_built"
470
- dump_json(meta_path, payload)
471
- return payload
472
-
473
-
474
- def update_lint_meta(
475
- meta_path: Path,
476
- *,
477
- stem: str,
478
- work_path: Path,
479
- submit_path: Path,
480
- lint_path: Path,
481
- lint_report: Dict[str, Any],
482
- workspace: str = "",
483
- ) -> Dict[str, Any]:
484
- current = load_meta(meta_path)
485
- resolved_workspace = workspace or _infer_workspace(current, work_path)
486
- payload = ensure_meta_shape(current, stem=stem, workspace=resolved_workspace)
487
- payload["lintOk"] = bool(lint_report.get("ok"))
488
- payload["lintCheckedAt"] = utc_now_iso()
489
- payload["lintWorkSha256"] = file_sha256(work_path)
490
- payload["lintSubmitSha256"] = file_sha256(submit_path)
491
- payload["lintSha256"] = file_sha256(lint_path)
492
- payload["submitConfirmedAt"] = None
493
- payload["submitConfirmedBy"] = None
494
- payload["status"] = "lint_passed" if payload["lintOk"] else "lint_failed"
495
- dump_json(meta_path, payload)
496
- return payload
497
-
498
-
499
- def ensure_submission_allowed(
500
- meta_path: Path,
501
- work_path: Path,
502
- submit_path: Path,
503
- raw_path: Optional[Path] = None,
504
- lint_path: Optional[Path] = None,
505
- ) -> Dict[str, Any]:
506
- if lint_path is None:
507
- lint_path = raw_path
508
- if lint_path is None:
509
- raise SystemExit("submission blocked: lint artifact is required")
510
- meta = load_meta(meta_path)
511
- required_fields = ("workConfirmedAt", "lintCheckedAt", "submitConfirmedAt")
512
- missing = [field for field in required_fields if not meta.get(field)]
513
- if missing:
514
- raise SystemExit(f"submission blocked: missing meta fields {', '.join(missing)}")
515
- if not meta.get("lintOk"):
516
- raise SystemExit("submission blocked: lint did not pass")
517
- if meta.get("workSha256") != file_sha256(work_path):
518
- raise SystemExit("submission blocked: work file changed after confirmation")
519
- if meta.get("submitSha256") != file_sha256(submit_path):
520
- raise SystemExit("submission blocked: submit file changed after confirmation")
521
- if meta.get("lintWorkSha256") != file_sha256(work_path) or meta.get("lintSubmitSha256") != file_sha256(submit_path):
522
- raise SystemExit("submission blocked: lint results are stale")
523
- if meta.get("lintSha256") != file_sha256(lint_path):
524
- raise SystemExit("submission blocked: lint artifact changed after confirmation")
525
- return meta
526
-
527
-
528
- def _is_valid_icon(value: Any) -> bool:
529
- if not isinstance(value, str) or not value.strip():
530
- return False
531
- return bool(RI_ICON_PATTERN.fullmatch(value) or EL_ICON_PATTERN.fullmatch(value))
532
-
533
-
534
- def _check_scope_payload(value: Any) -> Optional[str]:
535
- if value in (None, "", {}):
536
- return None
537
- try:
538
- payload = _parse_jsonish(value)
539
- except json.JSONDecodeError as exc:
540
- return str(exc)
541
- if not isinstance(payload, dict):
542
- return "visibility_scope must be an object"
543
- config = payload.get("config")
544
- if not isinstance(config, dict):
545
- return "visibility_scope.config must be an object"
546
- for key in ("user", "group", "role"):
547
- if key in config and not isinstance(config.get(key), list):
548
- return f"visibility_scope.config.{key} must be an array"
549
- return None
550
-
551
-
552
- def _scan_nodes(
553
- nodes: list[Any],
554
- *,
555
- config_type: str,
556
- path: str,
557
- report: Dict[str, Any],
558
- ) -> None:
559
- for idx, node in enumerate(nodes):
560
- node_path = f"{path}[{idx}]"
561
- if not isinstance(node, dict):
562
- report["errors"].append(f"{node_path} must be an object")
563
- continue
564
- for key in ("id", "name", "icon", "path", "sub", "permissionType", "visibility", "visibility_scope"):
565
- if key not in node:
566
- report["errors"].append(f"{node_path}.{key} is required")
567
- name = str(node.get("name") or "")
568
- if not name.strip():
569
- report["errors"].append(f"{node_path}.name must be a non-empty string")
570
- elif len(name.strip()) > 6:
571
- report["errors"].append(f"{node_path}.name exceeds the 6 Hanzi limit")
572
- if not _is_valid_icon(node.get("icon")):
573
- report["errors"].append(
574
- f"{node_path}.icon must be a full icon class; "
575
- f"{node_path}.icon must use a full icon class such as `ri ri_home-5-line`"
576
- )
577
- path_value = str(node.get("path") or "")
578
- if config_type in MOBILE_TYPES and (path_value.startswith("/project") or path_value.startswith("/myProject")):
579
- report["errors"].append(f"{node_path}.path must use an H5 path; got PC route instead of H5 route")
580
- if config_type not in MOBILE_TYPES and path_value.startswith("/pages/"):
581
- report["errors"].append(f"{node_path}.path must stay on PC routing; got H5 route instead of PC route")
582
- permission_type = str(node.get("permissionType") or "")
583
- if permission_type not in VALID_PERMISSION_TYPES:
584
- report["errors"].append(f"{node_path}.permissionType must be one of {sorted(VALID_PERMISSION_TYPES)}")
585
- visibility = str(node.get("visibility") or "")
586
- if permission_type == "PERMISSION_POINT":
587
- if visibility != "public":
588
- report["errors"].append(f"{node_path}.visibility must be `public` in PERMISSION_POINT mode")
589
- if node.get("visibility_scope") not in (None, "", {}):
590
- report["errors"].append(f"{node_path}.visibility_scope must be empty in PERMISSION_POINT mode")
591
- elif permission_type == "VISIBILITY_SCOPE":
592
- if str(node.get("permission") or ""):
593
- report["errors"].append(f"{node_path}.permission must be empty in VISIBILITY_SCOPE mode")
594
- if visibility not in VALID_VISIBILITY_VALUES:
595
- report["errors"].append(f"{node_path}.visibility must be one of {sorted(VALID_VISIBILITY_VALUES)}")
596
- scope_error = _check_scope_payload(node.get("visibility_scope"))
597
- if scope_error:
598
- report["errors"].append(f"{node_path}.visibility_scope invalid: {scope_error}")
599
- sub = node.get("sub")
600
- if not isinstance(sub, list):
601
- report["errors"].append(f"{node_path}.sub must be an array")
602
- continue
603
- if config_type in SHORTCUT_TYPES and sub:
604
- report["errors"].append(
605
- f"{node_path}.sub must stay empty for shortcut configs; must stay empty for flat shortcut configs"
606
- )
607
- _scan_nodes(sub, config_type=config_type, path=f"{node_path}.sub", report=report)
608
-
609
-
610
- def lint_nav_config_semantics(
611
- work_payload: Dict[str, Any],
612
- *,
613
- raw_payload: Optional[Dict[str, Any]] = None,
614
- submit_payload: Optional[Dict[str, Any]] = None,
615
- ) -> Dict[str, Any]:
616
- report: Dict[str, Any] = {
617
- "ok": True,
618
- "errors": [],
619
- "warnings": [],
620
- "checks": {
621
- "configTypes": list(CONFIG_TYPES),
622
- "workspace": str(work_payload.get("workspace") or ""),
623
- },
624
- }
625
- if raw_payload and raw_payload.get("baseUrl"):
626
- report["checks"]["sourceBaseUrl"] = raw_payload.get("baseUrl")
627
- configs = work_payload.get("configs")
628
- if not isinstance(configs, dict):
629
- report["errors"].append("work payload must contain configs object")
630
- report["ok"] = False
631
- return report
632
- missing_types = [config_type for config_type in CONFIG_TYPES if not isinstance(configs.get(config_type), dict)]
633
- if missing_types:
634
- report["errors"].append(f"missing config types: {', '.join(missing_types)}")
635
- for config_type in missing_types:
636
- report["errors"].append(f"missing config type {config_type}")
637
- payload = submit_payload
638
- if payload is None:
639
- try:
640
- payload = build_submit_payload(work_payload)
641
- except SystemExit as exc:
642
- report["warnings"].append(f"submit preview unavailable: {exc}")
643
- payload = {
644
- "configs": {
645
- config_type: {
646
- "type": config_type,
647
- "name": str((configs.get(config_type) or {}).get("name") or DEFAULT_NAMES[config_type]).strip(),
648
- }
649
- for config_type in CONFIG_TYPES
650
- if isinstance(configs.get(config_type), dict)
651
- }
652
- }
653
- submit_configs = payload.get("configs") if isinstance(payload.get("configs"), dict) else {}
654
- for config_type in CONFIG_TYPES:
655
- work_config = configs.get(config_type)
656
- if not isinstance(work_config, dict):
657
- continue
658
- submit_config = submit_configs.get(config_type)
659
- if not isinstance(submit_config, dict):
660
- report["errors"].append(f"{config_type}.submit payload missing")
661
- continue
662
- if submit_config.get("type") != config_type:
663
- report["errors"].append(f"{config_type}.type must equal {config_type}")
664
- if not isinstance(submit_config.get("name"), str) or not str(submit_config.get("name")).strip():
665
- report["errors"].append(f"{config_type}.name must be a non-empty string")
666
- try:
667
- sources = _read_config_sources(config_type, work_config)
668
- except SystemExit as exc:
669
- report["errors"].append(f"{config_type} invalid: {exc}")
670
- continue
671
- unique_sources: dict[str, tuple[str, list[dict[str, Any]], bool]] = {}
672
- for source_name, items, enable_multi_level in sources:
673
- unique_sources.setdefault(_source_signature(items, enable_multi_level), (source_name, items, enable_multi_level))
674
- if len(unique_sources) > 1:
675
- report["warnings"].append(f"{config_type} items/content views drifted; lint scanned both sources")
676
- for source_name, items, enable_multi_level in unique_sources.values():
677
- report["checks"][f"{config_type}.{source_name}.enableMultiLevel"] = enable_multi_level
678
- _scan_nodes(items, config_type=config_type, path=f"{config_type}.{source_name}", report=report)
679
- report["ok"] = not report["errors"]
680
- return report
681
-
682
-
683
- def _readback_configs(readback_payload: Dict[str, Any]) -> Dict[str, Any]:
684
- configs = readback_payload.get("configs")
685
- if isinstance(configs, dict):
686
- return configs
687
- return readback_payload
688
-
689
-
690
- def _detail_to_compare_payload(config_type: str, detail: Any) -> Dict[str, Any]:
691
- entry = _config_detail_to_work_entry(config_type, detail)
692
- items, enable_multi_level = _extract_work_items(config_type, entry)
693
- return {
694
- "type": config_type,
695
- "name": entry.get("name") or DEFAULT_NAMES[config_type],
696
- "content": _build_content(config_type, items, enable_multi_level),
697
- }
698
-
699
-
700
- def summarize_verification(
701
- submit_payload: Dict[str, Any],
702
- readback_by_type: Dict[str, Any],
703
- *,
704
- language: str = DEFAULT_LANGUAGE,
705
- ) -> Dict[str, Any]:
706
- checks: dict[str, Any] = {}
707
- ok = True
708
- readback_configs = _readback_configs(readback_by_type if isinstance(readback_by_type, dict) else {})
709
- for config_type in CONFIG_TYPES:
710
- submit_config = copy.deepcopy((submit_payload.get("configs") or {}).get(config_type) or {})
711
- readback_detail = copy.deepcopy(readback_configs.get(config_type) or {})
712
- expected = {
713
- "type": config_type,
714
- "name": submit_config.get("name", ""),
715
- "content": _build_content(
716
- config_type,
717
- _extract_items_and_flag(config_type, submit_config.get("content"))[0],
718
- _extract_items_and_flag(config_type, submit_config.get("content"))[1],
719
- ),
720
- }
721
- actual = _detail_to_compare_payload(config_type, readback_detail)
722
- match = expected == actual
723
- checks[config_type] = {"match": match, "expected": expected, "actual": actual}
724
- ok = ok and match
725
- if ok and language == DEFAULT_LANGUAGE:
726
- completion_status = "runtime_pending"
727
- elif ok:
728
- completion_status = "manual_followup_required"
729
- else:
730
- completion_status = "readback_only"
731
- return {"ok": ok, "checks": checks, "completionStatus": completion_status}
732
-
733
-
734
- @dataclass
735
- class ApiClient:
736
- base_url: str
737
- workspace: str
738
- language: str
739
- cookie_header: str
740
- timeout: float
741
- insecure: bool = False
742
-
743
- def _build_url(self, path: str) -> str:
744
- normalized = path if path.startswith("/") else f"/{path}"
745
- if not normalized.startswith("/api/"):
746
- normalized = f"/api{normalized}"
747
- joiner = "&" if "?" in normalized else "?"
748
- suffix = f"$workspace={urllib.parse.quote(self.workspace)}&$language={urllib.parse.quote(self.language)}"
749
- return self.base_url.rstrip("/") + normalized + joiner + suffix
750
-
751
- def _request_json(self, method: str, path: str, body: Any | None = None) -> Dict[str, Any]:
752
- data = None
753
- headers = {
754
- "accept": "application/json, text/plain, */*",
755
- "cookie": self.cookie_header,
756
- }
757
- if body is not None:
758
- data = json.dumps(body, ensure_ascii=False).encode("utf-8")
759
- headers["content-type"] = "application/json"
760
- request = urllib.request.Request(self._build_url(path), data=data, method=method.upper(), headers=headers)
761
- context = ssl._create_unverified_context() if self.insecure else None
762
- try:
763
- with urllib.request.urlopen(request, timeout=self.timeout, context=context) as response:
764
- raw = response.read().decode("utf-8").strip()
765
- except urllib.error.HTTPError as exc:
766
- detail = exc.read().decode("utf-8", errors="replace")
767
- raise SystemExit(f"{method.upper()} {path} failed: HTTP {exc.code}: {detail}") from exc
768
- if not raw:
769
- return {}
770
- return json.loads(raw)
771
-
772
- def read_configuration(self, config_type: str) -> Dict[str, Any]:
773
- payload = self._request_json(
774
- "GET",
775
- f"/configuration?q_type={urllib.parse.quote(config_type)}&is_default_action=1&page=1&page_size=10000",
776
- )
777
- data = payload.get("data")
778
- if isinstance(data, list) and data:
779
- return copy.deepcopy(data[0])
780
- if isinstance(data, dict):
781
- items = data.get("data")
782
- if isinstance(items, list) and items:
783
- return copy.deepcopy(items[0])
784
- if isinstance(data, dict):
785
- return copy.deepcopy(data)
786
- return {}
787
-
788
- def create_configuration(self, payload: Dict[str, Any]) -> Dict[str, Any]:
789
- return self._request_json("POST", "/configuration?is_default_action=1", payload)
790
-
791
- def update_configuration(self, config_id: Any, payload: Dict[str, Any]) -> Dict[str, Any]:
792
- return self._request_json("PUT", f"/configuration/{config_id}?is_default_action=1", payload)
793
-
794
-
795
- def build_client(args: Any) -> ApiClient:
796
- workspace = getattr(args, "workspace", None) or os.environ.get("BPMAX_WORKSPACE", "")
797
- if not workspace:
798
- raise SystemExit("missing workspace: pass --workspace or set BPMAX_WORKSPACE")
799
- cookie_header = getattr(args, "cookie_header", None) or os.environ.get("BPMAX_COOKIE_HEADER", "")
800
- if not cookie_header:
801
- raise SystemExit("missing cookie header: pass --cookie-header or set BPMAX_COOKIE_HEADER")
802
- return ApiClient(
803
- base_url=resolve_runtime_base_url(
804
- getattr(args, "base_url", None),
805
- browser_origin=getattr(args, "browser_origin", None),
806
- ),
807
- workspace=workspace,
808
- language=getattr(args, "language", None) or DEFAULT_LANGUAGE,
809
- cookie_header=cookie_header,
810
- timeout=float(getattr(args, "timeout", 30)),
811
- insecure=bool(getattr(args, "insecure", False)),
812
- )