bpmax-cli 0.1.43 → 0.1.44-beta.0
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 +3 -3
- package/dist/bin.js +3372 -453
- package/dist/bin.js.map +1 -1
- package/package.json +1 -1
- 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-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 +2 -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 +600 -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 +151 -0
- package/skills/bpmax-e2e-flow-config-orchestrator/agents/openai.yaml +4 -0
- package/skills/bpmax-e2e-flow-config-orchestrator/references/orchestration-matrix.md +60 -0
- package/skills/bpmax-e2e-flow-test-operator/SKILL.md +371 -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/browser-only-checkpoints.md +33 -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 +19 -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 +107 -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 +58 -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 +95 -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 +1043 -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 +159 -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 +163 -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 +54 -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 +93 -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 +1074 -0
- package/skills/bpmax-form-template-editor/agents/openai.yaml +4 -0
- package/skills/bpmax-form-template-editor/references/form-template-api-workflow.md +193 -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 +89 -0
- package/skills/bpmax-form-template-editor/scripts/form_template_editor_common.py +1745 -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 +1303 -0
- package/skills/bpmax-list-template-editor/SKILL.md +468 -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 +148 -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 +103 -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 +140 -0
- package/skills/bpmax-list-template-editor/references/special-formats.md +394 -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-nav-config-editor/SKILL.md +347 -0
- package/skills/bpmax-nav-config-editor/agents/openai.yaml +4 -0
- package/skills/bpmax-nav-config-editor/references/api-workflow.md +68 -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 +46 -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-project/SKILL.md +1 -1
- package/skills/bpmax-project-detail-template-editor/SKILL.md +329 -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 +47 -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/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,287 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
import tempfile
|
|
4
|
+
import unittest
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from unittest import mock
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
SCRIPT_DIR = Path(__file__).resolve().parents[1] / "scripts"
|
|
10
|
+
if str(SCRIPT_DIR) not in sys.path:
|
|
11
|
+
sys.path.insert(0, str(SCRIPT_DIR))
|
|
12
|
+
|
|
13
|
+
import api_platform_editor_common as common
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class ApiPlatformEditorCommonTests(unittest.TestCase):
|
|
17
|
+
def test_resolve_editor_base_url_prefers_browser_origin_before_agents_default(self) -> None:
|
|
18
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
19
|
+
agents_path = Path(tmpdir) / "AGENTS.md"
|
|
20
|
+
agents_path.write_text("BPMAX_DEFAULT_ORIGIN: https://repo.example.com\n", encoding="utf-8")
|
|
21
|
+
with mock.patch.dict(os.environ, {}, clear=True):
|
|
22
|
+
resolved = common.resolve_editor_base_url(
|
|
23
|
+
None,
|
|
24
|
+
browser_origin="https://browser.example.com/w:store_mgr/link_system",
|
|
25
|
+
env={},
|
|
26
|
+
agents_path=agents_path,
|
|
27
|
+
)
|
|
28
|
+
self.assertEqual(resolved, "https://browser.example.com")
|
|
29
|
+
|
|
30
|
+
def test_resolve_editor_base_url_uses_agents_default_when_other_inputs_missing(self) -> None:
|
|
31
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
32
|
+
agents_path = Path(tmpdir) / "AGENTS.md"
|
|
33
|
+
agents_path.write_text("DEFAULT_BPMAX_APP_ORIGIN=https://repo.example.com/\n", encoding="utf-8")
|
|
34
|
+
resolved = common.resolve_editor_base_url(None, env={}, agents_path=agents_path)
|
|
35
|
+
self.assertEqual(resolved, "https://repo.example.com")
|
|
36
|
+
|
|
37
|
+
def test_normalize_fetch_capture_extracts_primary_contract(self) -> None:
|
|
38
|
+
fetch_text = r'''
|
|
39
|
+
fetch("https://bpmax.example.com/api/api_proxy/18?$workspace=store_mgr", {
|
|
40
|
+
"headers": {
|
|
41
|
+
"accept": "application/json",
|
|
42
|
+
"content-type": "application/json",
|
|
43
|
+
"cookie": "ignored=yes"
|
|
44
|
+
},
|
|
45
|
+
"body": "{\"data\":{\"name\":\"D365接口\",\"path\":\"/crm/account\"}}",
|
|
46
|
+
"method": "PUT"
|
|
47
|
+
});
|
|
48
|
+
'''.strip()
|
|
49
|
+
|
|
50
|
+
contract = common.normalize_request_capture(fetch_text, layer="api")
|
|
51
|
+
|
|
52
|
+
self.assertEqual(contract["method"], "PUT")
|
|
53
|
+
self.assertEqual(contract["path"], "/api/api_proxy/18")
|
|
54
|
+
self.assertEqual(contract["query"]["$workspace"], "store_mgr")
|
|
55
|
+
self.assertEqual(contract["payloadPath"], ["data"])
|
|
56
|
+
self.assertEqual(contract["headers"], {"accept": "application/json", "content-type": "application/json"})
|
|
57
|
+
|
|
58
|
+
def test_normalize_har_capture_uses_preferred_binding_path(self) -> None:
|
|
59
|
+
har = {
|
|
60
|
+
"log": {
|
|
61
|
+
"entries": [
|
|
62
|
+
{
|
|
63
|
+
"request": {
|
|
64
|
+
"url": "https://bpmax.example.com/api/api_proxy/18",
|
|
65
|
+
"method": "POST",
|
|
66
|
+
"headers": [],
|
|
67
|
+
"postData": {"text": '{"name":"api"}'},
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"request": {
|
|
72
|
+
"url": (
|
|
73
|
+
"https://bpmax.example.com/api/api_proxy_entity_binding"
|
|
74
|
+
"?q_proxy_guid=proxy-guid&q_direction=response"
|
|
75
|
+
),
|
|
76
|
+
"method": "POST",
|
|
77
|
+
"headers": [{"name": "content-type", "value": "application/json"}],
|
|
78
|
+
"postData": {"text": '{"entity_id":17,"direction":"response"}'},
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
contract = common.normalize_request_capture(
|
|
86
|
+
common.json.dumps(har, ensure_ascii=False),
|
|
87
|
+
layer="api",
|
|
88
|
+
preferred_substring="/api/api_proxy_entity_binding",
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
self.assertEqual(contract["path"], "/api/api_proxy_entity_binding")
|
|
92
|
+
self.assertEqual(contract["query"]["q_proxy_guid"], "proxy-guid")
|
|
93
|
+
self.assertEqual(contract["bodyTemplate"]["entity_id"], 17)
|
|
94
|
+
|
|
95
|
+
def test_instance_export_and_build_round_trip(self) -> None:
|
|
96
|
+
detail = {
|
|
97
|
+
"id": 9,
|
|
98
|
+
"guid": "instance-guid",
|
|
99
|
+
"name": "D365测试环境",
|
|
100
|
+
"instance_key": "d365_test",
|
|
101
|
+
"env_type": "test",
|
|
102
|
+
"auth_type": "script",
|
|
103
|
+
"description": "测试环境",
|
|
104
|
+
"status": 1,
|
|
105
|
+
"api_platform_guid": "platform-guid",
|
|
106
|
+
"config_schema": {"baseUrl": "https://upstream.example.com", "timeout": 30},
|
|
107
|
+
"on_setup_script": "// setup",
|
|
108
|
+
"on_request_script": "return ctx;",
|
|
109
|
+
"on_response_script": "return res;",
|
|
110
|
+
"on_error_script": "throw err;",
|
|
111
|
+
}
|
|
112
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
113
|
+
tmp_root = Path(tmpdir)
|
|
114
|
+
with mock.patch.object(common, "TMP_ROOT", tmp_root):
|
|
115
|
+
work = common.instance_detail_to_work(detail, mode="update", stem="instance-9")
|
|
116
|
+
bundle = common.build_submit_bundle(work)
|
|
117
|
+
|
|
118
|
+
self.assertEqual(bundle["payload"]["name"], "D365测试环境")
|
|
119
|
+
self.assertEqual(bundle["payload"]["config_schema"]["baseUrl"], "https://upstream.example.com")
|
|
120
|
+
self.assertEqual(bundle["payload"]["on_request_script"], "return ctx;")
|
|
121
|
+
self.assertEqual(bundle["executionPlan"], ["instance", "readback"])
|
|
122
|
+
|
|
123
|
+
def test_api_build_requires_binding_contract_when_binding_sidecar_exists(self) -> None:
|
|
124
|
+
api_detail = {
|
|
125
|
+
"id": 18,
|
|
126
|
+
"guid": "proxy-guid",
|
|
127
|
+
"name": "D365经销商查询接口",
|
|
128
|
+
"api_key": "dealerQuery",
|
|
129
|
+
"status": 1,
|
|
130
|
+
"version": 1,
|
|
131
|
+
"method": "POST",
|
|
132
|
+
"path": "/crm/account",
|
|
133
|
+
"description": "查询经销商",
|
|
134
|
+
"api_platform_guid": "platform-guid",
|
|
135
|
+
"request_schema": {"body_params": []},
|
|
136
|
+
"response_schema": {"type": "object"},
|
|
137
|
+
"request_example": {"pageSize": 10},
|
|
138
|
+
"response_example": {"isSuccess": True},
|
|
139
|
+
}
|
|
140
|
+
binding = {"entity_id": 19, "direction": "response"}
|
|
141
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
142
|
+
tmp_root = Path(tmpdir)
|
|
143
|
+
with mock.patch.object(common, "TMP_ROOT", tmp_root):
|
|
144
|
+
work = common.api_detail_to_work(api_detail, binding=binding, mode="create", stem="create-api-18")
|
|
145
|
+
with self.assertRaises(SystemExit) as ctx:
|
|
146
|
+
common.build_submit_bundle(work, contract={"requests": {"primary": {}}})
|
|
147
|
+
self.assertIn("binding write contract", str(ctx.exception))
|
|
148
|
+
bundle = common.build_submit_bundle(work, contract={"requests": {"primary": {}, "binding": {}}})
|
|
149
|
+
|
|
150
|
+
self.assertEqual(bundle["executionPlan"], ["api_proxy", "binding", "readback"])
|
|
151
|
+
self.assertEqual(bundle["response_binding"]["entity_id"], 19)
|
|
152
|
+
|
|
153
|
+
def test_submit_api_create_executes_proxy_then_binding_then_readback(self) -> None:
|
|
154
|
+
submit_bundle = {
|
|
155
|
+
"layer": "api",
|
|
156
|
+
"mode": "create",
|
|
157
|
+
"payload": {
|
|
158
|
+
"name": "D365经销商查询接口",
|
|
159
|
+
"api_key": "dealerQuery",
|
|
160
|
+
"status": 1,
|
|
161
|
+
"version": 1,
|
|
162
|
+
"method": "POST",
|
|
163
|
+
"path": "/crm/account",
|
|
164
|
+
"description": "查询经销商",
|
|
165
|
+
"api_platform_guid": "platform-guid",
|
|
166
|
+
"request_schema": {"body_params": []},
|
|
167
|
+
"response_schema": {"type": "object"},
|
|
168
|
+
"request_example": {"pageSize": 10},
|
|
169
|
+
"response_example": {"isSuccess": True},
|
|
170
|
+
},
|
|
171
|
+
"response_binding": {"entity_id": 19, "direction": "response"},
|
|
172
|
+
"executionPlan": ["api_proxy", "binding", "readback"],
|
|
173
|
+
}
|
|
174
|
+
contract = {
|
|
175
|
+
"requests": {
|
|
176
|
+
"primary": {
|
|
177
|
+
"method": "POST",
|
|
178
|
+
"path": "/api/api_proxy",
|
|
179
|
+
"query": {},
|
|
180
|
+
"headers": {},
|
|
181
|
+
"bodyTemplate": {},
|
|
182
|
+
"bodyKind": "json",
|
|
183
|
+
"payloadPath": [],
|
|
184
|
+
},
|
|
185
|
+
"binding": {
|
|
186
|
+
"method": "POST",
|
|
187
|
+
"path": "/api/api_proxy_entity_binding",
|
|
188
|
+
"query": {},
|
|
189
|
+
"headers": {},
|
|
190
|
+
"bodyTemplate": {},
|
|
191
|
+
"bodyKind": "json",
|
|
192
|
+
"payloadPath": [],
|
|
193
|
+
},
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
class FakeClient:
|
|
198
|
+
def __init__(self) -> None:
|
|
199
|
+
self.events: list[str] = []
|
|
200
|
+
|
|
201
|
+
def call_contract(self, request_contract: dict, submit_payload: object) -> dict:
|
|
202
|
+
self.events.append(request_contract["path"])
|
|
203
|
+
if request_contract["path"] == "/api/api_proxy":
|
|
204
|
+
return {"data": {"id": 18, "guid": "proxy-guid"}}
|
|
205
|
+
return {"data": {"id": 401, "q_proxy_guid": "proxy-guid"}}
|
|
206
|
+
|
|
207
|
+
def get_api(self, api_id: object) -> dict:
|
|
208
|
+
self.events.append("GET:/api/api_proxy/18")
|
|
209
|
+
return {
|
|
210
|
+
"data": {
|
|
211
|
+
**submit_bundle["payload"],
|
|
212
|
+
"id": 18,
|
|
213
|
+
"guid": "proxy-guid",
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
def get_binding(self, proxy_guid: str, *, direction: str = "response") -> dict:
|
|
218
|
+
self.events.append("GET:/api/api_proxy_entity_binding")
|
|
219
|
+
return {"data": [{"entity_id": 19, "direction": "response", "q_proxy_guid": proxy_guid}]}
|
|
220
|
+
|
|
221
|
+
fake_client = FakeClient()
|
|
222
|
+
result = common.submit_layer(
|
|
223
|
+
fake_client, meta={"layer": "api", "remoteId": None}, contract=contract, submit_bundle=submit_bundle
|
|
224
|
+
)
|
|
225
|
+
|
|
226
|
+
self.assertEqual(
|
|
227
|
+
fake_client.events,
|
|
228
|
+
["/api/api_proxy", "/api/api_proxy_entity_binding", "GET:/api/api_proxy/18", "GET:/api/api_proxy_entity_binding"],
|
|
229
|
+
)
|
|
230
|
+
self.assertEqual(result["executionOrder"], ["api_proxy", "binding", "readback"])
|
|
231
|
+
self.assertEqual(result["status"], "runtime_pending")
|
|
232
|
+
|
|
233
|
+
def test_doc_debug_acceptance_requires_response_summary(self) -> None:
|
|
234
|
+
work = {
|
|
235
|
+
"doc_url": "https://bpmax.example.com/w:store_mgr/api-docs/system_api/18?system=dynamic",
|
|
236
|
+
"platform_key": "dynamic",
|
|
237
|
+
"api_id": 18,
|
|
238
|
+
"api_key": "dealerQuery",
|
|
239
|
+
}
|
|
240
|
+
with self.assertRaises(SystemExit) as ctx:
|
|
241
|
+
common.build_doc_debug_acceptance(
|
|
242
|
+
work=work,
|
|
243
|
+
instance_key="d365_test",
|
|
244
|
+
api_args={"pageSize": 10},
|
|
245
|
+
response_summary="",
|
|
246
|
+
matched_expected=True,
|
|
247
|
+
)
|
|
248
|
+
self.assertIn("response summary", str(ctx.exception))
|
|
249
|
+
|
|
250
|
+
def test_doc_debug_acceptance_updates_target_meta(self) -> None:
|
|
251
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
252
|
+
tmp_root = Path(tmpdir)
|
|
253
|
+
with mock.patch.object(common, "TMP_ROOT", tmp_root):
|
|
254
|
+
doc_paths = common.paths_for("doc-debug-dynamic-18")
|
|
255
|
+
target_paths = common.paths_for("api-18")
|
|
256
|
+
common.dump_json(
|
|
257
|
+
doc_paths["meta"],
|
|
258
|
+
common.ensure_meta_shape({}, stem="doc-debug-dynamic-18", layer="doc-debug", mode="update"),
|
|
259
|
+
)
|
|
260
|
+
common.dump_json(
|
|
261
|
+
target_paths["meta"],
|
|
262
|
+
common.ensure_meta_shape({}, stem="api-18", layer="api", mode="update"),
|
|
263
|
+
)
|
|
264
|
+
work = {
|
|
265
|
+
"doc_url": "https://bpmax.example.com/w:store_mgr/api-docs/system_api/18?system=dynamic",
|
|
266
|
+
"platform_key": "dynamic",
|
|
267
|
+
"api_id": 18,
|
|
268
|
+
"api_key": "dealerQuery",
|
|
269
|
+
}
|
|
270
|
+
acceptance = common.build_doc_debug_acceptance(
|
|
271
|
+
work=work,
|
|
272
|
+
instance_key="d365_test",
|
|
273
|
+
api_args={"pageSize": 10},
|
|
274
|
+
response_summary="200 + 业务成功",
|
|
275
|
+
matched_expected=True,
|
|
276
|
+
)
|
|
277
|
+
common.dump_json(doc_paths["acceptance"], acceptance)
|
|
278
|
+
common.persist_doc_debug_result(doc_paths["meta"], accepted=True, acceptance_path=doc_paths["acceptance"])
|
|
279
|
+
common.persist_doc_debug_result(target_paths["meta"], accepted=True, acceptance_path=doc_paths["acceptance"])
|
|
280
|
+
target_meta = common.load_meta(target_paths["meta"])
|
|
281
|
+
|
|
282
|
+
self.assertEqual(target_meta["status"], "completed")
|
|
283
|
+
self.assertEqual(target_meta["runtimeAcceptance"]["result"], "passed")
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
if __name__ == "__main__":
|
|
287
|
+
unittest.main()
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: bpmax-auth
|
|
3
3
|
version: 1.0.0
|
|
4
|
-
description: Use when the user needs BPMAX device authorization,
|
|
4
|
+
description: Use when the user needs BPMAX device-code authorization, API key setup, auth status checks, logout, or diagnosis around bpmax-cli authentication.
|
|
5
5
|
metadata:
|
|
6
6
|
requires:
|
|
7
7
|
bins: ["bpmax-cli"]
|
|
@@ -11,7 +11,7 @@ metadata:
|
|
|
11
11
|
# auth
|
|
12
12
|
|
|
13
13
|
> **前置条件:** 先阅读 `../bpmax-shared/SKILL.md`。
|
|
14
|
-
> **登录约束:**
|
|
14
|
+
> **登录约束:** 只使用 device-code 校对码授权;不要使用浏览器 callback flow。
|
|
15
15
|
|
|
16
16
|
## 何时使用
|
|
17
17
|
|
|
@@ -19,7 +19,7 @@ metadata:
|
|
|
19
19
|
- 用户要登录 BPMAX
|
|
20
20
|
- 用户要检查当前 API Key 是否有效
|
|
21
21
|
- 用户要清空当前环境的登录状态
|
|
22
|
-
-
|
|
22
|
+
- 用户遇到授权页、权限不足、校对码过期或 API Key 落盘问题
|
|
23
23
|
|
|
24
24
|
## 命令
|
|
25
25
|
|
|
@@ -27,7 +27,7 @@ metadata:
|
|
|
27
27
|
bpmax-cli init --agent openclaw --channel feishu --url <BPMAX_URL> --name local --profile-scope <TRUSTED_RUNTIME_SCOPE> --format json
|
|
28
28
|
bpmax-cli --config-dir <config_dir_from_init> auth device complete --profile <profile_from_init> --session <device_code> --format json
|
|
29
29
|
bpmax-cli auth login --mode device --profile local
|
|
30
|
-
bpmax-cli auth login
|
|
30
|
+
bpmax-cli auth login --mode device
|
|
31
31
|
bpmax-cli auth status
|
|
32
32
|
bpmax-cli auth logout
|
|
33
33
|
```
|
|
@@ -39,7 +39,7 @@ bpmax-cli auth logout
|
|
|
39
39
|
- 只需要发起无浏览器授权:用 `auth device start`,把返回的 `message_card.authorization_url` 和 `message_card.user_code` 发给用户
|
|
40
40
|
- 用户确认短码后:优先执行返回的 `message_card.next_command`;不要从 `next_action` 自然语言里猜命令
|
|
41
41
|
- 后续授权状态只复制 `init` 返回的 `next_commands.auth_status`;不要自行把 profile 写成 `local`,也不要漏掉 `--config-dir`
|
|
42
|
-
-
|
|
42
|
+
- 本地终端也使用 `auth login --mode device`
|
|
43
43
|
- 只想确认当前身份和连通性:`auth status`
|
|
44
44
|
- 只清空当前 profile 的本地 API Key:`auth logout`
|
|
45
45
|
|
|
@@ -61,20 +61,9 @@ bpmax-cli auth logout
|
|
|
61
61
|
- `authorization_pending` 代表用户还没确认,可稍后重试 `complete`
|
|
62
62
|
- `expired_token` 代表短码过期,应重新 `start`
|
|
63
63
|
|
|
64
|
-
## 浏览器 Callback 登录流程理解
|
|
65
|
-
|
|
66
|
-
`auth login` 的固定链路:
|
|
67
|
-
|
|
68
|
-
1. CLI 读取目标 profile 的 `origin`
|
|
69
|
-
2. CLI 启动本地一次性 `localhost` 回调服务
|
|
70
|
-
3. CLI 打开 `hpt-frontend` 的 CLI 登录桥接页
|
|
71
|
-
4. 页面复用 `huanpingtong-server` 现有 `/api/user_api_key` 机制获取或创建 `bpmax-cli` API Key
|
|
72
|
-
5. 页面通过 `POST /callback` 把 API Key 回传本地 CLI
|
|
73
|
-
6. CLI 校验 `state` 后落盘
|
|
74
|
-
|
|
75
64
|
## 常见问题
|
|
76
65
|
|
|
77
66
|
- 401/403:先检查 `origin`、`api_key`、当前 profile 是否正确
|
|
78
67
|
- 页面提示无权限:优先怀疑缺少 `user.api_key.manage`
|
|
79
|
-
-
|
|
68
|
+
- `authorization_pending`:用户还没有在授权页确认校对码,稍后重试 `auth device complete`
|
|
80
69
|
- 需要切环境登录:显式传 `--profile <name>`
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: "bpmax-builder-shared"
|
|
3
|
+
description: "BPMAX 配置类 skill 的共享规则和脚本库。用于复用配置编辑器的范围门禁、运行时脚本规则、模板脚本硬规则、base URL 处理和 skill 审计工具;不作为直接修改 BPMAX 远端配置的入口。"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# BPMAX Builder Shared
|
|
7
|
+
|
|
8
|
+
## 定位
|
|
9
|
+
|
|
10
|
+
这是 BPMAX 配置类 skill 的共享辅助库,不直接执行远端配置写入。
|
|
11
|
+
|
|
12
|
+
适用场景:
|
|
13
|
+
- 配置类 skill 需要复用 `base_url.py`、`runtime_script_rules.py`、`template_script_hard_rules.py` 或 `skill_audit.py`。
|
|
14
|
+
- 检查配置编辑器 skill 是否满足范围门禁、脚本硬规则、运行时脚本站点矩阵。
|
|
15
|
+
- 为 `bpmax-form-template-editor`、`bpmax-flow-template-editor`、`bpmax-list-template-editor`、`bpmax-filter-template-editor`、`bpmax-project-detail-template-editor`、`bpmax-console-template-editor`、`bpmax-dataset-template-editor`、`bpmax-dataset-field-template-editor`、`bpmax-api-platform-editor`、`bpmax-role-editor`、`bpmax-nav-config-editor` 提供共享参考。
|
|
16
|
+
|
|
17
|
+
## 写入路径硬约束
|
|
18
|
+
|
|
19
|
+
- 不要从本目录脚本直接调用 BPMAX 远端写接口。
|
|
20
|
+
- 所有真实配置提交必须走 `bpmax-cli config <domain> build` 和 `bpmax-cli config <domain> submit`。
|
|
21
|
+
- 不得用 `bpmax-cli api POST/PUT/PATCH/DELETE` 绕过 typed config submit。
|
|
22
|
+
- `submit` 默认 dry-run;真实提交必须带精确 `--confirm "submit <domain> <id>"`。
|
|
23
|
+
|
|
24
|
+
## 使用方式
|
|
25
|
+
|
|
26
|
+
优先在具体配置 skill 中引用本目录的脚本或规则文件,不要把本 skill 当作用户任务入口。
|
|
27
|
+
|
|
28
|
+
常用文件:
|
|
29
|
+
- `base_url.py`:统一处理 BPMAX/sysconfigdiff URL。
|
|
30
|
+
- `runtime_script_rules.py`:运行时脚本规则。
|
|
31
|
+
- `template_script_hard_rules.py`:模板脚本硬规则。
|
|
32
|
+
- `skill_audit.py`:配置类 skill 静态审计。
|
|
33
|
+
- `runtime-script-site-matrix.md`:运行时脚本站点矩阵说明。
|
|
34
|
+
- `runtime-script-template-catalog.md`:模板脚本分类参考。
|
|
35
|
+
|
|
36
|
+
## 验证
|
|
37
|
+
|
|
38
|
+
修改共享脚本后至少运行对应本地测试:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
python -m pytest skills/bpmax-builder-shared/tests
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
如果调用方 skill 也改了,再运行对应 skill 的 quick validate。
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import os
|
|
5
|
+
import re
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from typing import Mapping
|
|
8
|
+
from urllib.parse import urlparse
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
BASE_URL_ENV_VAR = "BPMAX_BASE_URL"
|
|
12
|
+
DEFAULT_BASE_URL = ""
|
|
13
|
+
REPO_ROOT = Path(__file__).resolve().parents[3]
|
|
14
|
+
DEFAULT_AGENTS_PATH = REPO_ROOT / "AGENTS.md"
|
|
15
|
+
AGENTS_CONTRACT_MARKER = "BPMAX_DEFAULT_ORIGIN_CONTRACT"
|
|
16
|
+
AGENTS_CONTRACT_PATTERN = re.compile(
|
|
17
|
+
rf"<!--\s*{AGENTS_CONTRACT_MARKER}\s*(\{{.*?\}})\s*-->",
|
|
18
|
+
re.DOTALL,
|
|
19
|
+
)
|
|
20
|
+
AGENTS_SIMPLE_PATTERN = re.compile(r"^\s*BPMAX_DEFAULT_ORIGIN:\s*(\S+)\s*$", re.MULTILINE)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def _normalize_base_url(value: str) -> str:
|
|
24
|
+
text = str(value or "").strip()
|
|
25
|
+
if not text:
|
|
26
|
+
return ""
|
|
27
|
+
text = text.rstrip("/")
|
|
28
|
+
if text.endswith("/api"):
|
|
29
|
+
text = text[:-4]
|
|
30
|
+
parsed = urlparse(text)
|
|
31
|
+
if parsed.scheme not in ("http", "https") or not parsed.netloc:
|
|
32
|
+
raise SystemExit(
|
|
33
|
+
f"invalid base url: {text!r}. Use an http(s) origin such as https://bpmax.example.com"
|
|
34
|
+
)
|
|
35
|
+
if parsed.path not in ("", "/"):
|
|
36
|
+
raise SystemExit(f"invalid base url: {text!r}. Use the app origin only, not a nested path.")
|
|
37
|
+
return f"{parsed.scheme}://{parsed.netloc}"
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def load_agents_default_origin(*, agents_path: str | Path | None = None) -> str:
|
|
41
|
+
path = DEFAULT_AGENTS_PATH if agents_path is None else Path(agents_path)
|
|
42
|
+
if not path.exists():
|
|
43
|
+
return ""
|
|
44
|
+
text = path.read_text(encoding="utf-8")
|
|
45
|
+
match = AGENTS_CONTRACT_PATTERN.search(text)
|
|
46
|
+
if match is not None:
|
|
47
|
+
try:
|
|
48
|
+
payload = json.loads(match.group(1))
|
|
49
|
+
except json.JSONDecodeError as exc:
|
|
50
|
+
raise SystemExit(f"invalid {AGENTS_CONTRACT_MARKER} JSON in {path}") from exc
|
|
51
|
+
if not isinstance(payload, dict):
|
|
52
|
+
raise SystemExit(f"invalid {AGENTS_CONTRACT_MARKER} payload in {path}")
|
|
53
|
+
resolved = _normalize_base_url(str(payload.get("default_origin") or ""))
|
|
54
|
+
if resolved:
|
|
55
|
+
return resolved
|
|
56
|
+
simple_match = AGENTS_SIMPLE_PATTERN.search(text)
|
|
57
|
+
if simple_match is not None:
|
|
58
|
+
return _normalize_base_url(simple_match.group(1))
|
|
59
|
+
return ""
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def resolve_base_url(
|
|
63
|
+
value: str | None,
|
|
64
|
+
*,
|
|
65
|
+
browser_origin: str | None = None,
|
|
66
|
+
env: Mapping[str, str] | None = None,
|
|
67
|
+
agents_path: str | Path | None = None,
|
|
68
|
+
) -> str:
|
|
69
|
+
env_map = os.environ if env is None else env
|
|
70
|
+
resolved = value if value not in (None, "") else env_map.get(BASE_URL_ENV_VAR, "")
|
|
71
|
+
if resolved in (None, ""):
|
|
72
|
+
resolved = browser_origin
|
|
73
|
+
if resolved in (None, ""):
|
|
74
|
+
resolved = load_agents_default_origin(agents_path=agents_path)
|
|
75
|
+
normalized = _normalize_base_url(resolved)
|
|
76
|
+
if normalized:
|
|
77
|
+
return normalized
|
|
78
|
+
raise SystemExit(
|
|
79
|
+
"missing BPMAX base url: pass --base-url, set BPMAX_BASE_URL, provide the current browser page origin, "
|
|
80
|
+
"or define a repo fallback in AGENTS.md"
|
|
81
|
+
)
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"sites": [
|
|
4
|
+
{
|
|
5
|
+
"site_name": "lambda",
|
|
6
|
+
"runtime_kind": "frontend_expression",
|
|
7
|
+
"supports_await": true,
|
|
8
|
+
"requires_return_wrapper": true,
|
|
9
|
+
"recommended_max_lines": 40,
|
|
10
|
+
"allowed_side_effects": ["setValue", "mergeRule", "reload"],
|
|
11
|
+
"preferred_pattern": "return (async () => { guard; normalize; fetch; apply; })();",
|
|
12
|
+
"forbidden_pattern": "flat multi-branch promise chain with top-level await or nested then",
|
|
13
|
+
"allows_promise_then": false
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"site_name": "customeValidate",
|
|
17
|
+
"runtime_kind": "frontend_validator",
|
|
18
|
+
"supports_await": true,
|
|
19
|
+
"requires_return_wrapper": true,
|
|
20
|
+
"recommended_max_lines": 40,
|
|
21
|
+
"allowed_side_effects": ["return_validation_result"],
|
|
22
|
+
"preferred_pattern": "return (async () => { guard; fetch; return message_or_empty; })();",
|
|
23
|
+
"forbidden_pattern": "field writeback, notification, or nested promise chain",
|
|
24
|
+
"allows_promise_then": false
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"site_name": "es_project_selector_search",
|
|
28
|
+
"runtime_kind": "frontend_async_callback",
|
|
29
|
+
"supports_await": true,
|
|
30
|
+
"requires_return_wrapper": true,
|
|
31
|
+
"recommended_max_lines": 60,
|
|
32
|
+
"allowed_side_effects": ["return_search_list"],
|
|
33
|
+
"preferred_pattern": "return (async () => { guard; query; return { list }; })();",
|
|
34
|
+
"forbidden_pattern": "inline mapping tables mixed with UI writeback",
|
|
35
|
+
"allows_promise_then": false
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"site_name": "pre_process_script",
|
|
39
|
+
"runtime_kind": "backend_hook",
|
|
40
|
+
"supports_await": true,
|
|
41
|
+
"requires_return_wrapper": false,
|
|
42
|
+
"recommended_max_lines": 80,
|
|
43
|
+
"allowed_side_effects": ["rewrite_query", "append_filters", "default_sort", "import_server_script"],
|
|
44
|
+
"preferred_pattern": "guard; normalize; optional helper call; rewrite ctx.body; return",
|
|
45
|
+
"forbidden_pattern": "mixed UI concerns, writeback, notifications, or nested then chains",
|
|
46
|
+
"allows_promise_then": false
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"site_name": "beforeNextStepScript",
|
|
50
|
+
"runtime_kind": "backend_flow_hook",
|
|
51
|
+
"supports_await": true,
|
|
52
|
+
"requires_return_wrapper": false,
|
|
53
|
+
"recommended_max_lines": 120,
|
|
54
|
+
"allowed_side_effects": ["step_guard", "query", "state_patch", "external_sync", "import_server_script"],
|
|
55
|
+
"preferred_pattern": "guard; normalize; fetch; decide; apply; return",
|
|
56
|
+
"forbidden_pattern": "mixed validation, notification, and persistence branches in one flat function",
|
|
57
|
+
"allows_promise_then": false
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"site_name": "project_create_validator",
|
|
61
|
+
"runtime_kind": "backend_create_hook",
|
|
62
|
+
"supports_await": true,
|
|
63
|
+
"requires_return_wrapper": true,
|
|
64
|
+
"recommended_max_lines": 120,
|
|
65
|
+
"allowed_side_effects": ["query", "return_validation_result", "import_server_script"],
|
|
66
|
+
"preferred_pattern": "return (async () => { guard; fetch; validate; return message_or_empty; })();",
|
|
67
|
+
"forbidden_pattern": "nested then chains, writeback, or mixed callback side effects",
|
|
68
|
+
"allows_promise_then": false
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Runtime Script Site Matrix
|
|
2
|
+
|
|
3
|
+
统一约束 BPMAX 运行时脚本的生成目标。先看位点,再写脚本;不要把不同宿主的语义混成一个“大一统脚本”。
|
|
4
|
+
|
|
5
|
+
## 默认流程
|
|
6
|
+
1. 先产出脚本大纲:输入、输出、外部调用、分支数、是否需要 `await`
|
|
7
|
+
2. 对照 [runtime-script-site-matrix.json](./runtime-script-site-matrix.json) 做预算和宿主校验
|
|
8
|
+
3. 只有通过校验后,才生成最终脚本
|
|
9
|
+
4. 超预算时,不继续内联;只能二选一:
|
|
10
|
+
- 下沉 helper / server script
|
|
11
|
+
- 拆成“薄脚本 + 映射表 / 配置表”
|
|
12
|
+
|
|
13
|
+
## 位点矩阵
|
|
14
|
+
|
|
15
|
+
| site_name | runtime_kind | supports_await | requires_return_wrapper | recommended_max_lines | allowed_side_effects | preferred_pattern | forbidden_pattern |
|
|
16
|
+
| --- | --- | --- | --- | --- | --- | --- | --- |
|
|
17
|
+
| `lambda` | `frontend_expression` | `true` | `true` | `40` | `setValue`, `mergeRule`, `reload` | `return (async () => { ... })();` | 顶层 `await`、Promise 链式回调、平铺大函数 |
|
|
18
|
+
| `customeValidate` | `frontend_validator` | `true` | `true` | `40` | `return_validation_result` | `return (async () => { ... })();` | 写字段、通知、副作用过多 |
|
|
19
|
+
| `es_project_selector_search` | `frontend_async_callback` | `true` | `true` | `60` | `return_search_list` | `return (async () => { ... })();` | 映射表和 UI 写回混写 |
|
|
20
|
+
| `pre_process_script` | `backend_hook` | `true` | `false` | `80` | `rewrite_query`, `append_filters`, `default_sort`, `import_server_script` | `guard -> normalize -> helper/query -> rewrite ctx.body` | UI 逻辑、写回、Promise 链式回调 |
|
|
21
|
+
| `beforeNextStepScript` | `backend_flow_hook` | `true` | `false` | `120` | `step_guard`, `query`, `state_patch`, `external_sync`, `import_server_script` | `guard -> fetch -> decide -> apply -> return` | 校验/通知/持久化全揉在一个平铺函数里 |
|
|
22
|
+
| `project_create_validator` | `backend_create_hook` | `true` | `true` | `120` | `query`, `return_validation_result`, `import_server_script` | `return (async () => { ... })();` | 嵌套 Promise 回调、写回、副作用串写 |
|
|
23
|
+
|
|
24
|
+
## 额外规则
|
|
25
|
+
- 默认禁止 `.then(`。只有宿主已验证无法稳定承接 `async/await` 时,才允许加 `allow-then` 标记后保留。
|
|
26
|
+
- `recommended_max_lines` 只算有效代码行,不算空行。
|
|
27
|
+
- 分支和外部调用过多时,优先提取 helper,不要继续堆 if/else。
|
|
28
|
+
- BPMAX 数据集联动默认把筛选条件下推到 `raw-es-search` / `ctx.$esQuery(...)`;禁止用复杂 SQL join 兜底查询。
|
|
29
|
+
- 禁止先拉取大批 ES 数据再在脚本里 `find` / `filter` / `some` 匹配;查询请求必须直接表达目标条件,并控制 `size`。
|
|
30
|
+
- 能声明为数据的内容不要写成代码:
|
|
31
|
+
- 字段映射表
|
|
32
|
+
- 状态映射表
|
|
33
|
+
- 按钮文案到动作的映射
|
|
34
|
+
- 校验规则清单
|