bpmax-cli 0.1.44-beta.8 → 0.1.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/dist/bin.js +466 -4578
- package/dist/bin.js.map +1 -1
- package/package.json +1 -1
- package/scripts/install-skills.mjs +0 -98
- package/skills/bpmax-auth/SKILL.md +17 -6
- package/skills/bpmax-cli/SKILL.md +0 -2
- package/skills/bpmax-project/SKILL.md +2 -1
- package/skills/bpmax-shared/SKILL.md +1 -1
- package/skills/bpmax-api-platform-editor/SKILL.md +0 -321
- package/skills/bpmax-api-platform-editor/agents/openai.yaml +0 -4
- package/skills/bpmax-api-platform-editor/references/api-doc-debug-workflow.md +0 -34
- package/skills/bpmax-api-platform-editor/references/api-proxy-shape.md +0 -41
- package/skills/bpmax-api-platform-editor/references/instance-config-shape.md +0 -41
- package/skills/bpmax-api-platform-editor/references/platform-api-map.md +0 -52
- package/skills/bpmax-api-platform-editor/references/runtime-workflow.md +0 -32
- package/skills/bpmax-api-platform-editor/scripts/api_platform_editor_common.py +0 -1276
- package/skills/bpmax-api-platform-editor/scripts/build_submit_payload.py +0 -64
- package/skills/bpmax-api-platform-editor/scripts/capture_write_contract.py +0 -40
- package/skills/bpmax-api-platform-editor/scripts/export_layer_bundle.py +0 -212
- package/skills/bpmax-api-platform-editor/scripts/record_doc_debug_acceptance.py +0 -62
- package/skills/bpmax-api-platform-editor/scripts/submit_and_verify_layer.py +0 -75
- package/skills/bpmax-api-platform-editor/tests/test_api_platform_editor.py +0 -287
- package/skills/bpmax-builder-shared/SKILL.md +0 -44
- package/skills/bpmax-builder-shared/base_url.py +0 -81
- package/skills/bpmax-builder-shared/runtime-script-site-matrix.json +0 -71
- package/skills/bpmax-builder-shared/runtime-script-site-matrix.md +0 -34
- package/skills/bpmax-builder-shared/runtime-script-template-catalog.md +0 -123
- package/skills/bpmax-builder-shared/runtime_script_rules.py +0 -272
- package/skills/bpmax-builder-shared/skill_audit.py +0 -374
- package/skills/bpmax-builder-shared/template_script_hard_rules.py +0 -280
- package/skills/bpmax-builder-shared/tests/test_base_url.py +0 -80
- package/skills/bpmax-builder-shared/tests/test_runtime_script_rules.py +0 -115
- package/skills/bpmax-builder-shared/tests/test_skill_audit.py +0 -231
- package/skills/bpmax-builder-shared/tests/test_template_script_hard_rules.py +0 -281
- package/skills/bpmax-config-latest/SKILL.md +0 -71
- package/skills/bpmax-console-template-editor/SKILL.md +0 -536
- package/skills/bpmax-console-template-editor/agents/openai.yaml +0 -4
- package/skills/bpmax-console-template-editor/references/filter-integration.md +0 -60
- package/skills/bpmax-console-template-editor/references/lessons-from-resume-dashboard.md +0 -114
- package/skills/bpmax-console-template-editor/references/local-temp-workflow.md +0 -69
- package/skills/bpmax-console-template-editor/references/module-catalog.md +0 -100
- package/skills/bpmax-console-template-editor/references/runtime-page-shape.md +0 -91
- package/skills/bpmax-console-template-editor/references/template-shape.md +0 -149
- package/skills/bpmax-console-template-editor/scripts/build_submit_payload.py +0 -38
- package/skills/bpmax-console-template-editor/scripts/confirm_console_template.py +0 -33
- package/skills/bpmax-console-template-editor/scripts/console_template_editor_common.py +0 -964
- package/skills/bpmax-console-template-editor/scripts/export_console_template.py +0 -99
- package/skills/bpmax-console-template-editor/scripts/lint_console_template.py +0 -46
- package/skills/bpmax-console-template-editor/scripts/submit_console_template.py +0 -99
- package/skills/bpmax-console-template-editor/tests/test_console_template_editor.py +0 -383
- package/skills/bpmax-dataset-field-template-editor/SKILL.md +0 -600
- package/skills/bpmax-dataset-field-template-editor/references/create-request-gotchas.md +0 -25
- package/skills/bpmax-dataset-field-template-editor/references/field-classify-mapping.md +0 -35
- package/skills/bpmax-dataset-field-template-editor/references/nested-field-patterns.md +0 -24
- package/skills/bpmax-dataset-field-template-editor/references/runtime-verified-field-page-shape.md +0 -61
- package/skills/bpmax-dataset-field-template-editor/references/virtual-field-patterns.md +0 -27
- package/skills/bpmax-dataset-field-template-editor/references/work-file-to-submit-mapping.md +0 -127
- package/skills/bpmax-dataset-field-template-editor/scripts/build_submit_payload.py +0 -67
- package/skills/bpmax-dataset-field-template-editor/scripts/confirm_dataset_field.py +0 -37
- package/skills/bpmax-dataset-field-template-editor/scripts/dataset_field_editor_common.py +0 -784
- package/skills/bpmax-dataset-field-template-editor/scripts/export_dataset_field.py +0 -62
- package/skills/bpmax-dataset-field-template-editor/scripts/init_create_dataset_field.py +0 -104
- package/skills/bpmax-dataset-field-template-editor/scripts/inspect_dataset_field_runtime.py +0 -83
- package/skills/bpmax-dataset-field-template-editor/scripts/lint_dataset_field_semantics.py +0 -35
- package/skills/bpmax-dataset-field-template-editor/scripts/submit_dataset_field.py +0 -95
- package/skills/bpmax-dataset-field-template-editor/tests/test_dataset_field_editor.py +0 -709
- package/skills/bpmax-dataset-field-template-editor/tests/test_init_create_dataset_field.py +0 -59
- package/skills/bpmax-dataset-template-editor/SKILL.md +0 -779
- package/skills/bpmax-dataset-template-editor/references/custom-key-usage-patterns.md +0 -18
- package/skills/bpmax-dataset-template-editor/references/dataset-script-runtime-matrix.md +0 -73
- package/skills/bpmax-dataset-template-editor/references/pre-process-script-authoring-guide.md +0 -186
- package/skills/bpmax-dataset-template-editor/references/pre-process-script-example-catalog.md +0 -106
- package/skills/bpmax-dataset-template-editor/references/runtime-gotchas.md +0 -28
- package/skills/bpmax-dataset-template-editor/references/runtime-verified-dataset-page-shape.md +0 -47
- package/skills/bpmax-dataset-template-editor/references/ui-to-backend-field-map.md +0 -23
- package/skills/bpmax-dataset-template-editor/references/work-file-to-submit-mapping.md +0 -97
- package/skills/bpmax-dataset-template-editor/scripts/basic_table_audit.py +0 -65
- package/skills/bpmax-dataset-template-editor/scripts/build_submit_payload.py +0 -38
- package/skills/bpmax-dataset-template-editor/scripts/dataset_editor_common.py +0 -650
- package/skills/bpmax-dataset-template-editor/scripts/export_dataset.py +0 -155
- package/skills/bpmax-dataset-template-editor/scripts/lint_dataset_template.py +0 -42
- package/skills/bpmax-dataset-template-editor/scripts/resolve_dataset.py +0 -43
- package/skills/bpmax-dataset-template-editor/scripts/scan_custom_key_references.py +0 -27
- package/skills/bpmax-dataset-template-editor/scripts/submit_dataset.py +0 -115
- package/skills/bpmax-dataset-template-editor/scripts/verify_dataset_list.py +0 -52
- package/skills/bpmax-dataset-template-editor/scripts/verify_publish_health.py +0 -39
- package/skills/bpmax-dataset-template-editor/tests/test_dataset_editor.py +0 -373
- package/skills/bpmax-e2e-flow-config-orchestrator/SKILL.md +0 -177
- package/skills/bpmax-e2e-flow-config-orchestrator/agents/openai.yaml +0 -4
- package/skills/bpmax-e2e-flow-config-orchestrator/references/orchestration-matrix.md +0 -60
- package/skills/bpmax-e2e-flow-test-operator/SKILL.md +0 -394
- package/skills/bpmax-e2e-flow-test-operator/agents/openai.yaml +0 -5
- package/skills/bpmax-e2e-flow-test-operator/profiles/negative_sale.json +0 -97
- package/skills/bpmax-e2e-flow-test-operator/profiles/negative_sale_final_v2.json +0 -105
- package/skills/bpmax-e2e-flow-test-operator/profiles/negative_sale_main.json +0 -36
- package/skills/bpmax-e2e-flow-test-operator/profiles/negative_sale_region.json +0 -40
- package/skills/bpmax-e2e-flow-test-operator/references/browser-only-checkpoints.md +0 -41
- package/skills/bpmax-e2e-flow-test-operator/references/failure-update-loop.md +0 -17
- package/skills/bpmax-e2e-flow-test-operator/references/filter-field-discovery.md +0 -40
- package/skills/bpmax-e2e-flow-test-operator/references/minimal-test-loop.md +0 -24
- package/skills/bpmax-e2e-flow-test-operator/references/negative-sale-api-matrix.md +0 -75
- package/skills/bpmax-e2e-flow-test-operator/references/profile-schema.md +0 -107
- package/skills/bpmax-e2e-flow-test-operator/references/skill-experience-coverage-matrix.md +0 -29
- package/skills/bpmax-e2e-flow-test-operator/references/stale-runtime-and-clean-sample-rules.md +0 -54
- package/skills/bpmax-e2e-flow-test-operator/references/state-schema.md +0 -83
- package/skills/bpmax-e2e-flow-test-operator/scripts/bpmax_session.py +0 -287
- package/skills/bpmax-e2e-flow-test-operator/scripts/dealer_sample_on_shelf_plan.json +0 -59
- package/skills/bpmax-e2e-flow-test-operator/scripts/dealer_sample_on_shelf_runner.py +0 -687
- package/skills/bpmax-e2e-flow-test-operator/scripts/e2e_doc.py +0 -121
- package/skills/bpmax-e2e-flow-test-operator/scripts/e2e_state.py +0 -288
- package/skills/bpmax-e2e-flow-test-operator/scripts/flow_api_matrix.py +0 -161
- package/skills/bpmax-e2e-flow-test-operator/scripts/flow_filter_fields.py +0 -138
- package/skills/bpmax-e2e-flow-test-operator/scripts/flow_form_runtime.py +0 -396
- package/skills/bpmax-e2e-flow-test-operator/scripts/flow_runner.py +0 -341
- package/skills/bpmax-e2e-flow-test-operator/scripts/flow_test_profile.py +0 -185
- package/skills/bpmax-e2e-flow-test-operator/tests/test_negative_sale_api_tools.py +0 -138
- package/skills/bpmax-feishu-chat-flow-plugin-editor/SKILL.md +0 -69
- package/skills/bpmax-feishu-chat-flow-plugin-editor/agents/openai.yaml +0 -4
- package/skills/bpmax-feishu-chat-flow-plugin-editor/references/config-checklist.md +0 -42
- package/skills/bpmax-feishu-chat-flow-plugin-editor/references/config-recipes.md +0 -38
- package/skills/bpmax-feishu-chat-flow-plugin-editor/references/config-shape.md +0 -86
- package/skills/bpmax-feishu-chat-flow-plugin-editor/references/gate-lint.md +0 -68
- package/skills/bpmax-feishu-chat-flow-plugin-editor/references/hoocoo-patterns.md +0 -39
- package/skills/bpmax-feishu-chat-flow-plugin-editor/references/runtime-behavior.md +0 -41
- package/skills/bpmax-feishu-chat-flow-plugin-editor/references/script-authoring.md +0 -110
- package/skills/bpmax-feishu-chat-flow-plugin-editor/scripts/lint_feishu_chat_plugin.py +0 -278
- package/skills/bpmax-feishu-chat-flow-plugin-editor/tests/test_lint_feishu_chat_plugin.py +0 -203
- package/skills/bpmax-filter-template-editor/SKILL.md +0 -564
- package/skills/bpmax-filter-template-editor/references/experience-coverage-matrix.md +0 -38
- package/skills/bpmax-filter-template-editor/references/filter-and-flow-binding.md +0 -57
- package/skills/bpmax-filter-template-editor/references/filter-content-schema.md +0 -141
- package/skills/bpmax-filter-template-editor/references/filter-request-shape.md +0 -287
- package/skills/bpmax-filter-template-editor/references/filter-runtime-patterns.md +0 -115
- package/skills/bpmax-filter-template-editor/references/runtime-verified-filter-page-shape.md +0 -94
- package/skills/bpmax-filter-template-editor/scripts/build_submit_payload.py +0 -25
- package/skills/bpmax-filter-template-editor/scripts/confirm_filter_template.py +0 -22
- package/skills/bpmax-filter-template-editor/scripts/export_filter_template.py +0 -57
- package/skills/bpmax-filter-template-editor/scripts/filter_template_editor_common.py +0 -348
- package/skills/bpmax-filter-template-editor/scripts/init_create_filter_template.py +0 -8
- package/skills/bpmax-filter-template-editor/scripts/lint_filter_template_semantics.py +0 -26
- package/skills/bpmax-filter-template-editor/scripts/submit_filter_template.py +0 -62
- package/skills/bpmax-filter-template-editor/tests/test_filter_template_editor.py +0 -231
- package/skills/bpmax-flow-template-editor/SKILL.md +0 -1058
- package/skills/bpmax-flow-template-editor/agents/openai.yaml +0 -4
- package/skills/bpmax-flow-template-editor/references/before-next-step-script-runtime-gotchas.md +0 -62
- package/skills/bpmax-flow-template-editor/references/config-surfaces-and-placeholders.md +0 -270
- package/skills/bpmax-flow-template-editor/references/diff-strategy.md +0 -67
- package/skills/bpmax-flow-template-editor/references/editor-runtime-vs-draft.md +0 -25
- package/skills/bpmax-flow-template-editor/references/flow-template-api-workflow.md +0 -174
- package/skills/bpmax-flow-template-editor/references/intent-model.md +0 -117
- package/skills/bpmax-flow-template-editor/references/lessons-from-price-plan-flow.md +0 -147
- package/skills/bpmax-flow-template-editor/references/local-temp-workflow.md +0 -97
- package/skills/bpmax-flow-template-editor/references/matrix-flow-form-nav-collaboration.md +0 -165
- package/skills/bpmax-flow-template-editor/references/payload-checklist.md +0 -133
- package/skills/bpmax-flow-template-editor/references/project-create-runtime-gotchas.md +0 -54
- package/skills/bpmax-flow-template-editor/references/requirement-to-node-mapping.md +0 -149
- package/skills/bpmax-flow-template-editor/references/runtime-verified-flow-detail-shape.md +0 -41
- package/skills/bpmax-flow-template-editor/references/runtime-verified-meta-fields.md +0 -155
- package/skills/bpmax-flow-template-editor/references/runtime-verified-node-fields.md +0 -179
- package/skills/bpmax-flow-template-editor/references/save-draft-request-shape.md +0 -91
- package/skills/bpmax-flow-template-editor/references/script-review-hard-rules.md +0 -93
- package/skills/bpmax-flow-template-editor/references/work-file-to-submit-mapping.md +0 -57
- package/skills/bpmax-flow-template-editor/scripts/build_submit_payload.py +0 -69
- package/skills/bpmax-flow-template-editor/scripts/confirm_flow_template.py +0 -52
- package/skills/bpmax-flow-template-editor/scripts/export_flow_template.py +0 -114
- package/skills/bpmax-flow-template-editor/scripts/flow_template_editor_common.py +0 -1084
- package/skills/bpmax-flow-template-editor/scripts/submit_flow_template.py +0 -159
- package/skills/bpmax-flow-template-editor/tests/test_flow_template_editor.py +0 -636
- package/skills/bpmax-form-template-editor/SKILL.md +0 -1099
- package/skills/bpmax-form-template-editor/agents/openai.yaml +0 -4
- package/skills/bpmax-form-template-editor/references/form-template-api-workflow.md +0 -203
- package/skills/bpmax-form-template-editor/references/local-temp-workflow.md +0 -125
- package/skills/bpmax-form-template-editor/references/payload-checklist.md +0 -77
- package/skills/bpmax-form-template-editor/references/sub-form-patterns.md +0 -49
- package/skills/bpmax-form-template-editor/scripts/build_submit_payload.py +0 -37
- package/skills/bpmax-form-template-editor/scripts/check_form_template_consistency.py +0 -145
- package/skills/bpmax-form-template-editor/scripts/confirm_form_template.py +0 -67
- package/skills/bpmax-form-template-editor/scripts/export_form_template.py +0 -91
- package/skills/bpmax-form-template-editor/scripts/form_template_editor_common.py +0 -1762
- package/skills/bpmax-form-template-editor/scripts/lint_form_template_semantics.py +0 -30
- package/skills/bpmax-form-template-editor/scripts/record_runtime_acceptance.py +0 -67
- package/skills/bpmax-form-template-editor/scripts/submit_form_template.py +0 -163
- package/skills/bpmax-form-template-editor/tests/test_form_template_editor.py +0 -1292
- package/skills/bpmax-list-template-editor/SKILL.md +0 -468
- package/skills/bpmax-list-template-editor/agents/openai.yaml +0 -4
- package/skills/bpmax-list-template-editor/references/browser-page-contract.md +0 -81
- package/skills/bpmax-list-template-editor/references/content-config-shape.md +0 -148
- package/skills/bpmax-list-template-editor/references/dataset-field-mapping.md +0 -60
- package/skills/bpmax-list-template-editor/references/list-template-api-workflow.md +0 -103
- package/skills/bpmax-list-template-editor/references/local-temp-workflow.md +0 -102
- package/skills/bpmax-list-template-editor/references/payload-checklist.md +0 -47
- package/skills/bpmax-list-template-editor/references/runtime-verified-workflow.md +0 -140
- package/skills/bpmax-list-template-editor/references/special-formats.md +0 -394
- package/skills/bpmax-list-template-editor/scripts/build_submit_payload.py +0 -37
- package/skills/bpmax-list-template-editor/scripts/confirm_list_template.py +0 -33
- package/skills/bpmax-list-template-editor/scripts/export_list_template.py +0 -89
- package/skills/bpmax-list-template-editor/scripts/fetch_data_set.py +0 -34
- package/skills/bpmax-list-template-editor/scripts/lint_list_template_semantics.py +0 -54
- package/skills/bpmax-list-template-editor/scripts/list_template_editor_common.py +0 -955
- package/skills/bpmax-list-template-editor/scripts/record_acceptance.py +0 -55
- package/skills/bpmax-list-template-editor/scripts/submit_list_template.py +0 -117
- package/skills/bpmax-list-template-editor/tests/test_list_template_editor_common.py +0 -441
- package/skills/bpmax-memory-protocol/SKILL.md +0 -72
- package/skills/bpmax-nav-config-editor/SKILL.md +0 -347
- package/skills/bpmax-nav-config-editor/agents/openai.yaml +0 -4
- package/skills/bpmax-nav-config-editor/references/api-workflow.md +0 -68
- package/skills/bpmax-nav-config-editor/references/config-shape.md +0 -78
- package/skills/bpmax-nav-config-editor/references/icon-selection.md +0 -83
- package/skills/bpmax-nav-config-editor/references/path-mapping-rules.md +0 -46
- package/skills/bpmax-nav-config-editor/references/payload-checklist.md +0 -41
- package/skills/bpmax-nav-config-editor/references/runtime-probing.md +0 -47
- package/skills/bpmax-nav-config-editor/scripts/build_submit_payload.py +0 -34
- package/skills/bpmax-nav-config-editor/scripts/confirm_nav_config.py +0 -32
- package/skills/bpmax-nav-config-editor/scripts/export_nav_config.py +0 -56
- package/skills/bpmax-nav-config-editor/scripts/lint_nav_config_semantics.py +0 -33
- package/skills/bpmax-nav-config-editor/scripts/nav_config_editor_common.py +0 -812
- package/skills/bpmax-nav-config-editor/scripts/submit_nav_config.py +0 -44
- package/skills/bpmax-nav-config-editor/scripts/verify_nav_config.py +0 -33
- package/skills/bpmax-nav-config-editor/tests/test_nav_config_editor.py +0 -358
- package/skills/bpmax-nav-config-editor/tests/test_nav_config_editor_common.py +0 -138
- package/skills/bpmax-nav-config-editor/tests/test_nav_config_lint.py +0 -58
- package/skills/bpmax-nav-config-editor/tests/test_nav_config_submit_verify.py +0 -51
- package/skills/bpmax-project-detail-template-editor/SKILL.md +0 -329
- package/skills/bpmax-project-detail-template-editor/agents/openai.yaml +0 -4
- package/skills/bpmax-project-detail-template-editor/references/local-temp-workflow.md +0 -59
- package/skills/bpmax-project-detail-template-editor/references/module-catalog-and-config-notes.md +0 -47
- package/skills/bpmax-project-detail-template-editor/references/payload-checklist.md +0 -33
- package/skills/bpmax-project-detail-template-editor/references/project-detail-template-api-workflow.md +0 -44
- package/skills/bpmax-project-detail-template-editor/scripts/build_submit_payload.py +0 -30
- package/skills/bpmax-project-detail-template-editor/scripts/confirm_project_detail_template.py +0 -33
- package/skills/bpmax-project-detail-template-editor/scripts/export_project_detail_template.py +0 -87
- package/skills/bpmax-project-detail-template-editor/scripts/lint_project_detail_template_semantics.py +0 -37
- package/skills/bpmax-project-detail-template-editor/scripts/project_detail_template_editor_common.py +0 -507
- package/skills/bpmax-project-detail-template-editor/scripts/submit_project_detail_template.py +0 -120
- package/skills/bpmax-project-detail-template-editor/tests/test_project_detail_template_editor.py +0 -369
- package/skills/bpmax-role-editor/SKILL.md +0 -251
- package/skills/bpmax-role-editor/references/api-workflow.md +0 -30
- package/skills/bpmax-role-editor/references/runtime-page-shape.md +0 -18
- package/skills/bpmax-role-editor/references/work-file-mapping.md +0 -32
- package/skills/bpmax-role-editor/scripts/build_submit_payload.py +0 -38
- package/skills/bpmax-role-editor/scripts/confirm_role.py +0 -33
- package/skills/bpmax-role-editor/scripts/export_role.py +0 -163
- package/skills/bpmax-role-editor/scripts/lint_role_semantics.py +0 -38
- package/skills/bpmax-role-editor/scripts/role_editor_common.py +0 -1231
- package/skills/bpmax-role-editor/scripts/submit_role.py +0 -144
- package/skills/bpmax-role-editor/tests/test_role_editor.py +0 -343
- package/skills/bpmax-user-mock-operator/SKILL.md +0 -106
- package/skills/bpmax-user-mock-operator/agents/openai.yaml +0 -4
- package/skills/bpmax-user-mock-operator/scripts/switch_user_identity.py +0 -37
- package/skills/bpmax-user-mock-operator/scripts/user_mock_operator_common.py +0 -136
- package/skills/bpmax-user-mock-operator/tests/test_user_mock_operator.py +0 -138
- package/skills/form-control-library/SKILL.md +0 -82
- package/skills/form-control-library/agents/openai.yaml +0 -4
- package/skills/form-control-library/references/form-controls.md +0 -199
- package/skills/form-control-library/references/form-template-submit-schema.md +0 -180
- package/skills/form-control-library/references/group-select-runtime.md +0 -191
- package/skills/form-control-library/scripts/rebuild_form_control_library.py +0 -55
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
from __future__ import annotations
|
|
3
|
-
|
|
4
|
-
import re
|
|
5
|
-
from collections import Counter
|
|
6
|
-
from typing import Any
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
SCRIPT_SITE_MATRIX: dict[str, dict[str, Any]] = {
|
|
10
|
-
"lambda": {
|
|
11
|
-
"site_name": "lambda",
|
|
12
|
-
"runtime_kind": "frontend_expression",
|
|
13
|
-
"supports_await": True,
|
|
14
|
-
"requires_return_wrapper": True,
|
|
15
|
-
"recommended_max_lines": 40,
|
|
16
|
-
"allowed_side_effects": ["setValue", "mergeRule", "reload"],
|
|
17
|
-
"preferred_pattern": "return (async () => { guard; normalize; fetch; apply; })();",
|
|
18
|
-
"forbidden_pattern": "flat multi-branch promise chain with top-level await or nested then",
|
|
19
|
-
"allows_promise_then": False,
|
|
20
|
-
},
|
|
21
|
-
"customeValidate": {
|
|
22
|
-
"site_name": "customeValidate",
|
|
23
|
-
"runtime_kind": "frontend_validator",
|
|
24
|
-
"supports_await": True,
|
|
25
|
-
"requires_return_wrapper": True,
|
|
26
|
-
"recommended_max_lines": 40,
|
|
27
|
-
"allowed_side_effects": ["return_validation_result"],
|
|
28
|
-
"preferred_pattern": "return (async () => { guard; fetch; return message_or_empty; })();",
|
|
29
|
-
"forbidden_pattern": "field writeback, notification, or nested promise chain",
|
|
30
|
-
"allows_promise_then": False,
|
|
31
|
-
},
|
|
32
|
-
"es_project_selector_search": {
|
|
33
|
-
"site_name": "es_project_selector_search",
|
|
34
|
-
"runtime_kind": "frontend_async_callback",
|
|
35
|
-
"supports_await": True,
|
|
36
|
-
"requires_return_wrapper": True,
|
|
37
|
-
"recommended_max_lines": 60,
|
|
38
|
-
"allowed_side_effects": ["return_search_list"],
|
|
39
|
-
"preferred_pattern": "return (async () => { guard; query; return { list }; })();",
|
|
40
|
-
"forbidden_pattern": "inline mapping tables mixed with UI writeback",
|
|
41
|
-
"allows_promise_then": False,
|
|
42
|
-
},
|
|
43
|
-
"pre_process_script": {
|
|
44
|
-
"site_name": "pre_process_script",
|
|
45
|
-
"runtime_kind": "backend_hook",
|
|
46
|
-
"supports_await": True,
|
|
47
|
-
"requires_return_wrapper": False,
|
|
48
|
-
"recommended_max_lines": 80,
|
|
49
|
-
"allowed_side_effects": ["rewrite_query", "append_filters", "default_sort", "import_server_script"],
|
|
50
|
-
"preferred_pattern": "guard; normalize; optional helper call; rewrite ctx.body; return",
|
|
51
|
-
"forbidden_pattern": "mixed UI concerns, writeback, notifications, or nested then chains",
|
|
52
|
-
"allows_promise_then": False,
|
|
53
|
-
},
|
|
54
|
-
"beforeNextStepScript": {
|
|
55
|
-
"site_name": "beforeNextStepScript",
|
|
56
|
-
"runtime_kind": "backend_flow_hook",
|
|
57
|
-
"supports_await": True,
|
|
58
|
-
"requires_return_wrapper": False,
|
|
59
|
-
"recommended_max_lines": 120,
|
|
60
|
-
"allowed_side_effects": ["step_guard", "query", "state_patch", "external_sync", "import_server_script"],
|
|
61
|
-
"preferred_pattern": "guard; normalize; fetch; decide; apply; return",
|
|
62
|
-
"forbidden_pattern": "mixed validation, notification, and persistence branches in one flat function",
|
|
63
|
-
"allows_promise_then": False,
|
|
64
|
-
},
|
|
65
|
-
"project_create_validator": {
|
|
66
|
-
"site_name": "project_create_validator",
|
|
67
|
-
"runtime_kind": "backend_create_hook",
|
|
68
|
-
"supports_await": True,
|
|
69
|
-
"requires_return_wrapper": True,
|
|
70
|
-
"recommended_max_lines": 120,
|
|
71
|
-
"allowed_side_effects": ["query", "return_validation_result", "import_server_script"],
|
|
72
|
-
"preferred_pattern": "return (async () => { guard; fetch; validate; return message_or_empty; })();",
|
|
73
|
-
"forbidden_pattern": "nested then chains, writeback, or mixed callback side effects",
|
|
74
|
-
"allows_promise_then": False,
|
|
75
|
-
},
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
DEFAULT_DUPLICATE_LINE_THRESHOLD = 3
|
|
79
|
-
DEFAULT_BRANCH_BUDGET = {
|
|
80
|
-
"lambda": 4,
|
|
81
|
-
"customeValidate": 4,
|
|
82
|
-
"es_project_selector_search": 6,
|
|
83
|
-
"pre_process_script": 8,
|
|
84
|
-
"beforeNextStepScript": 12,
|
|
85
|
-
"project_create_validator": 8,
|
|
86
|
-
}
|
|
87
|
-
EXTERNAL_CALL_PATTERN = re.compile(
|
|
88
|
-
r"ctx\.\$(?:axios|esQuery|proxyRequest|proxy|query|importServerScript|model)\b|ctx\.axios\b"
|
|
89
|
-
)
|
|
90
|
-
BRANCH_PATTERN = re.compile(r"^\s*(?:if|else\s+if|switch|case|catch|for|while)\b")
|
|
91
|
-
RETURN_WRAPPER_PATTERN = re.compile(r"return\s*\(\s*async\s*\(\s*\)\s*=>\s*\{", re.MULTILINE)
|
|
92
|
-
THEN_PATTERN = re.compile(r"\.then\s*\(")
|
|
93
|
-
AWAIT_PATTERN = re.compile(r"\bawait\b")
|
|
94
|
-
PROJECT_LIST_PATTERN = re.compile(r"/bpmax/project/list|ESProjectList|esProjectList")
|
|
95
|
-
SQL_JOIN_PATTERN = re.compile(r"\bselect\b[\s\S]{0,800}\bjoin\b", re.IGNORECASE)
|
|
96
|
-
ES_QUERY_PATTERN = re.compile(r"raw-es-search|ctx\.\$esQuery", re.IGNORECASE)
|
|
97
|
-
ES_SIZE_PATTERN = re.compile(r"\bsize\s*:\s*(\d{3,})\b")
|
|
98
|
-
SCRIPT_MATCH_PATTERN = re.compile(r"\.(?:find|filter|some)\s*\(|\.includes\s*\(")
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
def _finding(code: str, message: str, *, snippet: str, line: int | None = None) -> dict[str, Any]:
|
|
102
|
-
return {
|
|
103
|
-
"code": code,
|
|
104
|
-
"message": message,
|
|
105
|
-
"line": line,
|
|
106
|
-
"snippet": snippet[:240],
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
def _significant_lines(source: str) -> list[str]:
|
|
111
|
-
return [line.rstrip() for line in source.splitlines() if line.strip()]
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
def _line_budget_error(rule: dict[str, Any]) -> str:
|
|
115
|
-
return (
|
|
116
|
-
f"script exceeds the recommended {rule['recommended_max_lines']}-line budget; "
|
|
117
|
-
"split it into a thin orchestration script plus helper/server script or data mapping table"
|
|
118
|
-
)
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
def _strip_allowed_async_wrappers(source: str) -> str:
|
|
122
|
-
text = source
|
|
123
|
-
while True:
|
|
124
|
-
match = RETURN_WRAPPER_PATTERN.search(text)
|
|
125
|
-
if match is None:
|
|
126
|
-
return text
|
|
127
|
-
start = match.start()
|
|
128
|
-
brace_depth = 1
|
|
129
|
-
idx = match.end()
|
|
130
|
-
while idx < len(text) and brace_depth > 0:
|
|
131
|
-
char = text[idx]
|
|
132
|
-
if char == "{":
|
|
133
|
-
brace_depth += 1
|
|
134
|
-
elif char == "}":
|
|
135
|
-
brace_depth -= 1
|
|
136
|
-
idx += 1
|
|
137
|
-
if brace_depth != 0:
|
|
138
|
-
return text
|
|
139
|
-
tail = text[idx:]
|
|
140
|
-
tail_match = re.match(r"\s*\)\s*\(\s*\)\s*;", tail)
|
|
141
|
-
if tail_match is None:
|
|
142
|
-
return text
|
|
143
|
-
end = idx + tail_match.end()
|
|
144
|
-
text = text[:start] + text[end:]
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
def lint_runtime_script(site_name: str, source: str) -> dict[str, Any]:
|
|
148
|
-
rule = SCRIPT_SITE_MATRIX.get(site_name)
|
|
149
|
-
if rule is None:
|
|
150
|
-
raise KeyError(f"unknown runtime script site: {site_name}")
|
|
151
|
-
|
|
152
|
-
findings: list[dict[str, Any]] = []
|
|
153
|
-
errors: list[str] = []
|
|
154
|
-
warnings: list[str] = []
|
|
155
|
-
|
|
156
|
-
significant_lines = _significant_lines(source)
|
|
157
|
-
line_count = len(significant_lines)
|
|
158
|
-
branch_count = sum(1 for line in significant_lines if BRANCH_PATTERN.search(line))
|
|
159
|
-
external_call_count = len(EXTERNAL_CALL_PATTERN.findall(source))
|
|
160
|
-
|
|
161
|
-
if PROJECT_LIST_PATTERN.search(source):
|
|
162
|
-
finding = _finding(
|
|
163
|
-
"project_list_forbidden",
|
|
164
|
-
(
|
|
165
|
-
f"{site_name} must not use `/bpmax/project/list` or user-scope "
|
|
166
|
-
"ESProjectList; use raw-es-search with data_set_key or backend "
|
|
167
|
-
"ctx.$esQuery instead"
|
|
168
|
-
),
|
|
169
|
-
snippet=source,
|
|
170
|
-
)
|
|
171
|
-
findings.append(finding)
|
|
172
|
-
errors.append(finding["message"])
|
|
173
|
-
|
|
174
|
-
if SQL_JOIN_PATTERN.search(source):
|
|
175
|
-
finding = _finding(
|
|
176
|
-
"sql_join_forbidden",
|
|
177
|
-
(
|
|
178
|
-
f"{site_name} must not use complex SQL join queries for BPMAX dataset lookup; "
|
|
179
|
-
"query the needed ES dataset directly with raw-es-search + data_set_key "
|
|
180
|
-
"or a verified backend helper"
|
|
181
|
-
),
|
|
182
|
-
snippet=source,
|
|
183
|
-
)
|
|
184
|
-
findings.append(finding)
|
|
185
|
-
errors.append(finding["message"])
|
|
186
|
-
|
|
187
|
-
has_large_es_pull = ES_QUERY_PATTERN.search(source) and any(
|
|
188
|
-
int(match.group(1)) >= 500 for match in ES_SIZE_PATTERN.finditer(source)
|
|
189
|
-
)
|
|
190
|
-
if has_large_es_pull and SCRIPT_MATCH_PATTERN.search(source):
|
|
191
|
-
finding = _finding(
|
|
192
|
-
"bulk_es_script_matching",
|
|
193
|
-
(
|
|
194
|
-
f"{site_name} must not pull a large ES dataset and match rows in script; "
|
|
195
|
-
"push the match condition into raw-es-search/ctx.$esQuery and request "
|
|
196
|
-
"only the needed rows"
|
|
197
|
-
),
|
|
198
|
-
snippet=source,
|
|
199
|
-
)
|
|
200
|
-
findings.append(finding)
|
|
201
|
-
errors.append(finding["message"])
|
|
202
|
-
|
|
203
|
-
if line_count > rule["recommended_max_lines"]:
|
|
204
|
-
finding = _finding(
|
|
205
|
-
"line_budget_exceeded",
|
|
206
|
-
_line_budget_error(rule),
|
|
207
|
-
snippet=significant_lines[0] if significant_lines else "",
|
|
208
|
-
line=1 if significant_lines else None,
|
|
209
|
-
)
|
|
210
|
-
findings.append(finding)
|
|
211
|
-
errors.append(finding["message"])
|
|
212
|
-
|
|
213
|
-
if not rule.get("allows_promise_then", False) and THEN_PATTERN.search(source):
|
|
214
|
-
finding = _finding(
|
|
215
|
-
"forbidden_promise_then",
|
|
216
|
-
f"{site_name} should default to async/await, not Promise.then chains",
|
|
217
|
-
snippet=source,
|
|
218
|
-
)
|
|
219
|
-
findings.append(finding)
|
|
220
|
-
errors.append(finding["message"])
|
|
221
|
-
|
|
222
|
-
if rule.get("supports_await") and rule.get("requires_return_wrapper") and AWAIT_PATTERN.search(source):
|
|
223
|
-
residual_source = _strip_allowed_async_wrappers(source)
|
|
224
|
-
if AWAIT_PATTERN.search(residual_source):
|
|
225
|
-
finding = _finding(
|
|
226
|
-
"await_requires_wrapper",
|
|
227
|
-
f"{site_name} may use await only inside `return (async () => {{ ... }})();`",
|
|
228
|
-
snippet=source,
|
|
229
|
-
)
|
|
230
|
-
findings.append(finding)
|
|
231
|
-
errors.append(finding["message"])
|
|
232
|
-
|
|
233
|
-
if not rule.get("supports_await") and AWAIT_PATTERN.search(source):
|
|
234
|
-
finding = _finding(
|
|
235
|
-
"await_not_supported",
|
|
236
|
-
f"{site_name} does not support await in its runtime contract",
|
|
237
|
-
snippet=source,
|
|
238
|
-
)
|
|
239
|
-
findings.append(finding)
|
|
240
|
-
errors.append(finding["message"])
|
|
241
|
-
|
|
242
|
-
branch_budget = DEFAULT_BRANCH_BUDGET.get(site_name, 8)
|
|
243
|
-
if branch_count > branch_budget:
|
|
244
|
-
warnings.append(
|
|
245
|
-
f"{site_name} uses {branch_count} branches, above the recommended budget of {branch_budget}"
|
|
246
|
-
)
|
|
247
|
-
|
|
248
|
-
normalized_lines = [re.sub(r"\s+", " ", line).strip() for line in significant_lines if len(line.strip()) >= 16]
|
|
249
|
-
duplicates = [line for line, count in Counter(normalized_lines).items() if count >= DEFAULT_DUPLICATE_LINE_THRESHOLD]
|
|
250
|
-
if duplicates:
|
|
251
|
-
warnings.append(
|
|
252
|
-
f"{site_name} has duplicated fragments; prefer helper extraction or a mapping table: {duplicates[0][:80]}"
|
|
253
|
-
)
|
|
254
|
-
|
|
255
|
-
if external_call_count > 2:
|
|
256
|
-
warnings.append(
|
|
257
|
-
f"{site_name} performs {external_call_count} external calls; consider helper extraction or staged orchestration"
|
|
258
|
-
)
|
|
259
|
-
|
|
260
|
-
return {
|
|
261
|
-
"ok": not errors,
|
|
262
|
-
"site": site_name,
|
|
263
|
-
"rule": rule,
|
|
264
|
-
"errors": errors,
|
|
265
|
-
"warnings": warnings,
|
|
266
|
-
"findings": findings,
|
|
267
|
-
"stats": {
|
|
268
|
-
"line_count": line_count,
|
|
269
|
-
"branch_count": branch_count,
|
|
270
|
-
"external_call_count": external_call_count,
|
|
271
|
-
},
|
|
272
|
-
}
|
|
@@ -1,374 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
from __future__ import annotations
|
|
3
|
-
|
|
4
|
-
import argparse
|
|
5
|
-
import json
|
|
6
|
-
import re
|
|
7
|
-
from pathlib import Path
|
|
8
|
-
from typing import Any, Iterable
|
|
9
|
-
|
|
10
|
-
from runtime_script_rules import SCRIPT_SITE_MATRIX, lint_runtime_script
|
|
11
|
-
from template_script_hard_rules import contains_user_scope_project_list_query
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
HARD_CODED_ORIGIN_PATTERN = re.compile(
|
|
15
|
-
r"https?://(?!(?:bpmax|sysconfigdiff|git)\.example\.com\b)(?:[A-Za-z0-9-]+\.)+(?:local|test|dev|prod|com|cn)(?:/api)?"
|
|
16
|
-
)
|
|
17
|
-
UNIMPLEMENTED_DOC_PATTERNS = (
|
|
18
|
-
re.compile(r"scripts/\s*未落地"),
|
|
19
|
-
re.compile(r"脚本未落地"),
|
|
20
|
-
re.compile(r"当前仓库里这些脚本还不存在"),
|
|
21
|
-
re.compile(r"还没有\s+`?scripts/?`?\s+目录"),
|
|
22
|
-
re.compile(r"后续必须先把对应脚本落地"),
|
|
23
|
-
)
|
|
24
|
-
SCRIPT_REFERENCE_PATTERN = re.compile(r"`((?:[\w./-]+/)?[\w.-]+\.py)`")
|
|
25
|
-
FORBIDDEN_PROMISE_THEN_PATTERN = re.compile(r"\.then\s*\(")
|
|
26
|
-
GOVERNANCE_REFERENCE_PATTERNS = (
|
|
27
|
-
re.compile(r"runtime-script-site-matrix(?:\.md|\.json)?"),
|
|
28
|
-
re.compile(r"runtime-script-template-catalog(?:\.md)?"),
|
|
29
|
-
)
|
|
30
|
-
SCRIPT_GOVERNANCE_SITE_PATTERN = re.compile(
|
|
31
|
-
r"\blambda\b|customeValidate|pre_process_script|beforeNextStepScript|project_create_validator"
|
|
32
|
-
)
|
|
33
|
-
SCRIPT_GOVERNANCE_CONTEXT_PATTERN = re.compile(r"脚本|ctx\.|抽取|回写|单行化|writeback|patch|生成")
|
|
34
|
-
SECTION_HEADING_PATTERN = re.compile(r"^##\s+`?([A-Za-z_][A-Za-z0-9_-]*)`?\s*$")
|
|
35
|
-
TEXT_SUFFIXES = {".md", ".py", ".json", ".yaml", ".yml", ".txt"}
|
|
36
|
-
PROJECT_LIST_VERIFICATION_CONTEXT_PATTERN = re.compile(
|
|
37
|
-
r"验收|验证|回读|真实请求体|真实触发|请求级验证|结果级验证|自动发起|空态|列表页行为|观察"
|
|
38
|
-
)
|
|
39
|
-
PROJECT_LIST_GUIDANCE_CONTEXT_PATTERN = re.compile(
|
|
40
|
-
r"默认|优先|统一|建议|联动|初始化|回填|校验|查库存|查商品|查项目|ctx\.(?:\$axios|axios)|ESProjectList|esProjectList"
|
|
41
|
-
)
|
|
42
|
-
PROJECT_LIST_PROHIBITION_CONTEXT_PATTERN = re.compile(r"禁止|不得|不准|不能|must not|forbid", re.IGNORECASE)
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
def _finding(code: str, file_path: Path, line_no: int, message: str, snippet: str) -> dict[str, Any]:
|
|
46
|
-
return {
|
|
47
|
-
"code": code,
|
|
48
|
-
"file": file_path.as_posix(),
|
|
49
|
-
"line": line_no,
|
|
50
|
-
"message": message,
|
|
51
|
-
"snippet": snippet[:240],
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
def _iter_text_files(skill_root: Path) -> Iterable[Path]:
|
|
56
|
-
for path in sorted(skill_root.rglob("*")):
|
|
57
|
-
if not path.is_file() or path.suffix.lower() not in TEXT_SUFFIXES:
|
|
58
|
-
continue
|
|
59
|
-
if "tests" in path.relative_to(skill_root).parts:
|
|
60
|
-
continue
|
|
61
|
-
if path.suffix.lower() == ".py" and "scripts" not in path.relative_to(skill_root).parts:
|
|
62
|
-
continue
|
|
63
|
-
yield path
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
def _script_index(skill_root: Path) -> tuple[set[str], set[str]]:
|
|
67
|
-
script_names: set[str] = set()
|
|
68
|
-
relative_paths: set[str] = set()
|
|
69
|
-
for path in skill_root.rglob("*.py"):
|
|
70
|
-
script_names.add(path.name)
|
|
71
|
-
relative_paths.add(path.relative_to(skill_root).as_posix())
|
|
72
|
-
return script_names, relative_paths
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
def _scan_hardcoded_origins(path: Path, text: str) -> list[dict[str, Any]]:
|
|
76
|
-
findings: list[dict[str, Any]] = []
|
|
77
|
-
for line_no, line in enumerate(text.splitlines(), start=1):
|
|
78
|
-
if HARD_CODED_ORIGIN_PATTERN.search(line):
|
|
79
|
-
findings.append(
|
|
80
|
-
_finding(
|
|
81
|
-
"hardcoded_domain",
|
|
82
|
-
path,
|
|
83
|
-
line_no,
|
|
84
|
-
"Hardcoded BPMAX environment origin should be removed from skill-local docs or scripts.",
|
|
85
|
-
line.strip(),
|
|
86
|
-
)
|
|
87
|
-
)
|
|
88
|
-
return findings
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
def _scan_unimplemented_claims(path: Path, text: str, *, has_scripts: bool) -> list[dict[str, Any]]:
|
|
92
|
-
if not has_scripts or path.suffix.lower() != ".md":
|
|
93
|
-
return []
|
|
94
|
-
findings: list[dict[str, Any]] = []
|
|
95
|
-
for line_no, line in enumerate(text.splitlines(), start=1):
|
|
96
|
-
if any(pattern.search(line) for pattern in UNIMPLEMENTED_DOC_PATTERNS):
|
|
97
|
-
findings.append(
|
|
98
|
-
_finding(
|
|
99
|
-
"doc_claims_scripts_unimplemented",
|
|
100
|
-
path,
|
|
101
|
-
line_no,
|
|
102
|
-
"Documentation says scripts are not landed even though the skill already ships scripts.",
|
|
103
|
-
line.strip(),
|
|
104
|
-
)
|
|
105
|
-
)
|
|
106
|
-
return findings
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
def _scan_missing_script_references(
|
|
110
|
-
path: Path,
|
|
111
|
-
text: str,
|
|
112
|
-
*,
|
|
113
|
-
script_names: set[str],
|
|
114
|
-
relative_paths: set[str],
|
|
115
|
-
skill_root: Path,
|
|
116
|
-
) -> list[dict[str, Any]]:
|
|
117
|
-
if path.suffix.lower() != ".md":
|
|
118
|
-
return []
|
|
119
|
-
findings: list[dict[str, Any]] = []
|
|
120
|
-
for line_no, line in enumerate(text.splitlines(), start=1):
|
|
121
|
-
for ref in SCRIPT_REFERENCE_PATTERN.findall(line):
|
|
122
|
-
normalized = ref.lstrip("./")
|
|
123
|
-
candidates = {
|
|
124
|
-
normalized,
|
|
125
|
-
f"scripts/{Path(normalized).name}",
|
|
126
|
-
}
|
|
127
|
-
if any(candidate in relative_paths for candidate in candidates):
|
|
128
|
-
continue
|
|
129
|
-
if Path(normalized).name in script_names:
|
|
130
|
-
continue
|
|
131
|
-
if (skill_root / normalized).exists():
|
|
132
|
-
continue
|
|
133
|
-
findings.append(
|
|
134
|
-
_finding(
|
|
135
|
-
"doc_references_missing_script",
|
|
136
|
-
path,
|
|
137
|
-
line_no,
|
|
138
|
-
f"Documentation references missing script `{ref}`.",
|
|
139
|
-
line.strip(),
|
|
140
|
-
)
|
|
141
|
-
)
|
|
142
|
-
return findings
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
def _scan_missing_runtime_script_governance_reference(skill_root: Path, markdown_files: list[tuple[Path, str]]) -> list[dict[str, Any]]:
|
|
146
|
-
if not markdown_files:
|
|
147
|
-
return []
|
|
148
|
-
requires_governance = False
|
|
149
|
-
for _, text in markdown_files:
|
|
150
|
-
for line in text.splitlines():
|
|
151
|
-
if SCRIPT_GOVERNANCE_SITE_PATTERN.search(line) and SCRIPT_GOVERNANCE_CONTEXT_PATTERN.search(line):
|
|
152
|
-
requires_governance = True
|
|
153
|
-
break
|
|
154
|
-
if requires_governance:
|
|
155
|
-
break
|
|
156
|
-
if not requires_governance:
|
|
157
|
-
return []
|
|
158
|
-
has_reference = any(
|
|
159
|
-
any(pattern.search(text) for pattern in GOVERNANCE_REFERENCE_PATTERNS)
|
|
160
|
-
for _, text in markdown_files
|
|
161
|
-
)
|
|
162
|
-
if has_reference:
|
|
163
|
-
return []
|
|
164
|
-
target_path = next((path for path, _ in markdown_files if path.name == "SKILL.md"), markdown_files[0][0])
|
|
165
|
-
return [
|
|
166
|
-
_finding(
|
|
167
|
-
"missing_runtime_script_governance_reference",
|
|
168
|
-
target_path,
|
|
169
|
-
1,
|
|
170
|
-
"Runtime-script-heavy skills must reference the bpmax-builder-shared script site matrix or template catalog.",
|
|
171
|
-
"missing bpmax-builder-shared runtime script governance reference",
|
|
172
|
-
)
|
|
173
|
-
]
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
def _extract_markdown_code_fences(text: str) -> list[dict[str, Any]]:
|
|
177
|
-
fences: list[dict[str, Any]] = []
|
|
178
|
-
current_site: str | None = None
|
|
179
|
-
in_code = False
|
|
180
|
-
code_language = ""
|
|
181
|
-
code_start = 0
|
|
182
|
-
code_lines: list[str] = []
|
|
183
|
-
|
|
184
|
-
def flush_code() -> None:
|
|
185
|
-
nonlocal code_lines
|
|
186
|
-
fences.append(
|
|
187
|
-
{
|
|
188
|
-
"site": current_site,
|
|
189
|
-
"language": code_language,
|
|
190
|
-
"start_line": code_start,
|
|
191
|
-
"code": "\n".join(code_lines),
|
|
192
|
-
}
|
|
193
|
-
)
|
|
194
|
-
code_lines = []
|
|
195
|
-
|
|
196
|
-
for line_no, line in enumerate(text.splitlines(), start=1):
|
|
197
|
-
heading = SECTION_HEADING_PATTERN.match(line)
|
|
198
|
-
if not in_code and heading:
|
|
199
|
-
current_site = heading.group(1)
|
|
200
|
-
continue
|
|
201
|
-
|
|
202
|
-
if line.startswith("```"):
|
|
203
|
-
if not in_code:
|
|
204
|
-
in_code = True
|
|
205
|
-
code_language = line[3:].strip().lower()
|
|
206
|
-
code_start = line_no + 1
|
|
207
|
-
code_lines = []
|
|
208
|
-
else:
|
|
209
|
-
flush_code()
|
|
210
|
-
in_code = False
|
|
211
|
-
code_language = ""
|
|
212
|
-
continue
|
|
213
|
-
|
|
214
|
-
if in_code:
|
|
215
|
-
code_lines.append(line)
|
|
216
|
-
|
|
217
|
-
if in_code:
|
|
218
|
-
flush_code()
|
|
219
|
-
return fences
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
def _scan_forbidden_promise_then(path: Path, text: str) -> list[dict[str, Any]]:
|
|
223
|
-
findings: list[dict[str, Any]] = []
|
|
224
|
-
for fence in _extract_markdown_code_fences(text):
|
|
225
|
-
if fence["language"] not in ("js", "javascript"):
|
|
226
|
-
continue
|
|
227
|
-
code = str(fence["code"])
|
|
228
|
-
if "allow-then" in code:
|
|
229
|
-
continue
|
|
230
|
-
if FORBIDDEN_PROMISE_THEN_PATTERN.search(code):
|
|
231
|
-
findings.append(
|
|
232
|
-
_finding(
|
|
233
|
-
"forbidden_promise_then",
|
|
234
|
-
path,
|
|
235
|
-
int(fence["start_line"]),
|
|
236
|
-
"Runtime script examples should default to async/await, not Promise.then chains.",
|
|
237
|
-
code.strip(),
|
|
238
|
-
)
|
|
239
|
-
)
|
|
240
|
-
return findings
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
def _scan_runtime_script_code_fences(path: Path, text: str) -> list[dict[str, Any]]:
|
|
244
|
-
findings: list[dict[str, Any]] = []
|
|
245
|
-
for fence in _extract_markdown_code_fences(text):
|
|
246
|
-
site_name = fence["site"]
|
|
247
|
-
if site_name is None or site_name not in SCRIPT_SITE_MATRIX:
|
|
248
|
-
continue
|
|
249
|
-
if fence["language"] not in ("js", "javascript"):
|
|
250
|
-
continue
|
|
251
|
-
report = lint_runtime_script(str(site_name), str(fence["code"]))
|
|
252
|
-
for item in report["findings"]:
|
|
253
|
-
findings.append(
|
|
254
|
-
_finding(
|
|
255
|
-
item["code"],
|
|
256
|
-
path,
|
|
257
|
-
int(fence["start_line"]),
|
|
258
|
-
item["message"],
|
|
259
|
-
item["snippet"],
|
|
260
|
-
)
|
|
261
|
-
)
|
|
262
|
-
return findings
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
def _scan_project_list_guidance(path: Path, text: str) -> list[dict[str, Any]]:
|
|
266
|
-
if path.suffix.lower() != ".md":
|
|
267
|
-
return []
|
|
268
|
-
findings: list[dict[str, Any]] = []
|
|
269
|
-
in_code = False
|
|
270
|
-
for line_no, line in enumerate(text.splitlines(), start=1):
|
|
271
|
-
if line.startswith("```"):
|
|
272
|
-
in_code = not in_code
|
|
273
|
-
continue
|
|
274
|
-
if in_code:
|
|
275
|
-
continue
|
|
276
|
-
if not contains_user_scope_project_list_query(line):
|
|
277
|
-
continue
|
|
278
|
-
if PROJECT_LIST_PROHIBITION_CONTEXT_PATTERN.search(line):
|
|
279
|
-
continue
|
|
280
|
-
if PROJECT_LIST_VERIFICATION_CONTEXT_PATTERN.search(line):
|
|
281
|
-
continue
|
|
282
|
-
if not PROJECT_LIST_GUIDANCE_CONTEXT_PATTERN.search(line):
|
|
283
|
-
continue
|
|
284
|
-
findings.append(
|
|
285
|
-
_finding(
|
|
286
|
-
"project_list_guidance_forbidden",
|
|
287
|
-
path,
|
|
288
|
-
line_no,
|
|
289
|
-
"Documentation must not recommend `/bpmax/project/list` or user-scope ESProjectList in runtime scripts.",
|
|
290
|
-
line.strip(),
|
|
291
|
-
)
|
|
292
|
-
)
|
|
293
|
-
return findings
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
def _scan_project_list_code_fences(path: Path, text: str) -> list[dict[str, Any]]:
|
|
297
|
-
if path.suffix.lower() != ".md":
|
|
298
|
-
return []
|
|
299
|
-
findings: list[dict[str, Any]] = []
|
|
300
|
-
for fence in _extract_markdown_code_fences(text):
|
|
301
|
-
if fence["language"] not in ("js", "javascript"):
|
|
302
|
-
continue
|
|
303
|
-
code = str(fence["code"])
|
|
304
|
-
if not contains_user_scope_project_list_query(code):
|
|
305
|
-
continue
|
|
306
|
-
findings.append(
|
|
307
|
-
_finding(
|
|
308
|
-
"project_list_code_fence_forbidden",
|
|
309
|
-
path,
|
|
310
|
-
int(fence["start_line"]),
|
|
311
|
-
"Runtime script examples must not use `/bpmax/project/list` or user-scope ESProjectList.",
|
|
312
|
-
code.strip(),
|
|
313
|
-
)
|
|
314
|
-
)
|
|
315
|
-
return findings
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
def audit_skill_root(skill_root: str | Path) -> dict[str, Any]:
|
|
319
|
-
root = Path(skill_root).resolve()
|
|
320
|
-
script_names, relative_paths = _script_index(root)
|
|
321
|
-
findings: list[dict[str, Any]] = []
|
|
322
|
-
markdown_files: list[tuple[Path, str]] = []
|
|
323
|
-
for path in _iter_text_files(root):
|
|
324
|
-
text = path.read_text(encoding="utf-8")
|
|
325
|
-
if path.suffix.lower() == ".md":
|
|
326
|
-
markdown_files.append((path, text))
|
|
327
|
-
findings.extend(_scan_hardcoded_origins(path, text))
|
|
328
|
-
findings.extend(_scan_unimplemented_claims(path, text, has_scripts=bool(script_names)))
|
|
329
|
-
findings.extend(
|
|
330
|
-
_scan_missing_script_references(
|
|
331
|
-
path,
|
|
332
|
-
text,
|
|
333
|
-
script_names=script_names,
|
|
334
|
-
relative_paths=relative_paths,
|
|
335
|
-
skill_root=root,
|
|
336
|
-
)
|
|
337
|
-
)
|
|
338
|
-
findings.extend(_scan_forbidden_promise_then(path, text))
|
|
339
|
-
findings.extend(_scan_project_list_guidance(path, text))
|
|
340
|
-
findings.extend(_scan_project_list_code_fences(path, text))
|
|
341
|
-
findings.extend(_scan_runtime_script_code_fences(path, text))
|
|
342
|
-
findings.extend(_scan_missing_runtime_script_governance_reference(root, markdown_files))
|
|
343
|
-
findings.sort(key=lambda item: (item["file"], item["line"], item["code"]))
|
|
344
|
-
return {
|
|
345
|
-
"ok": not findings,
|
|
346
|
-
"root": root.as_posix(),
|
|
347
|
-
"errors": [f"{item['file']}:{item['line']} {item['message']}" for item in findings],
|
|
348
|
-
"findings": findings,
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
def audit_skill_roots(skill_roots: Iterable[str | Path]) -> dict[str, Any]:
|
|
353
|
-
reports = [audit_skill_root(root) for root in skill_roots]
|
|
354
|
-
findings = [finding for report in reports for finding in report["findings"]]
|
|
355
|
-
return {
|
|
356
|
-
"ok": not findings,
|
|
357
|
-
"roots": [report["root"] for report in reports],
|
|
358
|
-
"errors": [error for report in reports for error in report["errors"]],
|
|
359
|
-
"findings": findings,
|
|
360
|
-
"reports": reports,
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
def main(argv: list[str] | None = None) -> int:
|
|
365
|
-
parser = argparse.ArgumentParser(description="Audit BPMAX skill docs and scripts for stale contracts.")
|
|
366
|
-
parser.add_argument("skill_roots", nargs="+", help="Skill root directories to audit.")
|
|
367
|
-
args = parser.parse_args(argv)
|
|
368
|
-
report = audit_skill_roots(args.skill_roots)
|
|
369
|
-
print(json.dumps(report, ensure_ascii=False, indent=2))
|
|
370
|
-
return 0 if report["ok"] else 1
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
if __name__ == "__main__":
|
|
374
|
-
raise SystemExit(main())
|