bpmax-cli 0.1.44 → 0.2.1-beta.2
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.
- package/README.md +52 -5
- package/dist/bin.js +12304 -1315
- package/dist/bin.js.map +1 -1
- package/package.json +1 -1
- package/scripts/install-skills.mjs +98 -0
- package/skills/bpmax-ai-taskbook/SKILL.md +227 -0
- package/skills/bpmax-ai-taskbook/agents/openai.yaml +3 -0
- package/skills/bpmax-ai-taskbook/references/taskbook-template.md +68 -0
- package/skills/bpmax-api-platform-editor/SKILL.md +321 -0
- package/skills/bpmax-api-platform-editor/agents/openai.yaml +4 -0
- package/skills/bpmax-api-platform-editor/references/api-doc-debug-workflow.md +34 -0
- package/skills/bpmax-api-platform-editor/references/api-proxy-shape.md +41 -0
- package/skills/bpmax-api-platform-editor/references/instance-config-shape.md +41 -0
- package/skills/bpmax-api-platform-editor/references/platform-api-map.md +52 -0
- package/skills/bpmax-api-platform-editor/references/runtime-workflow.md +32 -0
- package/skills/bpmax-api-platform-editor/scripts/api_platform_editor_common.py +1276 -0
- package/skills/bpmax-api-platform-editor/scripts/build_submit_payload.py +64 -0
- package/skills/bpmax-api-platform-editor/scripts/capture_write_contract.py +40 -0
- package/skills/bpmax-api-platform-editor/scripts/export_layer_bundle.py +212 -0
- package/skills/bpmax-api-platform-editor/scripts/record_doc_debug_acceptance.py +62 -0
- package/skills/bpmax-api-platform-editor/scripts/submit_and_verify_layer.py +75 -0
- package/skills/bpmax-api-platform-editor/tests/test_api_platform_editor.py +287 -0
- package/skills/bpmax-approval-matrix/SKILL.md +90 -0
- package/skills/bpmax-auth/SKILL.md +6 -17
- package/skills/bpmax-builder-shared/SKILL.md +44 -0
- package/skills/bpmax-builder-shared/base_url.py +81 -0
- package/skills/bpmax-builder-shared/runtime-script-site-matrix.json +71 -0
- package/skills/bpmax-builder-shared/runtime-script-site-matrix.md +34 -0
- package/skills/bpmax-builder-shared/runtime-script-template-catalog.md +123 -0
- package/skills/bpmax-builder-shared/runtime_script_rules.py +272 -0
- package/skills/bpmax-builder-shared/skill_audit.py +374 -0
- package/skills/bpmax-builder-shared/template_script_hard_rules.py +280 -0
- package/skills/bpmax-builder-shared/tests/test_base_url.py +80 -0
- package/skills/bpmax-builder-shared/tests/test_runtime_script_rules.py +115 -0
- package/skills/bpmax-builder-shared/tests/test_skill_audit.py +231 -0
- package/skills/bpmax-builder-shared/tests/test_template_script_hard_rules.py +281 -0
- package/skills/bpmax-cli/SKILL.md +5 -0
- package/skills/bpmax-config-latest/SKILL.md +71 -0
- package/skills/bpmax-console-template-editor/SKILL.md +536 -0
- package/skills/bpmax-console-template-editor/agents/openai.yaml +4 -0
- package/skills/bpmax-console-template-editor/references/filter-integration.md +60 -0
- package/skills/bpmax-console-template-editor/references/lessons-from-resume-dashboard.md +114 -0
- package/skills/bpmax-console-template-editor/references/local-temp-workflow.md +69 -0
- package/skills/bpmax-console-template-editor/references/module-catalog.md +100 -0
- package/skills/bpmax-console-template-editor/references/runtime-page-shape.md +91 -0
- package/skills/bpmax-console-template-editor/references/template-shape.md +149 -0
- package/skills/bpmax-console-template-editor/scripts/build_submit_payload.py +38 -0
- package/skills/bpmax-console-template-editor/scripts/confirm_console_template.py +33 -0
- package/skills/bpmax-console-template-editor/scripts/console_template_editor_common.py +964 -0
- package/skills/bpmax-console-template-editor/scripts/export_console_template.py +99 -0
- package/skills/bpmax-console-template-editor/scripts/lint_console_template.py +46 -0
- package/skills/bpmax-console-template-editor/scripts/submit_console_template.py +99 -0
- package/skills/bpmax-console-template-editor/tests/test_console_template_editor.py +383 -0
- package/skills/bpmax-dataset-field-template-editor/SKILL.md +606 -0
- package/skills/bpmax-dataset-field-template-editor/references/create-request-gotchas.md +25 -0
- package/skills/bpmax-dataset-field-template-editor/references/field-classify-mapping.md +35 -0
- package/skills/bpmax-dataset-field-template-editor/references/nested-field-patterns.md +24 -0
- package/skills/bpmax-dataset-field-template-editor/references/runtime-verified-field-page-shape.md +61 -0
- package/skills/bpmax-dataset-field-template-editor/references/virtual-field-patterns.md +27 -0
- package/skills/bpmax-dataset-field-template-editor/references/work-file-to-submit-mapping.md +127 -0
- package/skills/bpmax-dataset-field-template-editor/scripts/build_submit_payload.py +67 -0
- package/skills/bpmax-dataset-field-template-editor/scripts/confirm_dataset_field.py +37 -0
- package/skills/bpmax-dataset-field-template-editor/scripts/dataset_field_editor_common.py +784 -0
- package/skills/bpmax-dataset-field-template-editor/scripts/export_dataset_field.py +62 -0
- package/skills/bpmax-dataset-field-template-editor/scripts/init_create_dataset_field.py +104 -0
- package/skills/bpmax-dataset-field-template-editor/scripts/inspect_dataset_field_runtime.py +83 -0
- package/skills/bpmax-dataset-field-template-editor/scripts/lint_dataset_field_semantics.py +35 -0
- package/skills/bpmax-dataset-field-template-editor/scripts/submit_dataset_field.py +95 -0
- package/skills/bpmax-dataset-field-template-editor/tests/test_dataset_field_editor.py +709 -0
- package/skills/bpmax-dataset-field-template-editor/tests/test_init_create_dataset_field.py +59 -0
- package/skills/bpmax-dataset-template-editor/SKILL.md +779 -0
- package/skills/bpmax-dataset-template-editor/references/custom-key-usage-patterns.md +18 -0
- package/skills/bpmax-dataset-template-editor/references/dataset-script-runtime-matrix.md +73 -0
- package/skills/bpmax-dataset-template-editor/references/pre-process-script-authoring-guide.md +186 -0
- package/skills/bpmax-dataset-template-editor/references/pre-process-script-example-catalog.md +106 -0
- package/skills/bpmax-dataset-template-editor/references/runtime-gotchas.md +28 -0
- package/skills/bpmax-dataset-template-editor/references/runtime-verified-dataset-page-shape.md +47 -0
- package/skills/bpmax-dataset-template-editor/references/ui-to-backend-field-map.md +23 -0
- package/skills/bpmax-dataset-template-editor/references/work-file-to-submit-mapping.md +97 -0
- package/skills/bpmax-dataset-template-editor/scripts/basic_table_audit.py +65 -0
- package/skills/bpmax-dataset-template-editor/scripts/build_submit_payload.py +38 -0
- package/skills/bpmax-dataset-template-editor/scripts/dataset_editor_common.py +650 -0
- package/skills/bpmax-dataset-template-editor/scripts/export_dataset.py +155 -0
- package/skills/bpmax-dataset-template-editor/scripts/lint_dataset_template.py +42 -0
- package/skills/bpmax-dataset-template-editor/scripts/resolve_dataset.py +43 -0
- package/skills/bpmax-dataset-template-editor/scripts/scan_custom_key_references.py +27 -0
- package/skills/bpmax-dataset-template-editor/scripts/submit_dataset.py +115 -0
- package/skills/bpmax-dataset-template-editor/scripts/verify_dataset_list.py +52 -0
- package/skills/bpmax-dataset-template-editor/scripts/verify_publish_health.py +39 -0
- package/skills/bpmax-dataset-template-editor/tests/test_dataset_editor.py +373 -0
- package/skills/bpmax-e2e-flow-config-orchestrator/SKILL.md +217 -0
- package/skills/bpmax-e2e-flow-config-orchestrator/agents/openai.yaml +4 -0
- package/skills/bpmax-e2e-flow-config-orchestrator/references/orchestration-matrix.md +63 -0
- package/skills/bpmax-e2e-flow-test-operator/SKILL.md +551 -0
- package/skills/bpmax-e2e-flow-test-operator/agents/openai.yaml +5 -0
- package/skills/bpmax-e2e-flow-test-operator/profiles/negative_sale.json +97 -0
- package/skills/bpmax-e2e-flow-test-operator/profiles/negative_sale_final_v2.json +105 -0
- package/skills/bpmax-e2e-flow-test-operator/profiles/negative_sale_main.json +36 -0
- package/skills/bpmax-e2e-flow-test-operator/profiles/negative_sale_region.json +40 -0
- package/skills/bpmax-e2e-flow-test-operator/references/ai-test-suite.md +333 -0
- package/skills/bpmax-e2e-flow-test-operator/references/browser-only-checkpoints.md +41 -0
- package/skills/bpmax-e2e-flow-test-operator/references/failure-update-loop.md +17 -0
- package/skills/bpmax-e2e-flow-test-operator/references/filter-field-discovery.md +40 -0
- package/skills/bpmax-e2e-flow-test-operator/references/minimal-test-loop.md +24 -0
- package/skills/bpmax-e2e-flow-test-operator/references/negative-sale-api-matrix.md +75 -0
- package/skills/bpmax-e2e-flow-test-operator/references/profile-schema.md +109 -0
- package/skills/bpmax-e2e-flow-test-operator/references/skill-experience-coverage-matrix.md +29 -0
- package/skills/bpmax-e2e-flow-test-operator/references/stale-runtime-and-clean-sample-rules.md +54 -0
- package/skills/bpmax-e2e-flow-test-operator/references/state-schema.md +83 -0
- package/skills/bpmax-e2e-flow-test-operator/scripts/bpmax_session.py +287 -0
- package/skills/bpmax-e2e-flow-test-operator/scripts/dealer_sample_on_shelf_plan.json +59 -0
- package/skills/bpmax-e2e-flow-test-operator/scripts/dealer_sample_on_shelf_runner.py +687 -0
- package/skills/bpmax-e2e-flow-test-operator/scripts/e2e_doc.py +121 -0
- package/skills/bpmax-e2e-flow-test-operator/scripts/e2e_state.py +288 -0
- package/skills/bpmax-e2e-flow-test-operator/scripts/flow_api_matrix.py +161 -0
- package/skills/bpmax-e2e-flow-test-operator/scripts/flow_filter_fields.py +138 -0
- package/skills/bpmax-e2e-flow-test-operator/scripts/flow_form_runtime.py +396 -0
- package/skills/bpmax-e2e-flow-test-operator/scripts/flow_runner.py +341 -0
- package/skills/bpmax-e2e-flow-test-operator/scripts/flow_test_profile.py +185 -0
- package/skills/bpmax-e2e-flow-test-operator/tests/test_negative_sale_api_tools.py +138 -0
- package/skills/bpmax-feishu-chat-flow-plugin-editor/SKILL.md +69 -0
- package/skills/bpmax-feishu-chat-flow-plugin-editor/agents/openai.yaml +4 -0
- package/skills/bpmax-feishu-chat-flow-plugin-editor/references/config-checklist.md +42 -0
- package/skills/bpmax-feishu-chat-flow-plugin-editor/references/config-recipes.md +38 -0
- package/skills/bpmax-feishu-chat-flow-plugin-editor/references/config-shape.md +86 -0
- package/skills/bpmax-feishu-chat-flow-plugin-editor/references/gate-lint.md +68 -0
- package/skills/bpmax-feishu-chat-flow-plugin-editor/references/hoocoo-patterns.md +39 -0
- package/skills/bpmax-feishu-chat-flow-plugin-editor/references/runtime-behavior.md +41 -0
- package/skills/bpmax-feishu-chat-flow-plugin-editor/references/script-authoring.md +110 -0
- package/skills/bpmax-feishu-chat-flow-plugin-editor/scripts/lint_feishu_chat_plugin.py +278 -0
- package/skills/bpmax-feishu-chat-flow-plugin-editor/tests/test_lint_feishu_chat_plugin.py +203 -0
- package/skills/bpmax-filter-template-editor/SKILL.md +564 -0
- package/skills/bpmax-filter-template-editor/references/experience-coverage-matrix.md +38 -0
- package/skills/bpmax-filter-template-editor/references/filter-and-flow-binding.md +57 -0
- package/skills/bpmax-filter-template-editor/references/filter-content-schema.md +141 -0
- package/skills/bpmax-filter-template-editor/references/filter-request-shape.md +287 -0
- package/skills/bpmax-filter-template-editor/references/filter-runtime-patterns.md +115 -0
- package/skills/bpmax-filter-template-editor/references/runtime-verified-filter-page-shape.md +94 -0
- package/skills/bpmax-filter-template-editor/scripts/build_submit_payload.py +25 -0
- package/skills/bpmax-filter-template-editor/scripts/confirm_filter_template.py +22 -0
- package/skills/bpmax-filter-template-editor/scripts/export_filter_template.py +57 -0
- package/skills/bpmax-filter-template-editor/scripts/filter_template_editor_common.py +348 -0
- package/skills/bpmax-filter-template-editor/scripts/init_create_filter_template.py +8 -0
- package/skills/bpmax-filter-template-editor/scripts/lint_filter_template_semantics.py +26 -0
- package/skills/bpmax-filter-template-editor/scripts/submit_filter_template.py +62 -0
- package/skills/bpmax-filter-template-editor/tests/test_filter_template_editor.py +231 -0
- package/skills/bpmax-flow-template-editor/SKILL.md +1095 -0
- package/skills/bpmax-flow-template-editor/agents/openai.yaml +4 -0
- package/skills/bpmax-flow-template-editor/references/before-next-step-script-runtime-gotchas.md +62 -0
- package/skills/bpmax-flow-template-editor/references/config-surfaces-and-placeholders.md +270 -0
- package/skills/bpmax-flow-template-editor/references/diff-strategy.md +67 -0
- package/skills/bpmax-flow-template-editor/references/editor-runtime-vs-draft.md +25 -0
- package/skills/bpmax-flow-template-editor/references/flow-template-api-workflow.md +174 -0
- package/skills/bpmax-flow-template-editor/references/intent-model.md +117 -0
- package/skills/bpmax-flow-template-editor/references/lessons-from-price-plan-flow.md +147 -0
- package/skills/bpmax-flow-template-editor/references/local-temp-workflow.md +97 -0
- package/skills/bpmax-flow-template-editor/references/matrix-flow-form-nav-collaboration.md +168 -0
- package/skills/bpmax-flow-template-editor/references/payload-checklist.md +133 -0
- package/skills/bpmax-flow-template-editor/references/project-create-runtime-gotchas.md +106 -0
- package/skills/bpmax-flow-template-editor/references/requirement-to-node-mapping.md +149 -0
- package/skills/bpmax-flow-template-editor/references/runtime-verified-flow-detail-shape.md +41 -0
- package/skills/bpmax-flow-template-editor/references/runtime-verified-meta-fields.md +155 -0
- package/skills/bpmax-flow-template-editor/references/runtime-verified-node-fields.md +179 -0
- package/skills/bpmax-flow-template-editor/references/save-draft-request-shape.md +91 -0
- package/skills/bpmax-flow-template-editor/references/script-review-hard-rules.md +96 -0
- package/skills/bpmax-flow-template-editor/references/work-file-to-submit-mapping.md +57 -0
- package/skills/bpmax-flow-template-editor/scripts/build_submit_payload.py +69 -0
- package/skills/bpmax-flow-template-editor/scripts/confirm_flow_template.py +52 -0
- package/skills/bpmax-flow-template-editor/scripts/export_flow_template.py +114 -0
- package/skills/bpmax-flow-template-editor/scripts/flow_template_editor_common.py +1084 -0
- package/skills/bpmax-flow-template-editor/scripts/submit_flow_template.py +159 -0
- package/skills/bpmax-flow-template-editor/tests/test_flow_template_editor.py +636 -0
- package/skills/bpmax-form-template-editor/SKILL.md +1113 -0
- package/skills/bpmax-form-template-editor/agents/openai.yaml +4 -0
- package/skills/bpmax-form-template-editor/references/form-template-api-workflow.md +203 -0
- package/skills/bpmax-form-template-editor/references/local-temp-workflow.md +125 -0
- package/skills/bpmax-form-template-editor/references/payload-checklist.md +77 -0
- package/skills/bpmax-form-template-editor/references/sub-form-patterns.md +49 -0
- package/skills/bpmax-form-template-editor/scripts/build_submit_payload.py +37 -0
- package/skills/bpmax-form-template-editor/scripts/check_form_template_consistency.py +145 -0
- package/skills/bpmax-form-template-editor/scripts/confirm_form_template.py +67 -0
- package/skills/bpmax-form-template-editor/scripts/export_form_template.py +91 -0
- package/skills/bpmax-form-template-editor/scripts/form_template_editor_common.py +1762 -0
- package/skills/bpmax-form-template-editor/scripts/lint_form_template_semantics.py +30 -0
- package/skills/bpmax-form-template-editor/scripts/record_runtime_acceptance.py +67 -0
- package/skills/bpmax-form-template-editor/scripts/submit_form_template.py +163 -0
- package/skills/bpmax-form-template-editor/tests/test_form_template_editor.py +1292 -0
- package/skills/bpmax-list-template-editor/SKILL.md +478 -0
- package/skills/bpmax-list-template-editor/agents/openai.yaml +4 -0
- package/skills/bpmax-list-template-editor/references/browser-page-contract.md +81 -0
- package/skills/bpmax-list-template-editor/references/content-config-shape.md +165 -0
- package/skills/bpmax-list-template-editor/references/dataset-field-mapping.md +60 -0
- package/skills/bpmax-list-template-editor/references/list-template-api-workflow.md +108 -0
- package/skills/bpmax-list-template-editor/references/local-temp-workflow.md +102 -0
- package/skills/bpmax-list-template-editor/references/payload-checklist.md +47 -0
- package/skills/bpmax-list-template-editor/references/runtime-verified-workflow.md +147 -0
- package/skills/bpmax-list-template-editor/references/special-formats.md +411 -0
- package/skills/bpmax-list-template-editor/scripts/build_submit_payload.py +37 -0
- package/skills/bpmax-list-template-editor/scripts/confirm_list_template.py +33 -0
- package/skills/bpmax-list-template-editor/scripts/export_list_template.py +89 -0
- package/skills/bpmax-list-template-editor/scripts/fetch_data_set.py +34 -0
- package/skills/bpmax-list-template-editor/scripts/lint_list_template_semantics.py +54 -0
- package/skills/bpmax-list-template-editor/scripts/list_template_editor_common.py +955 -0
- package/skills/bpmax-list-template-editor/scripts/record_acceptance.py +55 -0
- package/skills/bpmax-list-template-editor/scripts/submit_list_template.py +117 -0
- package/skills/bpmax-list-template-editor/tests/test_list_template_editor_common.py +441 -0
- package/skills/bpmax-memory-protocol/SKILL.md +72 -0
- package/skills/bpmax-nav-config-editor/SKILL.md +350 -0
- package/skills/bpmax-nav-config-editor/agents/openai.yaml +4 -0
- package/skills/bpmax-nav-config-editor/references/api-workflow.md +70 -0
- package/skills/bpmax-nav-config-editor/references/config-shape.md +78 -0
- package/skills/bpmax-nav-config-editor/references/icon-selection.md +83 -0
- package/skills/bpmax-nav-config-editor/references/path-mapping-rules.md +51 -0
- package/skills/bpmax-nav-config-editor/references/payload-checklist.md +41 -0
- package/skills/bpmax-nav-config-editor/references/runtime-probing.md +47 -0
- package/skills/bpmax-nav-config-editor/scripts/build_submit_payload.py +34 -0
- package/skills/bpmax-nav-config-editor/scripts/confirm_nav_config.py +32 -0
- package/skills/bpmax-nav-config-editor/scripts/export_nav_config.py +56 -0
- package/skills/bpmax-nav-config-editor/scripts/lint_nav_config_semantics.py +33 -0
- package/skills/bpmax-nav-config-editor/scripts/nav_config_editor_common.py +812 -0
- package/skills/bpmax-nav-config-editor/scripts/submit_nav_config.py +44 -0
- package/skills/bpmax-nav-config-editor/scripts/verify_nav_config.py +33 -0
- package/skills/bpmax-nav-config-editor/tests/test_nav_config_editor.py +358 -0
- package/skills/bpmax-nav-config-editor/tests/test_nav_config_editor_common.py +138 -0
- package/skills/bpmax-nav-config-editor/tests/test_nav_config_lint.py +58 -0
- package/skills/bpmax-nav-config-editor/tests/test_nav_config_submit_verify.py +51 -0
- package/skills/bpmax-plugin-config/SKILL.md +42 -0
- package/skills/bpmax-project/SKILL.md +17 -3
- package/skills/bpmax-project-detail-template-editor/SKILL.md +355 -0
- package/skills/bpmax-project-detail-template-editor/agents/openai.yaml +4 -0
- package/skills/bpmax-project-detail-template-editor/references/local-temp-workflow.md +59 -0
- package/skills/bpmax-project-detail-template-editor/references/module-catalog-and-config-notes.md +120 -0
- package/skills/bpmax-project-detail-template-editor/references/payload-checklist.md +33 -0
- package/skills/bpmax-project-detail-template-editor/references/project-detail-template-api-workflow.md +44 -0
- package/skills/bpmax-project-detail-template-editor/scripts/build_submit_payload.py +30 -0
- package/skills/bpmax-project-detail-template-editor/scripts/confirm_project_detail_template.py +33 -0
- package/skills/bpmax-project-detail-template-editor/scripts/export_project_detail_template.py +87 -0
- package/skills/bpmax-project-detail-template-editor/scripts/lint_project_detail_template_semantics.py +37 -0
- package/skills/bpmax-project-detail-template-editor/scripts/project_detail_template_editor_common.py +507 -0
- package/skills/bpmax-project-detail-template-editor/scripts/submit_project_detail_template.py +120 -0
- package/skills/bpmax-project-detail-template-editor/tests/test_project_detail_template_editor.py +369 -0
- package/skills/bpmax-role-editor/SKILL.md +251 -0
- package/skills/bpmax-role-editor/references/api-workflow.md +30 -0
- package/skills/bpmax-role-editor/references/runtime-page-shape.md +18 -0
- package/skills/bpmax-role-editor/references/work-file-mapping.md +32 -0
- package/skills/bpmax-role-editor/scripts/build_submit_payload.py +38 -0
- package/skills/bpmax-role-editor/scripts/confirm_role.py +33 -0
- package/skills/bpmax-role-editor/scripts/export_role.py +163 -0
- package/skills/bpmax-role-editor/scripts/lint_role_semantics.py +38 -0
- package/skills/bpmax-role-editor/scripts/role_editor_common.py +1231 -0
- package/skills/bpmax-role-editor/scripts/submit_role.py +144 -0
- package/skills/bpmax-role-editor/tests/test_role_editor.py +343 -0
- package/skills/bpmax-shared/SKILL.md +1 -1
- package/skills/bpmax-user-mock-operator/SKILL.md +106 -0
- package/skills/bpmax-user-mock-operator/agents/openai.yaml +4 -0
- package/skills/bpmax-user-mock-operator/scripts/switch_user_identity.py +37 -0
- package/skills/bpmax-user-mock-operator/scripts/user_mock_operator_common.py +136 -0
- package/skills/bpmax-user-mock-operator/tests/test_user_mock_operator.py +138 -0
- package/skills/bpmax-workspace-editor/SKILL.md +78 -0
- package/skills/bpmax-workspace-editor/agents/openai.yaml +4 -0
- package/skills/form-control-library/SKILL.md +82 -0
- package/skills/form-control-library/agents/openai.yaml +4 -0
- package/skills/form-control-library/references/form-controls.md +199 -0
- package/skills/form-control-library/references/form-template-submit-schema.md +180 -0
- package/skills/form-control-library/references/group-select-runtime.md +191 -0
- package/skills/form-control-library/scripts/rebuild_form_control_library.py +55 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
print(
|
|
7
|
+
"Legacy config submit scripts are disabled in bpmax-cli. Use `bpmax-cli config role submit` so capability, dry-run, confirmation, audit, and baseline checks are enforced.",
|
|
8
|
+
file=sys.stderr,
|
|
9
|
+
)
|
|
10
|
+
sys.exit(2)
|
|
11
|
+
|
|
12
|
+
import argparse
|
|
13
|
+
|
|
14
|
+
from role_editor_common import (
|
|
15
|
+
build_acceptance_urls,
|
|
16
|
+
build_client,
|
|
17
|
+
build_drift_report,
|
|
18
|
+
dump_json,
|
|
19
|
+
ensure_submission_allowed,
|
|
20
|
+
load_json,
|
|
21
|
+
paths_for,
|
|
22
|
+
record_submission_meta,
|
|
23
|
+
summarize_verification,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
28
|
+
parser = argparse.ArgumentParser(description="Submit BPMAX role payload and verify readback.")
|
|
29
|
+
parser.add_argument("--stem", required=True)
|
|
30
|
+
parser.add_argument("--workspace")
|
|
31
|
+
parser.add_argument("--base-url")
|
|
32
|
+
parser.add_argument("--language", default="zhCN")
|
|
33
|
+
parser.add_argument("--cookie-header")
|
|
34
|
+
parser.add_argument("--timeout", type=float, default=30)
|
|
35
|
+
parser.add_argument("--insecure", action="store_true")
|
|
36
|
+
return parser
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _resolve_role_id(meta: dict, response: dict, submit_payload: dict, client) -> int:
|
|
40
|
+
role_id = meta.get("roleId")
|
|
41
|
+
if isinstance(role_id, int):
|
|
42
|
+
return role_id
|
|
43
|
+
body = response.get("data")
|
|
44
|
+
if isinstance(body, dict):
|
|
45
|
+
if isinstance(body.get("id"), int):
|
|
46
|
+
return body["id"]
|
|
47
|
+
if isinstance(body.get("role_id"), int):
|
|
48
|
+
return body["role_id"]
|
|
49
|
+
if isinstance(body.get("id"), str) and body["id"].isdigit():
|
|
50
|
+
return int(body["id"])
|
|
51
|
+
if isinstance(body.get("role_id"), str) and body["role_id"].isdigit():
|
|
52
|
+
return int(body["role_id"])
|
|
53
|
+
expected_key = submit_payload["role"]["body"]["key"]
|
|
54
|
+
for item in client.get_role_list(page_size=1000):
|
|
55
|
+
if item.get("key") == expected_key and isinstance(item.get("id"), int):
|
|
56
|
+
return item["id"]
|
|
57
|
+
raise SystemExit(f"unable to resolve role id from response or role list for key {expected_key}")
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def _find_role_by_key(client, role_id: int, role_key: str) -> dict:
|
|
61
|
+
if role_id:
|
|
62
|
+
try:
|
|
63
|
+
return client.get_role(role_id)
|
|
64
|
+
except SystemExit:
|
|
65
|
+
pass
|
|
66
|
+
for item in client.get_role_list(page_size=1000):
|
|
67
|
+
if item.get("key") == role_key:
|
|
68
|
+
return item
|
|
69
|
+
raise SystemExit(f"unable to locate role readback for key={role_key}")
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def main() -> int:
|
|
73
|
+
args = build_parser().parse_args()
|
|
74
|
+
client = build_client(args)
|
|
75
|
+
paths = paths_for(args.stem)
|
|
76
|
+
meta = ensure_submission_allowed(paths["meta"], paths["work"], paths["submit"], paths["raw"], paths["lint"])
|
|
77
|
+
submit_payload = load_json(paths["submit"])
|
|
78
|
+
responses = {"pointOps": [], "role": None, "memberOps": []}
|
|
79
|
+
|
|
80
|
+
for op in submit_payload.get("pointOps", []):
|
|
81
|
+
if op["method"] == "DELETE":
|
|
82
|
+
responses["pointOps"].append(client.delete_point(op["id"]))
|
|
83
|
+
elif op["method"] == "PUT":
|
|
84
|
+
responses["pointOps"].append(client.update_point(op["id"], op["body"]))
|
|
85
|
+
elif op["method"] == "POST":
|
|
86
|
+
responses["pointOps"].append(client.create_point(op["body"]))
|
|
87
|
+
else:
|
|
88
|
+
raise SystemExit(f"unsupported point op method: {op['method']}")
|
|
89
|
+
|
|
90
|
+
role_op = submit_payload["role"]
|
|
91
|
+
if role_op["method"] == "POST":
|
|
92
|
+
responses["role"] = client.create_role(role_op["body"])
|
|
93
|
+
elif role_op["method"] == "PUT":
|
|
94
|
+
role_id = meta.get("roleId")
|
|
95
|
+
if not isinstance(role_id, int):
|
|
96
|
+
raise SystemExit("edit submission requires roleId in meta")
|
|
97
|
+
responses["role"] = client.update_role(role_id, role_op["body"])
|
|
98
|
+
else:
|
|
99
|
+
raise SystemExit(f"unsupported role method: {role_op['method']}")
|
|
100
|
+
|
|
101
|
+
role_id = _resolve_role_id(meta, responses["role"], submit_payload, client)
|
|
102
|
+
for op in submit_payload.get("memberOps", []):
|
|
103
|
+
if op["method"] == "POST":
|
|
104
|
+
responses["memberOps"].append(client.add_member(role_id, op["userId"]))
|
|
105
|
+
elif op["method"] == "DELETE":
|
|
106
|
+
responses["memberOps"].append(client.delete_member(op["user_role_id"]))
|
|
107
|
+
else:
|
|
108
|
+
raise SystemExit(f"unsupported member op method: {op['method']}")
|
|
109
|
+
|
|
110
|
+
role_readback = _find_role_by_key(client, role_id, submit_payload["role"]["body"]["key"])
|
|
111
|
+
point_readback = client.get_point_list() if submit_payload.get("pointOps") else []
|
|
112
|
+
member_readback = client.get_member_list(role_id) if submit_payload.get("memberOps") else []
|
|
113
|
+
acceptance_urls = build_acceptance_urls(base_url=client.base_url, workspace=client.workspace)
|
|
114
|
+
verify = summarize_verification(
|
|
115
|
+
submit_payload,
|
|
116
|
+
role_readback,
|
|
117
|
+
point_readback=point_readback,
|
|
118
|
+
member_readback=member_readback,
|
|
119
|
+
)
|
|
120
|
+
verify["acceptanceUrls"] = acceptance_urls
|
|
121
|
+
drift = build_drift_report(
|
|
122
|
+
submit_payload,
|
|
123
|
+
role_readback,
|
|
124
|
+
point_readback=point_readback,
|
|
125
|
+
member_readback=member_readback,
|
|
126
|
+
)
|
|
127
|
+
response_output = {"responses": responses, "roleId": role_id, "acceptanceUrls": acceptance_urls}
|
|
128
|
+
readback_output = {"role": role_readback, "points": point_readback, "members": member_readback}
|
|
129
|
+
dump_json(paths["response"], response_output)
|
|
130
|
+
dump_json(paths["readback"], readback_output)
|
|
131
|
+
dump_json(paths["verify"], verify)
|
|
132
|
+
dump_json(paths["drift"], drift)
|
|
133
|
+
record_submission_meta(paths["meta"], stem=args.stem, role_id=role_id, acceptance_urls=acceptance_urls)
|
|
134
|
+
print(paths["response"])
|
|
135
|
+
print(paths["readback"])
|
|
136
|
+
print(paths["verify"])
|
|
137
|
+
print(paths["drift"])
|
|
138
|
+
if not verify["ok"]:
|
|
139
|
+
raise SystemExit("role readback verification failed; inspect verify.json for mismatches")
|
|
140
|
+
return 0
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
if __name__ == "__main__":
|
|
144
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import os
|
|
3
|
+
import sys
|
|
4
|
+
import tempfile
|
|
5
|
+
import unittest
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from unittest import mock
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
SCRIPT_DIR = Path(__file__).resolve().parents[1] / "scripts"
|
|
11
|
+
if str(SCRIPT_DIR) not in sys.path:
|
|
12
|
+
sys.path.insert(0, str(SCRIPT_DIR))
|
|
13
|
+
|
|
14
|
+
from role_editor_common import ( # noqa: E402
|
|
15
|
+
DEFAULT_BASE_URL,
|
|
16
|
+
build_client,
|
|
17
|
+
build_create_work_payload,
|
|
18
|
+
build_submit_payload,
|
|
19
|
+
detail_to_work_payload,
|
|
20
|
+
ensure_build_allowed,
|
|
21
|
+
ensure_lint_allowed,
|
|
22
|
+
ensure_submission_allowed,
|
|
23
|
+
lint_work_payload,
|
|
24
|
+
load_json,
|
|
25
|
+
summarize_verification,
|
|
26
|
+
update_build_meta,
|
|
27
|
+
update_confirmation_state,
|
|
28
|
+
update_lint_meta,
|
|
29
|
+
)
|
|
30
|
+
from submit_role import _resolve_role_id # noqa: E402
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def make_role_detail() -> dict:
|
|
34
|
+
return {
|
|
35
|
+
"id": 895023449,
|
|
36
|
+
"name": "零售经理",
|
|
37
|
+
"key": "lingshou",
|
|
38
|
+
"permissions": {
|
|
39
|
+
"system": ["admin.project.list.my", "project.list.my", "ALL"],
|
|
40
|
+
"custom": ["point.alpha"],
|
|
41
|
+
"flow": {"flow956693507:": ["admin.project.list.my"], "default:demo_flow": ["project.list.my"]},
|
|
42
|
+
"workspace": {
|
|
43
|
+
"store_mgr": {
|
|
44
|
+
"system": ["organization.admin"],
|
|
45
|
+
"custom": ["point.beta"],
|
|
46
|
+
"flow": {"flow956693507:": ["project.list.my"]},
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
"intro": "零售经理",
|
|
51
|
+
"visible_scope": {"value": "team.all", "config": {"role": [], "user": [], "group": []}},
|
|
52
|
+
"guid": "019dc075-49b2-7995-b419-83b2438a7b9d",
|
|
53
|
+
"user_count": 16,
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def make_points() -> list[dict]:
|
|
58
|
+
return [
|
|
59
|
+
{"id": 11, "point": "point.alpha", "name": "权限A", "desc": "A", "category": "分类,操作"},
|
|
60
|
+
{"id": 12, "point": "point.beta", "name": "权限B", "desc": "B", "category": "分类,操作"},
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def make_members() -> list[dict]:
|
|
65
|
+
return [
|
|
66
|
+
{"id": 1001, "user_role_id": 9001, "name": "成员甲", "email": "a@example.com", "status": 0},
|
|
67
|
+
{"id": 1002, "user_role_id": 9002, "name": "成员乙", "email": "b@example.com", "status": 0},
|
|
68
|
+
]
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
class RoleEditorCommonTests(unittest.TestCase):
|
|
72
|
+
def test_detail_to_work_payload_normalizes_role_shape(self) -> None:
|
|
73
|
+
work = detail_to_work_payload(
|
|
74
|
+
make_role_detail(),
|
|
75
|
+
workspace="store_mgr",
|
|
76
|
+
point_details=make_points(),
|
|
77
|
+
member_details=make_members(),
|
|
78
|
+
role_list=[make_role_detail()],
|
|
79
|
+
workspace_list=[{"id": 1, "name": "门店", "key": "store_mgr"}],
|
|
80
|
+
flow_details=[{"id": 1, "name": "流程1", "flow_type": "flow956693507", "key": ""}],
|
|
81
|
+
mode="edit",
|
|
82
|
+
)
|
|
83
|
+
self.assertEqual(work["id"], 895023449)
|
|
84
|
+
self.assertEqual(work["basic"]["key"], "lingshou")
|
|
85
|
+
self.assertEqual(work["visibleScope"]["mode"], "all")
|
|
86
|
+
self.assertEqual(work["permissions"]["workspace"]["store_mgr"]["custom"], ["point.beta"])
|
|
87
|
+
self.assertEqual(len(work["preserve"]["availablePoints"]), 2)
|
|
88
|
+
|
|
89
|
+
def test_build_create_work_payload_uses_default_permission_skeleton(self) -> None:
|
|
90
|
+
work = build_create_work_payload(
|
|
91
|
+
workspace="store_mgr",
|
|
92
|
+
name="新角色",
|
|
93
|
+
key="new_role",
|
|
94
|
+
intro="说明",
|
|
95
|
+
point_details=make_points(),
|
|
96
|
+
role_list=[make_role_detail()],
|
|
97
|
+
workspace_list=[{"id": 1, "name": "门店", "key": "store_mgr"}],
|
|
98
|
+
)
|
|
99
|
+
self.assertIsNone(work["id"])
|
|
100
|
+
self.assertEqual(work["mode"], "create")
|
|
101
|
+
self.assertEqual(work["permissions"], {"system": [], "custom": [], "flow": {}, "workspace": {}})
|
|
102
|
+
self.assertEqual(work["visibleScope"]["mode"], "self")
|
|
103
|
+
self.assertEqual(len(work["preserve"]["availablePoints"]), 2)
|
|
104
|
+
self.assertEqual(work["preserve"]["availableWorkspaces"][0]["key"], "store_mgr")
|
|
105
|
+
|
|
106
|
+
def test_build_submit_payload_creates_multi_step_plan(self) -> None:
|
|
107
|
+
work = detail_to_work_payload(make_role_detail(), workspace="store_mgr", mode="edit")
|
|
108
|
+
work["customPoints"]["deletes"] = [12]
|
|
109
|
+
work["customPoints"]["upserts"] = [
|
|
110
|
+
{
|
|
111
|
+
"point": "point.gamma",
|
|
112
|
+
"name": "权限C",
|
|
113
|
+
"desc": "C",
|
|
114
|
+
"category": "分类",
|
|
115
|
+
"operation": "操作",
|
|
116
|
+
}
|
|
117
|
+
]
|
|
118
|
+
work["members"]["addUserIds"] = [1003]
|
|
119
|
+
work["members"]["removeUserRoleIds"] = [9002]
|
|
120
|
+
submit = build_submit_payload(work)
|
|
121
|
+
self.assertEqual(submit["role"]["method"], "PUT")
|
|
122
|
+
self.assertEqual(submit["pointOps"][0]["method"], "DELETE")
|
|
123
|
+
self.assertEqual(submit["pointOps"][1]["method"], "POST")
|
|
124
|
+
self.assertEqual(submit["memberOps"][0]["method"], "POST")
|
|
125
|
+
self.assertEqual(submit["memberOps"][1]["method"], "DELETE")
|
|
126
|
+
|
|
127
|
+
def test_default_base_url_is_empty_until_runtime_configured(self) -> None:
|
|
128
|
+
self.assertEqual(DEFAULT_BASE_URL, "")
|
|
129
|
+
|
|
130
|
+
def test_build_client_uses_environment_origin_without_api_suffix(self) -> None:
|
|
131
|
+
args = type(
|
|
132
|
+
"Args",
|
|
133
|
+
(),
|
|
134
|
+
{
|
|
135
|
+
"base_url": None,
|
|
136
|
+
"workspace": "store_mgr",
|
|
137
|
+
"language": "zhCN",
|
|
138
|
+
"cookie_header": "token=demo",
|
|
139
|
+
"timeout": 30,
|
|
140
|
+
"insecure": False,
|
|
141
|
+
},
|
|
142
|
+
)()
|
|
143
|
+
with mock.patch.dict(os.environ, {"BPMAX_BASE_URL": "https://bpmax.example.com/api/"}, clear=False):
|
|
144
|
+
client = build_client(args)
|
|
145
|
+
self.assertEqual(
|
|
146
|
+
client._build_url("/role?page=1"),
|
|
147
|
+
"https://bpmax.example.com/api/role?page=1&$workspace=store_mgr&$language=zhCN",
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
def test_resolve_role_id_falls_back_to_role_list_by_key(self) -> None:
|
|
151
|
+
client = mock.Mock()
|
|
152
|
+
client.get_role_list.return_value = [{"id": 9988, "key": "new_role"}]
|
|
153
|
+
role_id = _resolve_role_id(
|
|
154
|
+
{"roleId": None},
|
|
155
|
+
{"data": {"ok": True}},
|
|
156
|
+
{"role": {"body": {"key": "new_role"}}},
|
|
157
|
+
client,
|
|
158
|
+
)
|
|
159
|
+
self.assertEqual(role_id, 9988)
|
|
160
|
+
|
|
161
|
+
def test_lint_blocks_empty_custom_visibility_selection(self) -> None:
|
|
162
|
+
work = detail_to_work_payload(make_role_detail(), workspace="store_mgr", mode="edit")
|
|
163
|
+
work["visibleScope"] = {"mode": "custom", "config": {"user": [], "group": [], "role": []}}
|
|
164
|
+
report = lint_work_payload(work, raw_payload={"preserve": {"availablePoints": make_points()}})
|
|
165
|
+
self.assertFalse(report["ok"])
|
|
166
|
+
self.assertTrue(any("visibleScope.mode=custom" in error for error in report["errors"]))
|
|
167
|
+
|
|
168
|
+
def test_lint_blocks_deleting_still_referenced_custom_point(self) -> None:
|
|
169
|
+
work = detail_to_work_payload(make_role_detail(), workspace="store_mgr", mode="edit")
|
|
170
|
+
work["customPoints"]["deletes"] = [11]
|
|
171
|
+
report = lint_work_payload(work, raw_payload={"preserve": {"availablePoints": make_points()}})
|
|
172
|
+
self.assertFalse(report["ok"])
|
|
173
|
+
self.assertTrue(any("permissions.custom" in error for error in report["errors"]))
|
|
174
|
+
|
|
175
|
+
def test_lint_blocks_invalid_flow_key(self) -> None:
|
|
176
|
+
work = detail_to_work_payload(make_role_detail(), workspace="store_mgr", mode="edit")
|
|
177
|
+
work["permissions"]["flow"] = {"bad-key": ["project.list.my"]}
|
|
178
|
+
report = lint_work_payload(work)
|
|
179
|
+
self.assertFalse(report["ok"])
|
|
180
|
+
self.assertTrue(any("invalid flow permission key" in error for error in report["errors"]))
|
|
181
|
+
|
|
182
|
+
def test_lint_blocks_duplicate_and_overlapping_member_deltas(self) -> None:
|
|
183
|
+
work = detail_to_work_payload(make_role_detail(), workspace="store_mgr", mode="edit")
|
|
184
|
+
work["members"]["addUserIds"] = [1001, 1001, 9002]
|
|
185
|
+
work["members"]["removeUserRoleIds"] = [9002]
|
|
186
|
+
report = lint_work_payload(work)
|
|
187
|
+
self.assertFalse(report["ok"])
|
|
188
|
+
self.assertTrue(any("duplicate ids" in error or "cannot overlap" in error for error in report["errors"]))
|
|
189
|
+
|
|
190
|
+
def test_build_requires_work_confirmation(self) -> None:
|
|
191
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
192
|
+
root = Path(tmpdir)
|
|
193
|
+
meta_path = root / "meta.json"
|
|
194
|
+
work_path = root / "work.json"
|
|
195
|
+
work = detail_to_work_payload(make_role_detail(), workspace="store_mgr", mode="edit")
|
|
196
|
+
work_path.write_text(json.dumps(work, ensure_ascii=False), encoding="utf-8")
|
|
197
|
+
meta_path.write_text(
|
|
198
|
+
json.dumps({"stem": "895023449", "status": "exported", "workSha256": "old"}, ensure_ascii=False),
|
|
199
|
+
encoding="utf-8",
|
|
200
|
+
)
|
|
201
|
+
with self.assertRaises(SystemExit):
|
|
202
|
+
ensure_build_allowed(meta_path, work_path)
|
|
203
|
+
|
|
204
|
+
def test_submit_requires_submit_confirmation(self) -> None:
|
|
205
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
206
|
+
root = Path(tmpdir)
|
|
207
|
+
raw_path = root / "raw.json"
|
|
208
|
+
work_path = root / "work.json"
|
|
209
|
+
submit_path = root / "submit.json"
|
|
210
|
+
lint_path = root / "lint.json"
|
|
211
|
+
meta_path = root / "meta.json"
|
|
212
|
+
work = detail_to_work_payload(make_role_detail(), workspace="store_mgr", mode="edit")
|
|
213
|
+
submit = build_submit_payload(work)
|
|
214
|
+
lint = lint_work_payload(work, raw_payload={"preserve": {"availablePoints": make_points()}})
|
|
215
|
+
raw_path.write_text(json.dumps({"preserve": {"availablePoints": make_points()}}, ensure_ascii=False), encoding="utf-8")
|
|
216
|
+
work_path.write_text(json.dumps(work, ensure_ascii=False), encoding="utf-8")
|
|
217
|
+
submit_path.write_text(json.dumps(submit, ensure_ascii=False), encoding="utf-8")
|
|
218
|
+
lint_path.write_text(json.dumps(lint, ensure_ascii=False), encoding="utf-8")
|
|
219
|
+
meta_path.write_text(
|
|
220
|
+
json.dumps(
|
|
221
|
+
{
|
|
222
|
+
"stem": "895023449",
|
|
223
|
+
"mode": "edit",
|
|
224
|
+
"workspace": "store_mgr",
|
|
225
|
+
"workSha256": __import__("hashlib").sha256(work_path.read_bytes()).hexdigest(),
|
|
226
|
+
"submitSha256": __import__("hashlib").sha256(submit_path.read_bytes()).hexdigest(),
|
|
227
|
+
"workConfirmedAt": "2026-04-21T00:00:00+00:00",
|
|
228
|
+
"lintCheckedAt": "2026-04-21T00:00:30+00:00",
|
|
229
|
+
"lintOk": True,
|
|
230
|
+
"lintWorkSha256": __import__("hashlib").sha256(work_path.read_bytes()).hexdigest(),
|
|
231
|
+
"lintSubmitSha256": __import__("hashlib").sha256(submit_path.read_bytes()).hexdigest(),
|
|
232
|
+
"status": "lint_passed",
|
|
233
|
+
},
|
|
234
|
+
ensure_ascii=False,
|
|
235
|
+
),
|
|
236
|
+
encoding="utf-8",
|
|
237
|
+
)
|
|
238
|
+
with self.assertRaises(SystemExit):
|
|
239
|
+
ensure_submission_allowed(meta_path, work_path, submit_path, raw_path, lint_path)
|
|
240
|
+
|
|
241
|
+
def test_build_meta_invalidates_old_confirmation_after_work_change(self) -> None:
|
|
242
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
243
|
+
root = Path(tmpdir)
|
|
244
|
+
meta_path = root / "meta.json"
|
|
245
|
+
work_path = root / "work.json"
|
|
246
|
+
submit_path = root / "submit.json"
|
|
247
|
+
work_path.write_text(json.dumps({"name": "v1"}, ensure_ascii=False), encoding="utf-8")
|
|
248
|
+
submit_path.write_text(json.dumps({"name": "s1"}, ensure_ascii=False), encoding="utf-8")
|
|
249
|
+
meta_path.write_text(
|
|
250
|
+
json.dumps(
|
|
251
|
+
{
|
|
252
|
+
"stem": "895023449",
|
|
253
|
+
"mode": "edit",
|
|
254
|
+
"workspace": "store_mgr",
|
|
255
|
+
"workSha256": "old",
|
|
256
|
+
"status": "submit_confirmed",
|
|
257
|
+
"workConfirmedAt": "2026-04-21T00:00:00+00:00",
|
|
258
|
+
"submitConfirmedAt": "2026-04-21T00:01:00+00:00",
|
|
259
|
+
},
|
|
260
|
+
ensure_ascii=False,
|
|
261
|
+
),
|
|
262
|
+
encoding="utf-8",
|
|
263
|
+
)
|
|
264
|
+
update_build_meta(meta_path, stem="895023449", work_path=work_path, submit_path=submit_path)
|
|
265
|
+
meta = load_json(meta_path)
|
|
266
|
+
self.assertIsNone(meta["workConfirmedAt"])
|
|
267
|
+
self.assertIsNone(meta["submitConfirmedAt"])
|
|
268
|
+
self.assertEqual(meta["status"], "submit_built")
|
|
269
|
+
|
|
270
|
+
def test_two_stage_confirmation_flow(self) -> None:
|
|
271
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
272
|
+
root = Path(tmpdir)
|
|
273
|
+
meta_path = root / "meta.json"
|
|
274
|
+
work_path = root / "work.json"
|
|
275
|
+
submit_path = root / "submit.json"
|
|
276
|
+
lint_path = root / "lint.json"
|
|
277
|
+
work = detail_to_work_payload(make_role_detail(), workspace="store_mgr", mode="edit")
|
|
278
|
+
submit = build_submit_payload(work)
|
|
279
|
+
lint = lint_work_payload(work, raw_payload={"preserve": {"availablePoints": make_points()}})
|
|
280
|
+
work_path.write_text(json.dumps(work, ensure_ascii=False), encoding="utf-8")
|
|
281
|
+
submit_path.write_text(json.dumps(submit, ensure_ascii=False), encoding="utf-8")
|
|
282
|
+
lint_path.write_text(json.dumps(lint, ensure_ascii=False), encoding="utf-8")
|
|
283
|
+
update_confirmation_state(meta_path, stem="895023449", actor="tester", stage="work", work_path=work_path)
|
|
284
|
+
update_build_meta(meta_path, stem="895023449", work_path=work_path, submit_path=submit_path)
|
|
285
|
+
ensure_lint_allowed(meta_path, work_path, submit_path)
|
|
286
|
+
update_lint_meta(
|
|
287
|
+
meta_path,
|
|
288
|
+
stem="895023449",
|
|
289
|
+
work_path=work_path,
|
|
290
|
+
submit_path=submit_path,
|
|
291
|
+
lint_path=lint_path,
|
|
292
|
+
lint_report=lint,
|
|
293
|
+
)
|
|
294
|
+
update_confirmation_state(
|
|
295
|
+
meta_path,
|
|
296
|
+
stem="895023449",
|
|
297
|
+
actor="tester",
|
|
298
|
+
stage="submit",
|
|
299
|
+
work_path=work_path,
|
|
300
|
+
submit_path=submit_path,
|
|
301
|
+
)
|
|
302
|
+
meta = load_json(meta_path)
|
|
303
|
+
self.assertEqual(meta["status"], "submit_confirmed")
|
|
304
|
+
self.assertEqual(meta["submitConfirmedBy"], "tester")
|
|
305
|
+
|
|
306
|
+
def test_verification_detects_member_and_point_drift(self) -> None:
|
|
307
|
+
work = detail_to_work_payload(make_role_detail(), workspace="store_mgr", mode="edit")
|
|
308
|
+
work["customPoints"]["upserts"] = [{"point": "point.gamma", "name": "权限C", "desc": "", "category": "分类", "operation": "操作"}]
|
|
309
|
+
work["members"]["addUserIds"] = [1003]
|
|
310
|
+
submit = build_submit_payload(work)
|
|
311
|
+
verify = summarize_verification(
|
|
312
|
+
submit,
|
|
313
|
+
make_role_detail(),
|
|
314
|
+
point_readback=make_points(),
|
|
315
|
+
member_readback=make_members(),
|
|
316
|
+
)
|
|
317
|
+
self.assertFalse(verify["ok"])
|
|
318
|
+
self.assertFalse(verify["checks"]["customPoints"]["match"])
|
|
319
|
+
self.assertFalse(verify["checks"]["members"]["match"])
|
|
320
|
+
|
|
321
|
+
def test_verification_detects_point_category_drift(self) -> None:
|
|
322
|
+
work = detail_to_work_payload(make_role_detail(), workspace="store_mgr", mode="edit")
|
|
323
|
+
work["customPoints"]["upserts"] = [
|
|
324
|
+
{
|
|
325
|
+
"point": "point.alpha",
|
|
326
|
+
"name": "权限A",
|
|
327
|
+
"desc": "A",
|
|
328
|
+
"category": "新分类",
|
|
329
|
+
"operation": "新操作",
|
|
330
|
+
}
|
|
331
|
+
]
|
|
332
|
+
submit = build_submit_payload(work)
|
|
333
|
+
verify = summarize_verification(
|
|
334
|
+
submit,
|
|
335
|
+
make_role_detail(),
|
|
336
|
+
point_readback=make_points(),
|
|
337
|
+
member_readback=[],
|
|
338
|
+
)
|
|
339
|
+
self.assertFalse(verify["checks"]["customPoints"]["match"])
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
if __name__ == "__main__":
|
|
343
|
+
unittest.main()
|
|
@@ -54,7 +54,7 @@ bpmax-cli auth status
|
|
|
54
54
|
- 如果当前 profile 没有可用 API Key:
|
|
55
55
|
- OpenClaw/Aily/飞书等无浏览器 Agent 场景,优先走 `bpmax-cli init --agent <agent> --channel feishu --url <BPMAX_URL> --profile-scope <TRUSTED_RUNTIME_SCOPE> --format json`
|
|
56
56
|
- Agent 多用户场景必须传 `--profile-scope <TRUSTED_RUNTIME_SCOPE>`;scope 必须来自可信 runtime metadata,不得由 LLM 猜测
|
|
57
|
-
-
|
|
57
|
+
- 本地终端场景也走 `auth login --mode device`
|
|
58
58
|
- 如果用户明确指定环境,始终显式加 `--profile <name>`
|
|
59
59
|
|
|
60
60
|
## Agent 初始化
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: "bpmax-user-mock-operator"
|
|
3
|
+
description: "用于 BPMAX 浏览器 E2E 测试中的用户身份切换。只要用户提到“浏览器 E2E 切换用户”“模拟审批人测试”“多角色页面回归”“mock 用户做页面测试”“退出模拟用户”或等价表达,就应使用这个 skill。它只复用当前浏览器登录态调用既有 `PUT /api/user/:id` mock/unmock 接口,不提供 API Key 冒充、不修改平台权限、不修改本地配置镜像。"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# BPMAX User Mock Operator
|
|
7
|
+
|
|
8
|
+
## 使用范围
|
|
9
|
+
- 本 skill 只用于“浏览器 E2E 测试中的用户身份切换”。
|
|
10
|
+
- 目标是让同一浏览器会话在完整页面链路中切到发起人、审批人、查看人等角色,验证真实 UI 可见性、按钮、表单和流转。
|
|
11
|
+
- 不用于普通 CLI API 调用身份切换,不用于 API Key impersonation,不新增 `bpmax-cli user mock` typed command。
|
|
12
|
+
- 不修改 BPMAX 平台权限、角色配置、本地 `think_*` 镜像或配置提交体。
|
|
13
|
+
|
|
14
|
+
## 何时使用
|
|
15
|
+
- E2E 场景需要用不同用户在浏览器里发起、审批、驳回、查看或验证权限。
|
|
16
|
+
- 当前浏览器已登录一个具备模拟用户权限的管理账号,需要临时 mock 到目标用户。
|
|
17
|
+
- 测试结束后需要 unmock,恢复原管理账号身份。
|
|
18
|
+
- 用户只给了姓名但没有给 `user_id` 时,先通过用户管理页或已有查询链路确认目标用户 id。
|
|
19
|
+
|
|
20
|
+
## 前置条件
|
|
21
|
+
- 浏览器里已有可用 BPMAX 登录态。
|
|
22
|
+
- 当前账号具备平台已有的用户模拟权限。
|
|
23
|
+
- 已确认 workspace、目标用户 `user_id`、目标测试角色。
|
|
24
|
+
- 默认页面为 `.../w:<workspace>/userManagement`;如果测试页不是这个路由,可以传 `--href-path` 覆盖。
|
|
25
|
+
|
|
26
|
+
## Memory 协议
|
|
27
|
+
- 开始前先调用 [$bpmax-memory-protocol](../bpmax-memory-protocol/SKILL.md),检索词至少包含:
|
|
28
|
+
- `浏览器 E2E`
|
|
29
|
+
- `模拟用户`
|
|
30
|
+
- `mock unmock`
|
|
31
|
+
- `workspace`
|
|
32
|
+
- 只有遇到稳定经验时才写回 memory,例如:
|
|
33
|
+
- 某工作区用户管理路由不是默认 `/w:<workspace>/userManagement`
|
|
34
|
+
- 某环境对 `x-href` 或 `referer` 有额外要求
|
|
35
|
+
- 某类角色切换后的页面权限验证方式
|
|
36
|
+
- 不要写入 Cookie、Authorization、API Key、手机号、验证码、密码或完整接口响应。
|
|
37
|
+
|
|
38
|
+
## 核心接口
|
|
39
|
+
- 进入模拟:`PUT /api/user/<user_id>`,body `{"mock": 1}`
|
|
40
|
+
- 退出模拟:`PUT /api/user/<user_id>`,body `{"unmock": 1}`
|
|
41
|
+
- query 需要带 `$workspace=<workspace>&$language=<language>`
|
|
42
|
+
- 请求头复用当前浏览器登录态:
|
|
43
|
+
- `Cookie`
|
|
44
|
+
- `Origin`
|
|
45
|
+
- `Referer`
|
|
46
|
+
- `x-href`
|
|
47
|
+
- `Content-Type: application/json`
|
|
48
|
+
|
|
49
|
+
## 操作命令
|
|
50
|
+
|
|
51
|
+
### 进入目标用户身份
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
PYTHON_BIN=./venv/bin/python
|
|
55
|
+
[[ -x "$PYTHON_BIN" ]] || PYTHON_BIN=./.venv/bin/python
|
|
56
|
+
[[ -x "$PYTHON_BIN" ]] || PYTHON_BIN=python3
|
|
57
|
+
|
|
58
|
+
"$PYTHON_BIN" .codex/skills/bpmax-user-mock-operator/scripts/switch_user_identity.py \
|
|
59
|
+
--action mock \
|
|
60
|
+
--user-id <target_user_id> \
|
|
61
|
+
--workspace <workspace> \
|
|
62
|
+
--base-url <bpmax_origin> \
|
|
63
|
+
--cookie-header "$BPMAX_COOKIE_HEADER"
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### 退出模拟身份
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
"$PYTHON_BIN" .codex/skills/bpmax-user-mock-operator/scripts/switch_user_identity.py \
|
|
70
|
+
--action unmock \
|
|
71
|
+
--user-id <target_user_id> \
|
|
72
|
+
--workspace <workspace> \
|
|
73
|
+
--base-url <bpmax_origin> \
|
|
74
|
+
--cookie-header "$BPMAX_COOKIE_HEADER"
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## 参数说明
|
|
78
|
+
- `--action`:只能是 `mock` 或 `unmock`。
|
|
79
|
+
- `--user-id`:目标用户 id,必须是正整数。
|
|
80
|
+
- `--workspace`:工作区 key;也可用 `BPMAX_WORKSPACE` 环境变量。
|
|
81
|
+
- `--base-url`:BPMAX 页面 origin;也可用 `BPMAX_BASE_URL` 环境变量。
|
|
82
|
+
- `--cookie-header`:当前浏览器页面有效 Cookie 串;也可用 `BPMAX_COOKIE_HEADER` 环境变量。
|
|
83
|
+
- `--href-path`:覆盖默认 `/w:<workspace>/userManagement` 的 `x-href` / `Referer` 口径。
|
|
84
|
+
- `--language`:默认 `zhCN`。
|
|
85
|
+
- `--insecure`:仅用于证书异常的临时排障。
|
|
86
|
+
|
|
87
|
+
## 浏览器 E2E 工作流
|
|
88
|
+
1. 记录原始管理账号、workspace、当前页面和目标测试角色。
|
|
89
|
+
2. 从当前浏览器页面提取 Cookie,设置 `BPMAX_COOKIE_HEADER`。
|
|
90
|
+
3. 用本 skill 执行 `mock`。
|
|
91
|
+
4. 刷新或打开待测页面,通过 `/api/user/current` 或页面头像/用户名/权限入口确认当前身份已经切到目标用户。
|
|
92
|
+
5. 在浏览器中执行该角色的真实动作:发起、填写、提交、审批、驳回、查看或权限验证。
|
|
93
|
+
6. 记录截图、项目 ID、step ID、当前角色、目标用户 id 和结论。
|
|
94
|
+
7. 执行 `unmock`,刷新页面并确认已恢复原管理账号身份。
|
|
95
|
+
|
|
96
|
+
## 硬门禁
|
|
97
|
+
- 没有确认当前浏览器身份前,不得声称该角色浏览器 E2E 已通过。
|
|
98
|
+
- 没有执行 unmock 和恢复验证前,不得结束多角色测试。
|
|
99
|
+
- 不得把 mock 后的 Cookie/API 响应用作普通 API Key 或 CLI 业务命令身份。
|
|
100
|
+
- 不得把浏览器抓包中的 Cookie 或 Authorization 写入报告、memory、AGENTS.md 或 git。
|
|
101
|
+
|
|
102
|
+
## 常见问题
|
|
103
|
+
- 401/403:先确认 Cookie 是否过期,再确认原始管理账号是否具备模拟用户权限。
|
|
104
|
+
- HTTP 200 但业务 `code` 非 0:以后端返回的 JSON 错误为准,不要继续执行页面测试。
|
|
105
|
+
- 页面身份未变化:刷新页面,或调用 `/api/user/current` 验证;仍未变化则先 unmock 再重试。
|
|
106
|
+
- 目标用户 id 不确定:先在用户管理页定位用户,不要凭姓名猜 id。
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import argparse
|
|
5
|
+
import json
|
|
6
|
+
|
|
7
|
+
from user_mock_operator_common import build_client, default_href_path
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
11
|
+
parser = argparse.ArgumentParser(
|
|
12
|
+
description="Switch a BPMAX browser E2E session into or out of simulated identity mode via /api/user/:id."
|
|
13
|
+
)
|
|
14
|
+
parser.add_argument("--action", choices=("mock", "unmock"), required=True)
|
|
15
|
+
parser.add_argument("--user-id", type=int, required=True)
|
|
16
|
+
parser.add_argument("--workspace")
|
|
17
|
+
parser.add_argument("--base-url")
|
|
18
|
+
parser.add_argument("--language", default="zhCN")
|
|
19
|
+
parser.add_argument("--cookie-header")
|
|
20
|
+
parser.add_argument("--href-path")
|
|
21
|
+
parser.add_argument("--timeout", type=float, default=30)
|
|
22
|
+
parser.add_argument("--insecure", action="store_true")
|
|
23
|
+
return parser
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def main() -> int:
|
|
27
|
+
args = build_parser().parse_args()
|
|
28
|
+
client = build_client(args)
|
|
29
|
+
workspace = args.workspace or client.workspace
|
|
30
|
+
href_path = args.href_path or default_href_path(workspace)
|
|
31
|
+
payload = client.switch_user_identity(args.user_id, args.action, href_path)
|
|
32
|
+
print(json.dumps(payload, ensure_ascii=False))
|
|
33
|
+
return 0
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
if __name__ == "__main__":
|
|
37
|
+
raise SystemExit(main())
|