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,80 @@
|
|
|
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
|
+
SHARED_DIR = Path(__file__).resolve().parents[1]
|
|
10
|
+
if str(SHARED_DIR) not in sys.path:
|
|
11
|
+
sys.path.insert(0, str(SHARED_DIR))
|
|
12
|
+
|
|
13
|
+
from base_url import BASE_URL_ENV_VAR, load_agents_default_origin, resolve_base_url # noqa: E402
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class BaseUrlResolutionTests(unittest.TestCase):
|
|
17
|
+
def test_explicit_base_url_wins_over_environment(self) -> None:
|
|
18
|
+
with mock.patch.dict(os.environ, {BASE_URL_ENV_VAR: "https://env.example.com"}, clear=False):
|
|
19
|
+
self.assertEqual(resolve_base_url("https://cli.example.com/"), "https://cli.example.com")
|
|
20
|
+
|
|
21
|
+
def test_environment_base_url_is_used_when_cli_value_missing(self) -> None:
|
|
22
|
+
with mock.patch.dict(os.environ, {BASE_URL_ENV_VAR: "https://env.example.com/"}, clear=False):
|
|
23
|
+
self.assertEqual(resolve_base_url(None), "https://env.example.com")
|
|
24
|
+
|
|
25
|
+
def test_browser_origin_is_used_when_cli_and_environment_missing(self) -> None:
|
|
26
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
27
|
+
agents_path = Path(tmpdir) / "AGENTS.md"
|
|
28
|
+
agents_path.write_text("", encoding="utf-8")
|
|
29
|
+
with mock.patch.dict(os.environ, {}, clear=True):
|
|
30
|
+
self.assertEqual(
|
|
31
|
+
resolve_base_url(None, browser_origin="https://browser.example.com/api", agents_path=agents_path),
|
|
32
|
+
"https://browser.example.com",
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
def test_agents_default_origin_is_used_as_last_fallback(self) -> None:
|
|
36
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
37
|
+
agents_path = Path(tmpdir) / "AGENTS.md"
|
|
38
|
+
agents_path.write_text(
|
|
39
|
+
"\n".join(
|
|
40
|
+
[
|
|
41
|
+
"## BPMAX Default Address Contract",
|
|
42
|
+
"<!-- BPMAX_DEFAULT_ORIGIN_CONTRACT",
|
|
43
|
+
'{"version":1,"default_origin":"https://repo.example.com","resolution_priority":["--base-url","BPMAX_BASE_URL","current_browser_origin","agents_default_origin"]}',
|
|
44
|
+
"-->",
|
|
45
|
+
]
|
|
46
|
+
),
|
|
47
|
+
encoding="utf-8",
|
|
48
|
+
)
|
|
49
|
+
with mock.patch.dict(os.environ, {}, clear=True):
|
|
50
|
+
self.assertEqual(resolve_base_url(None, agents_path=agents_path), "https://repo.example.com")
|
|
51
|
+
|
|
52
|
+
def test_repo_without_agents_contract_has_no_default_origin(self) -> None:
|
|
53
|
+
self.assertEqual(load_agents_default_origin(), "")
|
|
54
|
+
|
|
55
|
+
def test_missing_base_url_raises_actionable_error(self) -> None:
|
|
56
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
57
|
+
agents_path = Path(tmpdir) / "AGENTS.md"
|
|
58
|
+
agents_path.write_text("", encoding="utf-8")
|
|
59
|
+
with mock.patch.dict(os.environ, {}, clear=True):
|
|
60
|
+
with self.assertRaises(SystemExit) as ctx:
|
|
61
|
+
resolve_base_url(None, agents_path=agents_path)
|
|
62
|
+
self.assertIn("BPMAX_BASE_URL", str(ctx.exception))
|
|
63
|
+
self.assertIn("AGENTS.md", str(ctx.exception))
|
|
64
|
+
|
|
65
|
+
def test_invalid_nested_browser_origin_is_rejected(self) -> None:
|
|
66
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
67
|
+
agents_path = Path(tmpdir) / "AGENTS.md"
|
|
68
|
+
agents_path.write_text("", encoding="utf-8")
|
|
69
|
+
with mock.patch.dict(os.environ, {}, clear=True):
|
|
70
|
+
with self.assertRaises(SystemExit) as ctx:
|
|
71
|
+
resolve_base_url(None, browser_origin="https://browser.example.com/app/detail", agents_path=agents_path)
|
|
72
|
+
self.assertIn("nested path", str(ctx.exception))
|
|
73
|
+
|
|
74
|
+
def test_console_mode_normalizes_api_suffix_back_to_app_origin(self) -> None:
|
|
75
|
+
with mock.patch.dict(os.environ, {}, clear=True):
|
|
76
|
+
self.assertEqual(resolve_base_url("https://host.example.com/api"), "https://host.example.com")
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
if __name__ == "__main__":
|
|
80
|
+
unittest.main()
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
import unittest
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
SCRIPT_DIR = Path(__file__).resolve().parents[1]
|
|
9
|
+
if str(SCRIPT_DIR) not in sys.path:
|
|
10
|
+
sys.path.insert(0, str(SCRIPT_DIR))
|
|
11
|
+
|
|
12
|
+
try:
|
|
13
|
+
from runtime_script_rules import lint_runtime_script # type: ignore
|
|
14
|
+
except ImportError:
|
|
15
|
+
lint_runtime_script = None
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def build_lines(prefix: str, count: int) -> str:
|
|
19
|
+
return "\n".join(f"{prefix} {idx};" for idx in range(count))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class RuntimeScriptRulesTests(unittest.TestCase):
|
|
23
|
+
def test_lambda_over_budget_requires_split(self) -> None:
|
|
24
|
+
self.assertIsNotNone(lint_runtime_script, "runtime_script_rules module should exist")
|
|
25
|
+
source = build_lines("const line =", 41)
|
|
26
|
+
report = lint_runtime_script("lambda", source)
|
|
27
|
+
self.assertFalse(report["ok"])
|
|
28
|
+
self.assertTrue(any(finding["code"] == "line_budget_exceeded" for finding in report["findings"]))
|
|
29
|
+
self.assertTrue(any("helper" in error or "映射表" in error for error in report["errors"]))
|
|
30
|
+
|
|
31
|
+
def test_lambda_rejects_top_level_await_without_wrapper(self) -> None:
|
|
32
|
+
self.assertIsNotNone(lint_runtime_script, "runtime_script_rules module should exist")
|
|
33
|
+
source = "const resp = await ctx.$axios.post('/bpmax/project/raw-es-search');\nctx.$setValueByKeyToValue({ sn: 'x' });"
|
|
34
|
+
report = lint_runtime_script("lambda", source)
|
|
35
|
+
self.assertFalse(report["ok"])
|
|
36
|
+
self.assertTrue(any(finding["code"] == "await_requires_wrapper" for finding in report["findings"]))
|
|
37
|
+
|
|
38
|
+
def test_lambda_rejects_await_outside_wrapper_even_if_wrapper_exists_elsewhere(self) -> None:
|
|
39
|
+
self.assertIsNotNone(lint_runtime_script, "runtime_script_rules module should exist")
|
|
40
|
+
source = "\n".join(
|
|
41
|
+
[
|
|
42
|
+
"const resp = await ctx.$axios.post('/bpmax/project/raw-es-search');",
|
|
43
|
+
"return (async () => {",
|
|
44
|
+
" return '';",
|
|
45
|
+
"})();",
|
|
46
|
+
]
|
|
47
|
+
)
|
|
48
|
+
report = lint_runtime_script("lambda", source)
|
|
49
|
+
self.assertFalse(report["ok"])
|
|
50
|
+
self.assertTrue(any(finding["code"] == "await_requires_wrapper" for finding in report["findings"]))
|
|
51
|
+
|
|
52
|
+
def test_project_create_validator_rejects_then_chain(self) -> None:
|
|
53
|
+
self.assertIsNotNone(lint_runtime_script, "runtime_script_rules module should exist")
|
|
54
|
+
source = "return ctx.$query('select 1').then((rows) => rows.length ? '' : '缺数据');"
|
|
55
|
+
report = lint_runtime_script("project_create_validator", source)
|
|
56
|
+
self.assertFalse(report["ok"])
|
|
57
|
+
self.assertTrue(any(finding["code"] == "forbidden_promise_then" for finding in report["findings"]))
|
|
58
|
+
|
|
59
|
+
def test_lambda_rejects_project_list(self) -> None:
|
|
60
|
+
self.assertIsNotNone(lint_runtime_script, "runtime_script_rules module should exist")
|
|
61
|
+
source = "return ctx.$axios.post('/bpmax/project/list?page=1', { flow_type: 'flow1', query: {} });"
|
|
62
|
+
report = lint_runtime_script("lambda", source)
|
|
63
|
+
self.assertFalse(report["ok"])
|
|
64
|
+
self.assertTrue(any(finding["code"] == "project_list_forbidden" for finding in report["findings"]))
|
|
65
|
+
|
|
66
|
+
def test_project_create_validator_rejects_sql_join(self) -> None:
|
|
67
|
+
self.assertIsNotNone(lint_runtime_script, "runtime_script_rules module should exist")
|
|
68
|
+
source = (
|
|
69
|
+
"return (async () => {\n"
|
|
70
|
+
" const rows = await ctx.$query(`select p.id from think_project p "
|
|
71
|
+
"join think_form f on p.id = f.project_id where f.sn = '${sn}'`);\n"
|
|
72
|
+
" return rows.length ? '' : 'SN不存在';\n"
|
|
73
|
+
"})();"
|
|
74
|
+
)
|
|
75
|
+
report = lint_runtime_script("project_create_validator", source)
|
|
76
|
+
self.assertFalse(report["ok"])
|
|
77
|
+
self.assertTrue(any(finding["code"] == "sql_join_forbidden" for finding in report["findings"]))
|
|
78
|
+
|
|
79
|
+
def test_lambda_rejects_large_es_pull_then_script_matching(self) -> None:
|
|
80
|
+
self.assertIsNotNone(lint_runtime_script, "runtime_script_rules module should exist")
|
|
81
|
+
source = "\n".join(
|
|
82
|
+
[
|
|
83
|
+
"return (async () => {",
|
|
84
|
+
" const response = await ctx.$axios.post('/bpmax/project/raw-es-search', {",
|
|
85
|
+
" flow_type: 'flow1',",
|
|
86
|
+
" data_set_key: 'inventory',",
|
|
87
|
+
" body: { query: { match_all: {} }, size: 10000 },",
|
|
88
|
+
" });",
|
|
89
|
+
" const match = response.data.data.hits.hits.find((hit) => hit._source.sn === sn);",
|
|
90
|
+
" return match ? '' : 'SN不存在';",
|
|
91
|
+
"})();",
|
|
92
|
+
]
|
|
93
|
+
)
|
|
94
|
+
report = lint_runtime_script("lambda", source)
|
|
95
|
+
self.assertFalse(report["ok"])
|
|
96
|
+
self.assertTrue(any(finding["code"] == "bulk_es_script_matching" for finding in report["findings"]))
|
|
97
|
+
|
|
98
|
+
def test_pre_process_script_accepts_async_await(self) -> None:
|
|
99
|
+
self.assertIsNotNone(lint_runtime_script, "runtime_script_rules module should exist")
|
|
100
|
+
source = "\n".join(
|
|
101
|
+
[
|
|
102
|
+
"const rows = await ctx.$esQuery({",
|
|
103
|
+
" data_set_key: 'matrix',",
|
|
104
|
+
" flow_type: 'flow160679070',",
|
|
105
|
+
" body: { query: { bool: { must: [] } } },",
|
|
106
|
+
"});",
|
|
107
|
+
"ctx.body.query.bool.must.push({ terms: { project_id: rows.map((row) => row.__id) } });",
|
|
108
|
+
]
|
|
109
|
+
)
|
|
110
|
+
report = lint_runtime_script("pre_process_script", source)
|
|
111
|
+
self.assertTrue(report["ok"], report["errors"])
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
if __name__ == "__main__":
|
|
115
|
+
unittest.main()
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
import tempfile
|
|
5
|
+
import unittest
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
SCRIPT_DIR = Path(__file__).resolve().parents[1]
|
|
10
|
+
if str(SCRIPT_DIR) not in sys.path:
|
|
11
|
+
sys.path.insert(0, str(SCRIPT_DIR))
|
|
12
|
+
|
|
13
|
+
from skill_audit import audit_skill_root # noqa: E402
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
REPO_ROOT = Path(__file__).resolve().parents[4]
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class SkillAuditTests(unittest.TestCase):
|
|
20
|
+
def test_flags_hardcoded_bpmax_origin(self) -> None:
|
|
21
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
22
|
+
skill_root = Path(tmpdir) / "demo-skill"
|
|
23
|
+
(skill_root / "scripts").mkdir(parents=True)
|
|
24
|
+
(skill_root / "scripts" / "submit_demo.py").write_text("print('ok')\n", encoding="utf-8")
|
|
25
|
+
(skill_root / "SKILL.md").write_text(
|
|
26
|
+
"Use `https://prod.bpmax.local` when calling the API.\n",
|
|
27
|
+
encoding="utf-8",
|
|
28
|
+
)
|
|
29
|
+
report = audit_skill_root(skill_root)
|
|
30
|
+
self.assertFalse(report["ok"])
|
|
31
|
+
self.assertEqual(report["findings"][0]["code"], "hardcoded_domain")
|
|
32
|
+
|
|
33
|
+
def test_flags_hardcoded_real_test_origin(self) -> None:
|
|
34
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
35
|
+
skill_root = Path(tmpdir) / "demo-skill"
|
|
36
|
+
skill_root.mkdir(parents=True)
|
|
37
|
+
(skill_root / "SKILL.md").write_text(
|
|
38
|
+
"Use `https://demo-" + "test.example.com` when calling the API.\n",
|
|
39
|
+
encoding="utf-8",
|
|
40
|
+
)
|
|
41
|
+
report = audit_skill_root(skill_root)
|
|
42
|
+
self.assertFalse(report["ok"])
|
|
43
|
+
self.assertEqual(report["findings"][0]["code"], "hardcoded_domain")
|
|
44
|
+
|
|
45
|
+
def test_flags_doc_claiming_scripts_unimplemented(self) -> None:
|
|
46
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
47
|
+
skill_root = Path(tmpdir) / "demo-skill"
|
|
48
|
+
(skill_root / "scripts").mkdir(parents=True)
|
|
49
|
+
(skill_root / "scripts" / "submit_demo.py").write_text("print('ok')\n", encoding="utf-8")
|
|
50
|
+
(skill_root / "SKILL.md").write_text("当前仓库里这些脚本还不存在。\n", encoding="utf-8")
|
|
51
|
+
report = audit_skill_root(skill_root)
|
|
52
|
+
self.assertFalse(report["ok"])
|
|
53
|
+
self.assertEqual(report["findings"][0]["code"], "doc_claims_scripts_unimplemented")
|
|
54
|
+
|
|
55
|
+
def test_flags_missing_script_reference(self) -> None:
|
|
56
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
57
|
+
skill_root = Path(tmpdir) / "demo-skill"
|
|
58
|
+
(skill_root / "scripts").mkdir(parents=True)
|
|
59
|
+
(skill_root / "scripts" / "submit_demo.py").write_text("print('ok')\n", encoding="utf-8")
|
|
60
|
+
(skill_root / "SKILL.md").write_text("调用 `verify_runtime.py` 完成最终校验。\n", encoding="utf-8")
|
|
61
|
+
report = audit_skill_root(skill_root)
|
|
62
|
+
self.assertFalse(report["ok"])
|
|
63
|
+
self.assertEqual(report["findings"][0]["code"], "doc_references_missing_script")
|
|
64
|
+
|
|
65
|
+
def test_flags_missing_runtime_script_governance_reference(self) -> None:
|
|
66
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
67
|
+
skill_root = Path(tmpdir) / "demo-skill"
|
|
68
|
+
(skill_root / "scripts").mkdir(parents=True)
|
|
69
|
+
(skill_root / "scripts" / "submit_demo.py").write_text("print('ok')\n", encoding="utf-8")
|
|
70
|
+
(skill_root / "SKILL.md").write_text(
|
|
71
|
+
"\n".join(
|
|
72
|
+
[
|
|
73
|
+
"# Demo",
|
|
74
|
+
"- 修改 `lambda` 与 `customeValidate.content` 时,先抽取再回写。",
|
|
75
|
+
"- 这里没有引用统一的脚本位点矩阵。",
|
|
76
|
+
]
|
|
77
|
+
)
|
|
78
|
+
+ "\n",
|
|
79
|
+
encoding="utf-8",
|
|
80
|
+
)
|
|
81
|
+
report = audit_skill_root(skill_root)
|
|
82
|
+
self.assertFalse(report["ok"])
|
|
83
|
+
self.assertTrue(
|
|
84
|
+
any(finding["code"] == "missing_runtime_script_governance_reference" for finding in report["findings"])
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
def test_flags_forbidden_then_in_runtime_docs(self) -> None:
|
|
88
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
89
|
+
skill_root = Path(tmpdir) / "demo-skill"
|
|
90
|
+
(skill_root / "scripts").mkdir(parents=True)
|
|
91
|
+
(skill_root / "scripts" / "submit_demo.py").write_text("print('ok')\n", encoding="utf-8")
|
|
92
|
+
(skill_root / "SKILL.md").write_text(
|
|
93
|
+
"\n".join(
|
|
94
|
+
[
|
|
95
|
+
"# Demo",
|
|
96
|
+
"- 统一参考 `../bpmax-builder-shared/runtime-script-site-matrix.md`。",
|
|
97
|
+
"```js",
|
|
98
|
+
"return ctx.$query('select 1').then((rows) => rows);",
|
|
99
|
+
"```",
|
|
100
|
+
]
|
|
101
|
+
)
|
|
102
|
+
+ "\n",
|
|
103
|
+
encoding="utf-8",
|
|
104
|
+
)
|
|
105
|
+
report = audit_skill_root(skill_root)
|
|
106
|
+
self.assertFalse(report["ok"])
|
|
107
|
+
self.assertTrue(any(finding["code"] == "forbidden_promise_then" for finding in report["findings"]))
|
|
108
|
+
|
|
109
|
+
def test_flags_project_list_guidance(self) -> None:
|
|
110
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
111
|
+
skill_root = Path(tmpdir) / "demo-skill"
|
|
112
|
+
(skill_root / "scripts").mkdir(parents=True)
|
|
113
|
+
(skill_root / "scripts" / "submit_demo.py").write_text("print('ok')\n", encoding="utf-8")
|
|
114
|
+
(skill_root / "SKILL.md").write_text(
|
|
115
|
+
"\n".join(
|
|
116
|
+
[
|
|
117
|
+
"# Demo",
|
|
118
|
+
"- 统一参考 `../bpmax-builder-shared/runtime-script-site-matrix.md`。",
|
|
119
|
+
"- 普通字段联动默认用 `ctx.$axios.post('/bpmax/project/list')`。",
|
|
120
|
+
]
|
|
121
|
+
)
|
|
122
|
+
+ "\n",
|
|
123
|
+
encoding="utf-8",
|
|
124
|
+
)
|
|
125
|
+
report = audit_skill_root(skill_root)
|
|
126
|
+
self.assertFalse(report["ok"])
|
|
127
|
+
self.assertTrue(any(finding["code"] == "project_list_guidance_forbidden" for finding in report["findings"]))
|
|
128
|
+
|
|
129
|
+
def test_flags_project_list_code_fence(self) -> None:
|
|
130
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
131
|
+
skill_root = Path(tmpdir) / "demo-skill"
|
|
132
|
+
(skill_root / "scripts").mkdir(parents=True)
|
|
133
|
+
(skill_root / "scripts" / "submit_demo.py").write_text("print('ok')\n", encoding="utf-8")
|
|
134
|
+
(skill_root / "SKILL.md").write_text(
|
|
135
|
+
"\n".join(
|
|
136
|
+
[
|
|
137
|
+
"# Demo",
|
|
138
|
+
"- 统一参考 `../bpmax-builder-shared/runtime-script-site-matrix.md`。",
|
|
139
|
+
"```js",
|
|
140
|
+
"return ctx.$axios.post('/bpmax/project/list?page=1', { flow_type: 'flow1', query: {} });",
|
|
141
|
+
"```",
|
|
142
|
+
]
|
|
143
|
+
)
|
|
144
|
+
+ "\n",
|
|
145
|
+
encoding="utf-8",
|
|
146
|
+
)
|
|
147
|
+
report = audit_skill_root(skill_root)
|
|
148
|
+
self.assertFalse(report["ok"])
|
|
149
|
+
self.assertTrue(any(finding["code"] == "project_list_code_fence_forbidden" for finding in report["findings"]))
|
|
150
|
+
|
|
151
|
+
def test_allows_verification_reference_to_project_list(self) -> None:
|
|
152
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
153
|
+
skill_root = Path(tmpdir) / "demo-skill"
|
|
154
|
+
(skill_root / "scripts").mkdir(parents=True)
|
|
155
|
+
(skill_root / "scripts" / "submit_demo.py").write_text("print('ok')\n", encoding="utf-8")
|
|
156
|
+
(skill_root / "SKILL.md").write_text(
|
|
157
|
+
"\n".join(
|
|
158
|
+
[
|
|
159
|
+
"# Demo",
|
|
160
|
+
"- 统一参考 `../bpmax-builder-shared/runtime-script-site-matrix.md`。",
|
|
161
|
+
"- 回读 `POST /bpmax/project/list` 的真实请求体,仅用于验收验证。",
|
|
162
|
+
]
|
|
163
|
+
)
|
|
164
|
+
+ "\n",
|
|
165
|
+
encoding="utf-8",
|
|
166
|
+
)
|
|
167
|
+
report = audit_skill_root(skill_root)
|
|
168
|
+
self.assertTrue(report["ok"], report["errors"])
|
|
169
|
+
|
|
170
|
+
def test_all_runtime_code_fences_are_linted_not_just_shared_catalog(self) -> None:
|
|
171
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
172
|
+
skill_root = Path(tmpdir) / "demo-skill"
|
|
173
|
+
(skill_root / "scripts").mkdir(parents=True)
|
|
174
|
+
(skill_root / "scripts" / "submit_demo.py").write_text("print('ok')\n", encoding="utf-8")
|
|
175
|
+
long_script = "\n".join(f"const line{idx} = {idx};" for idx in range(45))
|
|
176
|
+
(skill_root / "SKILL.md").write_text(
|
|
177
|
+
"\n".join(
|
|
178
|
+
[
|
|
179
|
+
"# Demo",
|
|
180
|
+
"- 统一参考 `../bpmax-builder-shared/runtime-script-site-matrix.md`。",
|
|
181
|
+
"## lambda",
|
|
182
|
+
"```js",
|
|
183
|
+
long_script,
|
|
184
|
+
"```",
|
|
185
|
+
]
|
|
186
|
+
)
|
|
187
|
+
+ "\n",
|
|
188
|
+
encoding="utf-8",
|
|
189
|
+
)
|
|
190
|
+
report = audit_skill_root(skill_root)
|
|
191
|
+
self.assertFalse(report["ok"])
|
|
192
|
+
self.assertTrue(any(finding["code"] == "line_budget_exceeded" for finding in report["findings"]))
|
|
193
|
+
|
|
194
|
+
def test_antipattern_prose_with_then_is_not_flagged(self) -> None:
|
|
195
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
196
|
+
skill_root = Path(tmpdir) / "demo-skill"
|
|
197
|
+
(skill_root / "scripts").mkdir(parents=True)
|
|
198
|
+
(skill_root / "scripts" / "submit_demo.py").write_text("print('ok')\n", encoding="utf-8")
|
|
199
|
+
(skill_root / "SKILL.md").write_text(
|
|
200
|
+
"\n".join(
|
|
201
|
+
[
|
|
202
|
+
"# Demo",
|
|
203
|
+
"- 统一参考 `../bpmax-builder-shared/runtime-script-site-matrix.md`。",
|
|
204
|
+
"- 反模式:不要再写 `ctx.$axios(...).then(...)` 这种链式回调。",
|
|
205
|
+
]
|
|
206
|
+
)
|
|
207
|
+
+ "\n",
|
|
208
|
+
encoding="utf-8",
|
|
209
|
+
)
|
|
210
|
+
report = audit_skill_root(skill_root)
|
|
211
|
+
self.assertTrue(report["ok"], report["errors"])
|
|
212
|
+
|
|
213
|
+
def test_form_flow_and_dataset_skills_pass_audit(self) -> None:
|
|
214
|
+
skill_roots = [
|
|
215
|
+
REPO_ROOT / ".codex" / "skills" / "bpmax-form-template-editor",
|
|
216
|
+
REPO_ROOT / ".codex" / "skills" / "bpmax-flow-template-editor",
|
|
217
|
+
REPO_ROOT / ".codex" / "skills" / "bpmax-dataset-template-editor",
|
|
218
|
+
]
|
|
219
|
+
for root in skill_roots:
|
|
220
|
+
with self.subTest(skill=root.name):
|
|
221
|
+
self.assertTrue(audit_skill_root(root)["ok"])
|
|
222
|
+
|
|
223
|
+
def test_filter_and_role_skills_pass_audit(self) -> None:
|
|
224
|
+
filter_root = REPO_ROOT / ".codex" / "skills" / "bpmax-filter-template-editor"
|
|
225
|
+
role_root = REPO_ROOT / ".codex" / "skills" / "bpmax-role-editor"
|
|
226
|
+
self.assertTrue(audit_skill_root(filter_root)["ok"])
|
|
227
|
+
self.assertTrue(audit_skill_root(role_root)["ok"])
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
if __name__ == "__main__":
|
|
231
|
+
unittest.main()
|