bugx-cli 0.1.1__py3-none-any.whl
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.
- bugx_cli/__init__.py +6 -0
- bugx_cli/cli.py +1685 -0
- bugx_cli/commands/__init__.py +1 -0
- bugx_cli/commands/advisory.py +94 -0
- bugx_cli/commands/agent.py +4210 -0
- bugx_cli/commands/audit.py +632 -0
- bugx_cli/commands/autonomous.py +260 -0
- bugx_cli/commands/cloud.py +1371 -0
- bugx_cli/commands/daemon.py +50 -0
- bugx_cli/commands/doctor.py +1590 -0
- bugx_cli/commands/goal.py +107 -0
- bugx_cli/commands/interaction.py +248 -0
- bugx_cli/commands/knowledge.py +619 -0
- bugx_cli/commands/lifecycle.py +2763 -0
- bugx_cli/commands/patch.py +1014 -0
- bugx_cli/commands/plugin.py +2749 -0
- bugx_cli/commands/plugin_claude.py +1446 -0
- bugx_cli/commands/plugin_cline.py +269 -0
- bugx_cli/commands/plugin_codex.py +74 -0
- bugx_cli/commands/plugin_funide.py +729 -0
- bugx_cli/commands/plugin_qoder.py +216 -0
- bugx_cli/commands/plugin_zcode.py +710 -0
- bugx_cli/commands/project.py +670 -0
- bugx_cli/commands/report.py +256 -0
- bugx_cli/commands/skill.py +251 -0
- bugx_cli/commands/stats.py +133 -0
- bugx_cli/commands/system.py +2567 -0
- bugx_cli/common.py +906 -0
- bugx_cli/host_adapters.py +1892 -0
- bugx_cli/hosts/__init__.py +80 -0
- bugx_cli/hosts/base.py +99 -0
- bugx_cli/hosts/registry.py +573 -0
- bugx_cli/hosts/template_engine.py +188 -0
- bugx_cli/infra/__init__.py +209 -0
- bugx_cli/infra/ai_advisor.py +851 -0
- bugx_cli/infra/engine_installer.py +1945 -0
- bugx_cli/infra/host_sync.py +548 -0
- bugx_cli/infra/mcp_advisor.py +826 -0
- bugx_cli/infra/security.py +339 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/bugx-mcp-manifest.json +53 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/CATALOG.json +141 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/README.md +254 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/README.md +35 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/android-interaction.json +81 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/android.json +24 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/desktop-macos.json +20 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/ios-interaction.json +34 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/ios.json +23 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/memory-macos.json +24 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/README.md +51 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/__init__.py +146 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/agent_artifacts.py +766 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/agent_eval.py +1155 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/agent_execution.py +718 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/agent_orchestrator.py +1351 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/agent_targets.py +877 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/agent_workspace.py +770 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/feature_baseline.py +150 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/README.md +24 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/axe-core/LICENSE-3RD-PARTY.txt +66 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/axe-core/LICENSE.txt +362 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/axe-core/UPSTREAM.md +10 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/axe-core/axe.min.js +12 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-avatar-1024.png +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-avatar-512.png +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-avatar-tight.svg +23 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-avatar.svg +28 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-hero-cn.png +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-hero-en.png +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-hero-en.svg +74 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-hero-zh.svg +74 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/codex.png +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/dsh.png +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/project-layout.md +42 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/zcode.png +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/README.md +37 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/data-audit/manifest.json +94 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/data-audit/stages/00-scope.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/data-audit/stages/10-schema-inventory.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/data-audit/stages/20-query-and-integrity.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/data-audit/stages/80-evidence-regression.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/desktop-audit/manifest.json +123 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/desktop-audit/stages/00-scope.md +15 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/desktop-audit/stages/10-process-model.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/desktop-audit/stages/20-package-integrity.md +15 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/desktop-audit/stages/30-ui-behavior.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/desktop-audit/stages/80-evidence-regression.md +15 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/memory-testing.md +227 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/manifest.json +155 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/modules/android.md +19 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/modules/h5.md +18 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/modules/ios.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/modules/miniprogram.md +26 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/modules/webview.md +18 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/stages/00-scope.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/stages/10-platform-inventory.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/stages/20-masvs-static.md +20 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/stages/30-component-exposure.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/stages/40-device-behavior.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/stages/80-evidence-regression.md +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/native-audit/manifest.json +127 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/native-audit/stages/00-scope.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/native-audit/stages/10-static-white-box.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/native-audit/stages/20-memory-concurrency.md +15 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/native-audit/stages/30-behavior-black-box.md +39 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/native-audit/stages/80-evidence-regression.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/platform-testing.md +174 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/manifest.json +191 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/modules/graphql.md +5 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/modules/h5.md +18 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/modules/multi-tenant.md +4 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/modules/oauth.md +4 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/modules/upload.md +4 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/modules/websocket.md +4 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/00-scope.md +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/10-discovery.md +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/20-auth-session.md +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/30-authz-business.md +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/40-input-output.md +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/50-state-async.md +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/60-file-ssrf-deser.md +12 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/70-config-dependency.md +12 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/80-evidence-regression.md +12 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/INTERFACE.md +61 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/README.md +58 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/__init__.py +109 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/attack_graph.py +1096 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/attack_graph_store.py +1868 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/audit_campaign.py +1232 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/behavior_graph.py +465 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/ghsa_advisories.py +174 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/models.py +93 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/mutator.py +87 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/patcher.py +126 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/scout.py +278 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/synthesizer.py +207 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/verifier.py +103 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/bugx.md +1299 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/bugx_paths.py +1881 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cli-help.txt +66 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/INTERFACE.md +32 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/README.md +62 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/__init__.py +23 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/auto_sync.py +398 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/cloud_client.py +1218 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/cloud_onboard.py +743 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/cloud_schema.py +648 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/consent.py +81 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/device_identity.py +307 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/endpoint_router.py +415 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/flywheel_client.py +769 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/network_transport.py +296 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/onboard_wizard.py +493 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/sensitive_filter.py +285 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/sync_pull.py +695 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/sync_push.py +723 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/AGENT_GUIDE.md +359 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/README.md +34 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/bugx-blackbox.md +541 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/bugx-opencode.md +469 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/bugx-quick.md +44 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/bugx-runtime-contract.md +353 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/bugx-worker.md +470 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/engine_gap_contracts.py +473 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/README.md +70 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/__init__.py +106 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_ai_review.py +185 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_backfill.py +54 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_bootstrap.py +713 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_business.py +36 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_cli.py +715 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_discovery.py +1429 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_evidence.py +1024 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_forensics.py +124 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_gate.py +277 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_intelligence.py +734 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_manifest.py +396 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_platform.py +77 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_validate.py +241 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/module_coverage.py +157 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/dev_harness/INTERFACE.md +20 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/dev_harness/README.md +21 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/dev_harness/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/dev_harness/__init__.py +5 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/dev_harness/interaction_preset.py +408 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/engine-integrity.json +2797 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/fuzzing/README.md +49 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/fuzzing/__init__.py +82 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/fuzzing/concurrency_fuzzer.py +435 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/fuzzing/differential_oracle.py +1164 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/fuzzing/fuzz_input.py +1291 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/fuzzing/stateful_fuzzer.py +404 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/README.md +61 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/__init__.py +130 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/capacity_planner.py +124 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/dependency_lock.py +317 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/goal_governor.py +754 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/guide_budget.py +458 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/lockdown.sh +50 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/readonly_enforcer.py +154 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/runtime_tool_gate.py +373 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/secret_redactor.py +784 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/token_budget.py +38 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/INTERFACE.md +36 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/README.md +51 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/__init__.py +121 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/base.py +111 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/claude.py +99 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/cline.py +298 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/codex.py +300 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/dsh.py +106 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/opencode.py +209 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/pi.py +94 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/zcode.py +99 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/INTERFACE.md +24 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/README.md +62 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/__init__.py +21 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/adapters.py +412 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/autonomous_runner.py +1152 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/cline.py +448 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/common.py +103 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/free_models.py +786 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/host_bootstrap.py +389 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/host_evaluators.py +761 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/host_probe.py +41 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/host_provider_arbitrator.py +831 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/host_registry.py +662 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/host_usage.py +127 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/mcp_process_tracker.py +509 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/mcp_registry_gate.py +379 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/pi.py +102 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/provider_facts.py +66 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/INTERFACE.md +51 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/README.md +67 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/__init__.py +140 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/_base_usage.py +152 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/_codex_usage.py +297 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/_dsh_usage.py +184 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/_mcp_toml.py +365 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/_zcode_usage.py +269 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/base.py +479 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/claude.py +212 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/cline.py +229 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/codex.py +1006 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/dsh.py +526 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/opencode.py +358 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/pi.py +308 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/zcode.py +219 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/i18n.py +252 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/README.md +41 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/__init__.py +17 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/build_info.py +105 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/client_metadata.py +185 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/json_utils.py +22 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/python_runtime.py +540 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/safe_xml.py +221 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_bugx.py +118 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/INTERFACE.md +31 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/README.md +106 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/__init__.py +29 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/candidate_revalidation.py +484 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/common.py +1060 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/finding_confirm_phase.py +391 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/finding_settlement.py +1432 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/findings_adjudication.py +666 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/findings_snapshot.py +357 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/judge_phase.py +848 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/lesson_context.py +536 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/lifecycle_reporter.py +627 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/orchestrator_controls.py +686 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_commit.py +567 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_coverage_sync.py +598 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_dry_run.py +817 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_observability.py +367 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_phase.py +1223 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_receipt.py +373 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_round_lifecycle.py +786 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/pre_phase.py +1029 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/pre_recon_scout.py +879 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/pre_state_builder.py +1133 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/report_sharing.py +414 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/round_orchestrator.py +1116 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/session_runtime.py +1670 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/startup_gates.py +1050 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/startup_interaction.py +1003 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/startup_version_gate.py +879 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/supervisor_bridge.py +1253 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/supervisor_coverage.py +423 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/supervisor_degraded.py +1211 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/worker_barriers.py +424 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/worker_orchestrator.py +1246 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/worker_prior.py +749 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/INTERFACE.md +35 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/README.md +160 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/__init__.py +67 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/_facade.py +227 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/archive_ops.py +630 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/auto_materialization.py +459 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/bug-log.md +22 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/cli.py +275 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/export_ops.py +554 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/finding_confirmation.py +1316 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/finding_io.py +299 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/finding_lifecycle.py +730 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/finding_verification.py +405 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/incidents.py +1005 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/lesson-replay-cases.json +20 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/lesson_ledger.py +241 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/lesson_replay.py +272 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/life_ledger.py +668 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/mistake-book.md +130 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/patterns.py +684 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/receipt_contract.py +269 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/schema.py +1192 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/sync_ops.py +940 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/tool_experience.py +683 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/verify_life.py +1597 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/lesson-ledger.json +275 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/locales/README.md +19 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/locales/en-US.json +462 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/locales/zh-CN.json +462 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/INTERFACE.md +75 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/README.md +62 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/__init__.py +128 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/base.py +717 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/channel_lifecycle.py +751 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/graph_handlers.py +222 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/knowledge_handlers.py +536 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/mining_handlers.py +586 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/resource_prompt_table.py +116 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/retrieval_handlers.py +249 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/rpc_server.py +470 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/supervisor_handlers.py +1461 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/telemetry_handlers.py +227 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/tool_table.py +1030 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_runtime_support/README.md +21 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_runtime_support/__init__.py +1 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_runtime_support/common.py +363 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_runtime_support/environment.py +567 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_runtime_support/verifier.py +758 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/metadata.txt +4 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/README.md +157 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/__init__.py +242 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/capability_plan.py +187 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/capability_planner.py +195 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/domain_archetype.py +542 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/domain_router.py +269 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/dynamic_flow_analyzer.py +533 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/impact_pruner.py +435 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/intent_adjudicator.py +175 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/judge_pipeline.py +1246 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/logic_analysis.py +419 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/prompt_harness.py +1704 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/source_inspector.py +267 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/spec_harvester.py +449 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/target_sandbox_manager.py +573 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/test_capability_verifier.py +1364 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/tools-kb.md +38 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/unit_kind.py +122 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/INTERFACE.md +83 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/README.md +51 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/SPEC.md +36 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/__init__.py +76 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/android_probe.py +552 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/base.py +147 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/codebase_memory_probe.py +647 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/desktop_probe.py +342 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/differential_probe.py +434 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/efficiency_probe.py +232 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ios_binary_probe.py +472 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/memory_probe.py +392 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/miniprogram_probe.py +385 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/mobile_probe.py +466 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/native_probe.py +302 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/openwiki_probe.py +263 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/pattern_probe.py +453 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/platform_probe.py +424 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/probe_registry.py +1770 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/sast_fixture_corpus.py +340 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/sast_probe.py +1510 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/sast_rules.py +1481 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/sca_scanner.py +779 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_accessibility.py +149 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_audit.py +513 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_contract.py +273 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_evidence.py +212 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_measurements.py +314 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_repair.py +250 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_review.py +133 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_storybook.py +107 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_tokens.py +185 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_visual_diff.py +131 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/web_probe.py +714 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/INTERFACE.md +62 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/README.md +53 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/SPEC.md +28 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/__init__.py +201 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/arbitrator.py +316 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/constants.py +247 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/detector.py +399 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/extractors.py +836 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/fingerprint.py +116 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/storage.py +258 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/strategy.py +301 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/README.md +35 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/codex_dialog_dispatch.md +9 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/command_routing_en.md +42 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/command_routing_zh.md +42 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/l0_router.md +47 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/rules/anti_patterns.md +16 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/rules/concurrency_rules.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/rules/memory_leak_rules.md +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/rules/prompt_injection_defense.md +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/stages/stage_explore.md +31 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/stages/stage_gate.md +43 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/stages/stage_mutate.md +42 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/stages/stage_repair.md +85 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/README.md +74 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/__init__.py +169 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/fix_watchlist.py +391 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/l7_dynamic.py +418 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/l7_repair_loop.py +462 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/l7_selfcheck.py +862 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/minimize_repro.py +466 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/patch_synthesizer.py +617 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/regression_pack.py +379 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/rsi_fixer.py +910 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/rsi_loop.py +311 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/rsi_repair.py +348 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/rsi_rounds.py +212 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/rsi_scope.py +281 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/self_heal.py +604 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/test_generator.py +1108 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/test_quality_auditor.py +410 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/test_strategy.py +511 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/INTERFACE.md +59 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/README.md +69 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/SPEC.md +28 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/__init__.py +47 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/attestation.py +228 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/authority.py +255 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/finding_report.py +418 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/formal_report_builder.py +924 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/html_renderers.py +696 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/models.py +759 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/pdf_exporter.py +231 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/projects_assets.py +730 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/report_client.py +743 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/report_data_builder.py +388 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/report_share.py +459 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/sast_bridge.py +116 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/server.py +832 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/visual_report_builder.py +796 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/web-conformance.md +168 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/web_conformance.py +428 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/workbench_assets.py +484 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/INTERFACE.md +20 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/README.md +161 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/__init__.py +3 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/code_analyzer.py +1720 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/codebase_memory_bridge.py +337 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/context_assembler.py +240 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/corpus_fetch.py +369 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/graph_ego.py +597 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/knowledge_auto.py +662 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/knowledge_sources.py +168 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/knowledge_sync.py +1003 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/memory_store.py +480 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/query_planner.py +1020 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/rrf_engine.py +137 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/slice_extractor.py +1209 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/slice_normalizer.py +373 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/slice_spec.py +357 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/symbol_index.py +1151 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/universal_code_matcher.py +622 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/xerj_bridge.py +476 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/xerj_supervisor.py +362 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/README.md +33 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/ios/PROVENANCE.json +30 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/ios/crypto.yaml +36 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/ios/network.yaml +20 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/ios/resilience.yaml +47 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/ios/storage.yaml +48 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/LICENSE +173 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/PROVENANCE.json +270 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-asymmetric-key-pair-used-for-multiple-purposes.yml +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-backup-manifest.yml +24 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-biometric-event-bound.yml +49 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-biometric-invalidated-enrollment.yml +11 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-biometric-no-confirmation-required.yml +10 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-biometric-validity-duration.yml +24 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-broken-encryption-algorithms.yaml +9 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-broken-encryption-modes.yaml +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-content-provider-exported.yml +35 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-custom-deeplink-scheme.yml +29 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-dangerous-app-permissions.yaml +65 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-data-unencrypted-shared-storage-no-user-interaction-apis.yml +36 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-data-unencrypted-shared-storage-no-user-interaction-manifest.yml +15 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-debuggable-flag.yml +10 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-debugger-checks.yml +12 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-deeplink-autoverify-missing.yml +33 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-deeplink-unvalidated-parameter.yml +11 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-device-passcode-present.yml +17 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-fileprovider-broad-scope.yml +46 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-hardcoded-crypto-keys-usage.yml +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-hardcoded-security-provider.yaml +18 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-implicit-intent-internal-communication.yml +30 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-implicit-intent-leaking-extras.yml +29 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-input-field-usage.yml +11 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-key-generation-with-insufficient-key-length.yml +21 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-keyboard-cache-input-types.yml +10 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-local-storage-input-validation.yml +48 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-native-debugger-checks.yml +12 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-network-checkservertrusted.yml +12 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-network-hostname-verification.yml +11 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-network-insecure-trust-anchors.yml +11 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-network-onreceivedsslerror.yml +12 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-non-random-use.yml +16 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-object-deserialization.yml +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-overlay-protection.yml +68 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-pendingintent-mutable.yml +39 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-random-apis-insufficient-entropy.yml +17 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-root-detection.yaml +59 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-sdk-version.yml +10 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-sensitive-data-in-notifications-manifest.yml +17 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-sensitive-data-in-notifications.yml +11 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-sensitive-data-in-screenshot.yml +18 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-sql-injection-contentprovider.yml +17 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-ssl-socket-hostnameverifier.yml +15 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-strictmode.yml +10 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-system-alert-window.yml +9 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-webview-allow-local-access.yml +15 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-webview-bridges.yml +28 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-webview-safebrowsing.yml +20 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-webview-url-handlers.yml +41 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/miniprogram/PROVENANCE.json +26 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/miniprogram/network.yaml +37 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/miniprogram/platform.yaml +36 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/miniprogram/storage.yaml +48 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/LICENSE +165 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/PROVENANCE.json +58 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/auth.yaml +59 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/crypto.yaml +66 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/jailbreak.yaml +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/keyboard.yaml +34 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/logging.yaml +23 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/network.yaml +55 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/resilience.yaml +29 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/secrets.yaml +33 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/storage.yaml +29 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/webview.yaml +32 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/README.md +198 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/__init__.py +3 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/bugx_logging.py +1464 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/daemon_runner.py +623 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/fixture_solidify.py +444 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/global_telemetry.py +549 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/incident_eval.py +148 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/interaction.py +605 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/interaction_store.py +435 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/interactive_menu.py +95 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/log_analytics.py +922 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/mining_quality_framework.py +1387 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/model_runner.py +732 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/platform_adapter.py +579 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/prep_validate.py +478 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/project_graph.py +827 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/project_init.py +481 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/project_profile.py +224 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/project_settings.py +964 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/provider_window.py +97 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/resume_ticket.py +115 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/scenario_eval.py +856 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/seed_drill.py +549 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/self_audit.py +550 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/session_profile.py +205 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/setup_ui_env.py +229 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/startup_environment.py +859 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/sync_store.py +1421 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/tool_install_targets.py +18 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/schemas/README.md +35 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/schemas/agent-graph.schema.json +368 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/schemas/attack-graph.schema.json +88 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/schemas/evidence-bundle.schema.json +33 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/schemas/skill-pack.schema.json +230 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/schemas/worker-checkpoint.schema.json +119 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/secure_atomic.py +289 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/README.md +55 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/c.txt +29 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/cpp.txt +32 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/css.txt +70 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/go.txt +46 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/java.txt +30 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/javascript.txt +55 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/kotlin.txt +28 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/python.txt +71 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/rust.txt +53 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/swift.txt +29 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/typescript.txt +29 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/README.md +53 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/__init__.py +189 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/bugx_docs_mcp_server.py +418 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/bugx_mcp_server.py +1161 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/mcp_runtime.py +968 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/mcp_session_proof.py +605 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/mobile_ui_inspector.py +405 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/skill_pack.py +1214 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/skill_synthesizer.py +1153 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/tools_kb.py +313 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/INTERFACE.md +121 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/README.md +209 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/__init__.py +175 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/audit_supervisor.py +1015 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/budget_governor.py +1254 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/checkpoint_handler.py +368 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/checkpoint_pipeline.py +1564 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/checkpoint_sync.py +653 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/claim_events.py +74 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/claim_sync.py +590 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/cli.py +812 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/context_sync.py +55 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/coverage_sync.py +115 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/finding_commit.py +470 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/finding_sync.py +688 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/finding_workflow.py +676 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/finish_policy.py +224 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/finish_sync.py +185 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/graph_sync.py +669 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/lease_manager.py +788 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/lifecycle_blocks.py +129 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/next_round_sync.py +126 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/observability.py +140 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/recovery_sync.py +165 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/rejection_remedies.py +355 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/round_governor.py +306 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/serial_authorization.py +544 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/start_sync.py +87 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/state_store.py +249 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/supervisor_host.py +511 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/supervisor_models.py +1143 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/systemic_failure.py +104 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/task_scheduler.py +1640 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/worker_checkpoint.py +230 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/worker_execution.py +265 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/worker_handoff.py +192 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/worker_lifecycle.py +396 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/worker_runtime.py +1005 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/worker_sync.py +89 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/README.md +36 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/__init__.py +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/exceptions.py +52 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/graph_models.py +357 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/path_containment.py +151 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/target_fingerprint.py +310 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/worker_claim.py +411 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/INTERFACE.md +50 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/README.md +57 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/SPEC.md +26 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/__init__.py +11 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/__init__.py +27 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/base.py +87 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/bugx.py +102 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/claude.py +222 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/cline.py +407 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/codex.py +260 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/dsh.py +177 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/opencode.py +218 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/pi.py +272 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/registry.py +100 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/zcode.py +312 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/api_routes_post.py +668 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/dispatcher.py +1376 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/docs_session_service.py +473 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/handler.py +674 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/ide_cloud_service.py +526 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/mcp_inspector.py +1747 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/00-base.css +1060 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/01-monitoring.css +802 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/02-header-actions.css +321 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/03-trigger-popover.css +697 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/04-composer.css +628 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/05-skills-center.css +878 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/06-mcp-center.css +623 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/07-skill-detail.css +265 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/08-files-management.css +167 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/09-files-center.css +386 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/10-icons.css +105 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/11-project-options.css +185 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/12-profile-tab.css +383 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/index-CXAsl8mr.js +333 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/index-DHQUtWtx.css +1 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-400-normal-B8Z6Jvzv.woff +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-400-normal-C44pakCn.woff2 +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-500-normal-Bb4u56_6.woff +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-500-normal-BdVUvljg.woff2 +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-ext-400-normal-CWV284fw.woff2 +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-ext-400-normal-DLkyKLvH.woff +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-ext-500-normal-8-8HP2PF.woff +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-ext-500-normal-DaDZE_Na.woff2 +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-greek-400-normal-BccYJ-vZ.woff +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-greek-400-normal-Cw5-AHNN.woff2 +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-greek-500-normal-By8GFJzz.woff2 +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-greek-500-normal-z-Q6FFuG.woff +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-400-normal-DJ5YJwmz.woff2 +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-400-normal-Dn3IlU-Z.woff +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-500-normal-CUHe9xxf.woff2 +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-500-normal-DVVamBqs.woff +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-ext-400-normal-CEpydyUl.woff +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-ext-400-normal-Cp7z-ARB.woff2 +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-ext-500-normal-BYjRCDVy.woff2 +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-ext-500-normal-D-qasQTj.woff +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-vietnamese-400-normal-BbG3LG1A.woff2 +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-vietnamese-400-normal-DR1UuFon.woff +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-vietnamese-500-normal-8N8MYVKB.woff +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-vietnamese-500-normal-Bi3OSTTW.woff2 +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/design-tokens.css +113 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/favicon.png +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/icon-192.png +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/index.html +55 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/manifest.webmanifest +19 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/project-settings.js +9602 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/sw.js +8 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/workspace_service.py +218 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/agents/bugx.md +27 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/dsh-patch.yml +18 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/mcp/cordis.patch.yml +4 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/mcp/index.js +219 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/mcp/package.json +28 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/skills/bugx/SKILL.md +70 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/skills/bugx-dsh/SKILL.md +229 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/ui/client.js +87 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/ui/cordis.patch.yml +4 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/ui/index.js +7 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/ui/package.json +27 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/mcp-lock.json +3075 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/opencode.json +129 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/pi/extensions/bugx/README.md +12 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/pi/extensions/bugx/index.ts +299 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/pi/extensions/bugx/manifest.json +11 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/pi/skills/bugx/SKILL.md +69 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/plugins/bugx/skills/bugx-claude/SKILL.md +326 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/plugins/bugx/skills/bugx-opencode/SKILL.md +129 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/plugins/bugx/skills/bugx-zcode/SKILL.md +459 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/workbuddy/connector-meta.json +19 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/workbuddy/icon.png +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/workbuddy/skills/bugx/SKILL.md +70 -0
- bugx_cli-0.1.1.dist-info/METADATA +335 -0
- bugx_cli-0.1.1.dist-info/RECORD +762 -0
- bugx_cli-0.1.1.dist-info/WHEEL +5 -0
- bugx_cli-0.1.1.dist-info/entry_points.txt +2 -0
- bugx_cli-0.1.1.dist-info/licenses/LICENSE +55 -0
- bugx_cli-0.1.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,1050 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""launch_phases/startup_gates.py - 启动门禁判定:Git边界、版本一致性、云端状态、交互菜单。"""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import datetime as dt
|
|
7
|
+
import functools
|
|
8
|
+
import json
|
|
9
|
+
import os
|
|
10
|
+
import re
|
|
11
|
+
import sys
|
|
12
|
+
import threading
|
|
13
|
+
import time
|
|
14
|
+
from pathlib import Path
|
|
15
|
+
from typing import Any
|
|
16
|
+
|
|
17
|
+
from core.launch_phases.common import (
|
|
18
|
+
AGENT_DIR,
|
|
19
|
+
STARTUP_TODO_ITEMS,
|
|
20
|
+
STARTUP_TODO_PHASE_INDEX,
|
|
21
|
+
STARTUP_TODO_GATE_PHASE,
|
|
22
|
+
HOST_DISPLAY_NAMES,
|
|
23
|
+
ISOLATED_REMOTE_VERSION_RESULT,
|
|
24
|
+
resolve_project_root,
|
|
25
|
+
uses_project_layout,
|
|
26
|
+
child_environment,
|
|
27
|
+
run_child,
|
|
28
|
+
run_verify_life,
|
|
29
|
+
POLLING_DECISION_REQUIRED,
|
|
30
|
+
REVIEW_DECISION_LATER,
|
|
31
|
+
bugx_paths,
|
|
32
|
+
bugx_logging,
|
|
33
|
+
)
|
|
34
|
+
import shutil
|
|
35
|
+
import subprocess
|
|
36
|
+
import core.secure_atomic as secure_atomic
|
|
37
|
+
from core.launch_phases.session_runtime import (
|
|
38
|
+
iso_time,
|
|
39
|
+
load_runtime,
|
|
40
|
+
save_runtime,
|
|
41
|
+
runtime_lock,
|
|
42
|
+
append_runtime_event,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
try:
|
|
46
|
+
from core.runtime import startup_environment
|
|
47
|
+
except ImportError:
|
|
48
|
+
startup_environment = None
|
|
49
|
+
|
|
50
|
+
try:
|
|
51
|
+
from core.runtime import interaction as _interaction
|
|
52
|
+
RADIO_UNAVAILABLE = _interaction.RADIO_UNAVAILABLE
|
|
53
|
+
except ImportError:
|
|
54
|
+
_interaction = None
|
|
55
|
+
RADIO_UNAVAILABLE = object()
|
|
56
|
+
|
|
57
|
+
try:
|
|
58
|
+
from core.cloud_sync import cloud_client as _cloud_client_module
|
|
59
|
+
from core.cloud_sync.cloud_client import CloudClient
|
|
60
|
+
except ImportError:
|
|
61
|
+
_cloud_client_module = None
|
|
62
|
+
CloudClient = None
|
|
63
|
+
|
|
64
|
+
try:
|
|
65
|
+
from core.infra import client_metadata as _client_metadata_module
|
|
66
|
+
except ImportError:
|
|
67
|
+
_client_metadata_module = None
|
|
68
|
+
|
|
69
|
+
try:
|
|
70
|
+
from core.cloud_sync.cloud_onboard import get_state, sync_layers
|
|
71
|
+
from core.cloud_sync.onboard_wizard import maybe_onboard
|
|
72
|
+
except ImportError:
|
|
73
|
+
maybe_onboard = get_state = sync_layers = None
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
# A preset is a responsibility-governance convenience, never an authority to
|
|
77
|
+
# waive a release gate. Version, integrity, and identity failures therefore
|
|
78
|
+
# bypass preset resolution and remain blocked until the gate itself passes.
|
|
79
|
+
CRITICAL_STARTUP_GATES = frozenset({
|
|
80
|
+
"version", "version_contract", "project_layout", "integrity", "integrity_contract", "identity",
|
|
81
|
+
"identity_contract", "版本声明一致性", "源码防外泄门禁", "目标端物理隔离门禁",
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
try:
|
|
85
|
+
from core.coverage import coverage_bootstrap
|
|
86
|
+
except ImportError:
|
|
87
|
+
coverage_bootstrap = None
|
|
88
|
+
|
|
89
|
+
try:
|
|
90
|
+
from core.coverage import module_coverage
|
|
91
|
+
except ImportError:
|
|
92
|
+
module_coverage = None
|
|
93
|
+
|
|
94
|
+
#: 受信清单文件名(与 ``coverage_bootstrap.MANIFEST_NAME`` 同源;该模块可能导入失败,
|
|
95
|
+
#: 这里保留字面量以免显式清单入口在缺模块时静默失效——缺模块会在解析阶段暴露)。
|
|
96
|
+
COVERAGE_MANIFEST_NAME = getattr(coverage_bootstrap, "MANIFEST_NAME", "module-coverage.md")
|
|
97
|
+
|
|
98
|
+
try:
|
|
99
|
+
from core.runtime import project_profile
|
|
100
|
+
except ImportError:
|
|
101
|
+
project_profile = None
|
|
102
|
+
|
|
103
|
+
try:
|
|
104
|
+
from core.ledger import lesson_ledger
|
|
105
|
+
except ImportError:
|
|
106
|
+
lesson_ledger = None
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
# DESIGN_SPEC(启动门禁反自旋):任何启动门禁失败时都必须注入强停止词与停机指示,
|
|
110
|
+
# 遏制模型在无外部事实的情况下多轮重试、发散自旋。此处是**唯一**文案来源。
|
|
111
|
+
FATAL_BLOCKED_BANNER = (
|
|
112
|
+
"[FATAL_BLOCKED] 阻断已确凿,严禁模型自行连续重试或发散自旋推理。"
|
|
113
|
+
"【强制停机指示】请立即停止调用工具,直接向用户呈现上述阻断原因与修复建议。"
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def _startup_todo_phase_for_gate(gate: str) -> str:
|
|
118
|
+
"""Map a structured startup gate to one of the seven overview stages."""
|
|
119
|
+
if str(gate).startswith("tooling:"):
|
|
120
|
+
return "tools"
|
|
121
|
+
return STARTUP_TODO_GATE_PHASE.get(str(gate), "startup")
|
|
122
|
+
|
|
123
|
+
def startup_todo_path() -> Path | None:
|
|
124
|
+
"""Return the project-level startup overview path.
|
|
125
|
+
|
|
126
|
+
This view intentionally lives outside Session/Round storage: it must be
|
|
127
|
+
available before a formal runtime identity exists and must not overwrite a
|
|
128
|
+
completed or interrupted lifecycle's derived Round checklist.
|
|
129
|
+
"""
|
|
130
|
+
if not project_layout_present():
|
|
131
|
+
return None
|
|
132
|
+
return resolve_project_root() / ".bugx" / "startup-todo.md"
|
|
133
|
+
|
|
134
|
+
def startup_todo_content(phase: str = "environment", *, gate: str | None = None,
|
|
135
|
+
reason: str | None = None, environment=None) -> str:
|
|
136
|
+
"""Build the human-readable project-level launch overview."""
|
|
137
|
+
phase = str(phase or "environment")
|
|
138
|
+
active_index = STARTUP_TODO_PHASE_INDEX.get(phase, 0)
|
|
139
|
+
env = environment
|
|
140
|
+
host = getattr(env, "host", "unknown") if env is not None else "unknown"
|
|
141
|
+
interface = getattr(env, "interface", "unknown") if env is not None else "unknown"
|
|
142
|
+
interaction = getattr(env, "interaction", "unknown") if env is not None else "unknown"
|
|
143
|
+
lines = [
|
|
144
|
+
"# BugX 启动总览 TODO",
|
|
145
|
+
"",
|
|
146
|
+
f"- 项目:`{resolve_project_root()}`",
|
|
147
|
+
f"- 宿主/界面:`{host}` / `{interface}` / `{interaction}`",
|
|
148
|
+
f"- 当前阶段:`{phase}`",
|
|
149
|
+
f"- 当前门禁:`{gate or 'none'}`",
|
|
150
|
+
f"- 最后校准:`{iso_time(time.time())}`",
|
|
151
|
+
"",
|
|
152
|
+
]
|
|
153
|
+
for index, (title, detail) in enumerate(STARTUP_TODO_ITEMS):
|
|
154
|
+
if index < active_index:
|
|
155
|
+
marker = "x"
|
|
156
|
+
elif index == active_index:
|
|
157
|
+
marker = "~"
|
|
158
|
+
else:
|
|
159
|
+
marker = " "
|
|
160
|
+
lines.append(f"- [{marker}] {index + 1}. {title}")
|
|
161
|
+
lines.append(f" - {detail}")
|
|
162
|
+
if reason:
|
|
163
|
+
lines.extend(["", f"- 当前说明:{reason}"])
|
|
164
|
+
lines.extend([
|
|
165
|
+
"",
|
|
166
|
+
"> 本文件是给用户和 Agent 查看全局进度的派生视图,不是账本、覆盖清单、Finding 来源或完成判定器。",
|
|
167
|
+
"> 正式 Round 开始后,详细进度位于当前生命周期 `state/audit-todo.md`。",
|
|
168
|
+
"> 阶段专精提示词(Harness):可通过 `bugx engine --root . prompt --stage <gate|explore|mutate|repair>` 或 MCP `bugx_get_stage_harness` 动态获取。",
|
|
169
|
+
])
|
|
170
|
+
return "\n".join(lines) + "\n"
|
|
171
|
+
|
|
172
|
+
def refresh_startup_todo(phase: str = "environment", *, gate: str | None = None,
|
|
173
|
+
reason: str | None = None, environment=None) -> Path | None:
|
|
174
|
+
"""Refresh the project-level launch overview without blocking BugX."""
|
|
175
|
+
path = startup_todo_path()
|
|
176
|
+
if path is None:
|
|
177
|
+
return None
|
|
178
|
+
try:
|
|
179
|
+
secure_atomic.atomic_write_text(
|
|
180
|
+
path,
|
|
181
|
+
startup_todo_content(phase, gate=gate, reason=reason, environment=environment),
|
|
182
|
+
mode=0o600,
|
|
183
|
+
parent_mode=0o700,
|
|
184
|
+
)
|
|
185
|
+
except (OSError, ValueError, RuntimeError) as exc:
|
|
186
|
+
print(f" (启动总览 TODO 刷新失败,不影响启动门禁:{exc})")
|
|
187
|
+
return None
|
|
188
|
+
return path
|
|
189
|
+
|
|
190
|
+
@functools.lru_cache(maxsize=None)
|
|
191
|
+
def _startup_environment_cached(module, root: str):
|
|
192
|
+
"""Memoised ``detect()`` call behind :func:`detect_startup_environment`."""
|
|
193
|
+
return module.detect(Path(root))
|
|
194
|
+
|
|
195
|
+
def detect_startup_environment():
|
|
196
|
+
"""Detect the real host/UI surface before any startup gate is shown.
|
|
197
|
+
|
|
198
|
+
结果按 (``startup_environment`` 模块, 项目根) 在**进程内**缓存:宿主进程树、
|
|
199
|
+
TTY 能力与 Git 就绪状态在一次会话里不会改变,而本函数在启动链路上被调用
|
|
200
|
+
20 余次,每次重探都要同步执行 7 次 git 子进程与最多 8 层进程祖先 ``ps``
|
|
201
|
+
(实测单次 65-108 ms,PERF-01)。
|
|
202
|
+
|
|
203
|
+
缓存键包含模块对象本身,因此测试替换 ``startup_environment`` 桩件时自然落到
|
|
204
|
+
新键,旧缓存不会掩盖后到的可用模块;模块不可用(``None``)时直接返回
|
|
205
|
+
``None`` 且不写缓存;探测抛出的异常也不会被缓存,下一次调用会重新探测。
|
|
206
|
+
|
|
207
|
+
需要强制重探时调用 :func:`clear_startup_environment_cache`(例如在同一进程内
|
|
208
|
+
改动显式会话宿主或 ``BUGX_INTERACTION`` 等交互钩子之后)。
|
|
209
|
+
"""
|
|
210
|
+
if startup_environment is None:
|
|
211
|
+
return None
|
|
212
|
+
try:
|
|
213
|
+
return _startup_environment_cached(startup_environment, str(resolve_project_root()))
|
|
214
|
+
except (OSError, RuntimeError, ValueError):
|
|
215
|
+
return None
|
|
216
|
+
|
|
217
|
+
def clear_startup_environment_cache() -> None:
|
|
218
|
+
"""清空启动环境探测缓存,并连带清空底层 ``startup_environment`` 的缓存。"""
|
|
219
|
+
_startup_environment_cached.cache_clear()
|
|
220
|
+
if startup_environment is not None:
|
|
221
|
+
clear = getattr(startup_environment, "clear_cache", None)
|
|
222
|
+
if callable(clear):
|
|
223
|
+
clear()
|
|
224
|
+
|
|
225
|
+
def startup_environment_line(environment) -> str:
|
|
226
|
+
if environment is None:
|
|
227
|
+
return "host=unknown interface=unknown interaction=blocked git=unknown"
|
|
228
|
+
git = getattr(environment, "git", {}) or {}
|
|
229
|
+
# 诊断行必须**永不因缺字段而崩**:它出现在 pre 的早期,任何 AttributeError
|
|
230
|
+
# 都会把一次正常启动变成 traceback(实测:测试用 SimpleNamespace 构造最小
|
|
231
|
+
# 环境时 `host_source`/`interaction` 缺失即崩溃)。缺字段降级为 unknown。
|
|
232
|
+
def _field(name: str, default: str = "unknown") -> str:
|
|
233
|
+
value = getattr(environment, name, None)
|
|
234
|
+
if value is None:
|
|
235
|
+
return default
|
|
236
|
+
if isinstance(value, bool):
|
|
237
|
+
# 布尔字段在摘要行里必须是小写 true/false(既有契约:宿主探针与
|
|
238
|
+
# 测试都按该形态解析;直接 str() 会给出 "True")。
|
|
239
|
+
return "true" if value else "false"
|
|
240
|
+
return str(value)
|
|
241
|
+
|
|
242
|
+
return (
|
|
243
|
+
f"host={_field('host')} source={_field('host_source')} "
|
|
244
|
+
f"interface={_field('interface')} interaction={_field('interaction')} "
|
|
245
|
+
f"stdin_tty={_field('stdin_tty', 'unknown')} "
|
|
246
|
+
f"stdout_tty={_field('stdout_tty', 'unknown')} "
|
|
247
|
+
f"git={git.get('status', 'unknown')}"
|
|
248
|
+
)
|
|
249
|
+
|
|
250
|
+
def _startup_host_label(environment=None, *, fallback: str = "当前宿主") -> str:
|
|
251
|
+
"""Return the host name for user-facing actions, never a fixed IDE name."""
|
|
252
|
+
environment = environment or detect_startup_environment()
|
|
253
|
+
host = getattr(environment, "host", None) if environment is not None else None
|
|
254
|
+
host = str(host or "").strip().casefold()
|
|
255
|
+
return HOST_DISPLAY_NAMES.get(host, fallback)
|
|
256
|
+
|
|
257
|
+
def git_startup_gate(environment=None, *, auto_init: bool = False) -> bool:
|
|
258
|
+
"""Require a readable Git baseline before creating a BugX Session.
|
|
259
|
+
|
|
260
|
+
The core never installs Git or initializes a repository unless ``auto_init`` is
|
|
261
|
+
requested (developer mode). In that mode it may create the repository, set a
|
|
262
|
+
repository-local commit identity when none is configured, and record an empty
|
|
263
|
+
baseline commit; it never stages or commits the user's working tree. Any Git
|
|
264
|
+
problem that remains still goes through the structured gate so the host can act
|
|
265
|
+
on an explicit user choice.
|
|
266
|
+
"""
|
|
267
|
+
snapshot = getattr(environment, "git", None) if environment is not None else None
|
|
268
|
+
if not isinstance(snapshot, dict) and startup_environment is not None:
|
|
269
|
+
try:
|
|
270
|
+
snapshot = startup_environment.detect_git(resolve_project_root())
|
|
271
|
+
except (OSError, RuntimeError, ValueError):
|
|
272
|
+
snapshot = None
|
|
273
|
+
snapshot = snapshot if isinstance(snapshot, dict) else {
|
|
274
|
+
"status": "unusable", "ready": False,
|
|
275
|
+
"detail": "无法读取 Git 环境快照", "root": str(resolve_project_root()),
|
|
276
|
+
}
|
|
277
|
+
if snapshot.get("ready") is True:
|
|
278
|
+
return True
|
|
279
|
+
|
|
280
|
+
status = str(snapshot.get("status") or "unusable")
|
|
281
|
+
if auto_init and status in {"not-repository", "unborn", "identity-missing"}:
|
|
282
|
+
root = resolve_project_root()
|
|
283
|
+
try:
|
|
284
|
+
if status == "not-repository":
|
|
285
|
+
subprocess.run(
|
|
286
|
+
["git", "init"], cwd=root, check=True, capture_output=True,
|
|
287
|
+
)
|
|
288
|
+
# 仓库级身份只在缺失时补齐,绝不改动全局 git 配置。
|
|
289
|
+
for key, value in (
|
|
290
|
+
("user.name", "BugX Dev"),
|
|
291
|
+
("user.email", "bugx-dev@localhost"),
|
|
292
|
+
):
|
|
293
|
+
probe = subprocess.run(
|
|
294
|
+
["git", "config", "--get", key],
|
|
295
|
+
cwd=root, capture_output=True, text=True,
|
|
296
|
+
)
|
|
297
|
+
if probe.returncode != 0 or not probe.stdout.strip():
|
|
298
|
+
subprocess.run(
|
|
299
|
+
["git", "config", "--local", key, value],
|
|
300
|
+
cwd=root, check=True, capture_output=True,
|
|
301
|
+
)
|
|
302
|
+
print(f"[launch_bugx] ✓ 开发模式已补齐仓库级 Git 身份 {key}={value}")
|
|
303
|
+
if status in {"not-repository", "unborn"}:
|
|
304
|
+
staged = subprocess.run(
|
|
305
|
+
["git", "diff", "--cached", "--quiet"], cwd=root, capture_output=True,
|
|
306
|
+
)
|
|
307
|
+
if staged.returncode == 0:
|
|
308
|
+
subprocess.run(
|
|
309
|
+
[
|
|
310
|
+
"git", "commit", "--allow-empty", "--no-verify",
|
|
311
|
+
"-m", "chore: bugx dev init baseline",
|
|
312
|
+
],
|
|
313
|
+
cwd=root, check=True, capture_output=True,
|
|
314
|
+
)
|
|
315
|
+
print("[launch_bugx] ✓ 开发模式已建立空的 Git 基线提交(未暂存工作区文件)")
|
|
316
|
+
else:
|
|
317
|
+
print(
|
|
318
|
+
"[launch_bugx] ⚠ 暂存区已有内容,跳过自动基线提交以免把工作区文件卷入"
|
|
319
|
+
)
|
|
320
|
+
except (OSError, subprocess.SubprocessError) as exc:
|
|
321
|
+
stderr = getattr(exc, "stderr", b"") or b""
|
|
322
|
+
if isinstance(stderr, bytes):
|
|
323
|
+
stderr = stderr.decode("utf-8", "replace")
|
|
324
|
+
print(f"[launch_bugx] ⚠ 自动初始化 Git 失败:{str(stderr).strip() or exc}")
|
|
325
|
+
if startup_environment is not None:
|
|
326
|
+
try:
|
|
327
|
+
refreshed = startup_environment.detect_git(root)
|
|
328
|
+
except (OSError, RuntimeError, ValueError):
|
|
329
|
+
refreshed = None
|
|
330
|
+
if isinstance(refreshed, dict):
|
|
331
|
+
snapshot = refreshed
|
|
332
|
+
if refreshed.get("ready") is True:
|
|
333
|
+
return True
|
|
334
|
+
status = str(refreshed.get("status") or status)
|
|
335
|
+
if status == "missing":
|
|
336
|
+
question = "项目缺少 Git,是否安装 Git?"
|
|
337
|
+
options = [
|
|
338
|
+
{
|
|
339
|
+
"label": "立即安装 Git",
|
|
340
|
+
"description": "由宿主执行系统 Git 安装,完成后重新检测",
|
|
341
|
+
"value": "install",
|
|
342
|
+
"action": "install_git",
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
"label": "退出",
|
|
346
|
+
"description": "停止本次 BugX 启动,不创建 Session",
|
|
347
|
+
"value": "exit",
|
|
348
|
+
"action": "stop_startup",
|
|
349
|
+
},
|
|
350
|
+
]
|
|
351
|
+
elif status == "not-repository":
|
|
352
|
+
question = "当前项目不是 Git 仓库,是否在项目根目录初始化?"
|
|
353
|
+
options = [
|
|
354
|
+
{
|
|
355
|
+
"label": "初始化 Git 仓库",
|
|
356
|
+
"description": "在确认的项目根目录执行 git init,完成后重新检测",
|
|
357
|
+
"value": "init",
|
|
358
|
+
"action": "git_init",
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
"label": "退出",
|
|
362
|
+
"description": "停止本次 BugX 启动,不创建 Session",
|
|
363
|
+
"value": "exit",
|
|
364
|
+
"action": "stop_startup",
|
|
365
|
+
},
|
|
366
|
+
]
|
|
367
|
+
else:
|
|
368
|
+
question = "Git 环境未准备好,是否修复后重新检测?"
|
|
369
|
+
options = [
|
|
370
|
+
{
|
|
371
|
+
"label": "修复 Git 环境",
|
|
372
|
+
"description": "补齐 HEAD、提交身份或 Git 元数据写入能力后重新检测",
|
|
373
|
+
"value": "repair",
|
|
374
|
+
"action": "repair_git",
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
"label": "退出",
|
|
378
|
+
"description": "停止本次 BugX 启动,不创建 Session",
|
|
379
|
+
"value": "exit",
|
|
380
|
+
"action": "stop_startup",
|
|
381
|
+
},
|
|
382
|
+
]
|
|
383
|
+
detail = str(snapshot.get("detail") or "Git 环境检查失败")
|
|
384
|
+
if snapshot.get("root"):
|
|
385
|
+
detail = f"项目根目录:{snapshot['root']};{detail}"
|
|
386
|
+
if emit_startup_gate(
|
|
387
|
+
"git_environment", question, options,
|
|
388
|
+
environment=environment,
|
|
389
|
+
detail=detail,
|
|
390
|
+
) is True:
|
|
391
|
+
if startup_environment is not None:
|
|
392
|
+
try:
|
|
393
|
+
refreshed = startup_environment.detect_git(resolve_project_root())
|
|
394
|
+
if isinstance(refreshed, dict) and refreshed.get("ready") is True:
|
|
395
|
+
return True
|
|
396
|
+
except Exception:
|
|
397
|
+
pass
|
|
398
|
+
return False
|
|
399
|
+
|
|
400
|
+
def emit_startup_gate(
|
|
401
|
+
gate: str,
|
|
402
|
+
question: str,
|
|
403
|
+
options: list[dict[str, object]],
|
|
404
|
+
*,
|
|
405
|
+
environment=None,
|
|
406
|
+
detail: str = "",
|
|
407
|
+
) -> bool:
|
|
408
|
+
"""Emit exactly one machine-readable interaction request for the host Agent.
|
|
409
|
+
|
|
410
|
+
The core process cannot invoke OpenCode/Claude UI tools itself. In a
|
|
411
|
+
headless child process it must return one gate, not print a text survey;
|
|
412
|
+
the host Agent renders this payload with its native single-select tool and
|
|
413
|
+
then retries the command with the persisted choice.
|
|
414
|
+
|
|
415
|
+
``value`` is the stable return value consumed by the host; ``action`` is
|
|
416
|
+
only an opaque business whitelist identifier. Requiring a value here
|
|
417
|
+
prevents a future gate from falling back to label parsing in adapters.
|
|
418
|
+
"""
|
|
419
|
+
# [BEGIN DEV_ONLY: STARTUP_GATE_PRESET]
|
|
420
|
+
if (
|
|
421
|
+
gate not in CRITICAL_STARTUP_GATES
|
|
422
|
+
and _interaction is not None
|
|
423
|
+
and hasattr(_interaction, "try_resolve_startup_gate_preset")
|
|
424
|
+
):
|
|
425
|
+
try:
|
|
426
|
+
resolved, _ = _interaction.try_resolve_startup_gate_preset(
|
|
427
|
+
gate, options, root=resolve_project_root()
|
|
428
|
+
)
|
|
429
|
+
if resolved:
|
|
430
|
+
return True
|
|
431
|
+
except Exception:
|
|
432
|
+
pass
|
|
433
|
+
# [END DEV_ONLY: STARTUP_GATE_PRESET]
|
|
434
|
+
|
|
435
|
+
environment = environment or detect_startup_environment()
|
|
436
|
+
if _interaction is None:
|
|
437
|
+
raise RuntimeError("统一交互组件不可用,拒绝降级为旧文本门禁")
|
|
438
|
+
try:
|
|
439
|
+
interaction_options = tuple(
|
|
440
|
+
_interaction.InteractionOption.from_mapping(option) for option in options
|
|
441
|
+
)
|
|
442
|
+
interaction_question = _interaction.InteractionQuestion(
|
|
443
|
+
question_id=gate,
|
|
444
|
+
phase="startup",
|
|
445
|
+
kind="select",
|
|
446
|
+
title="BugX 启动需要你的选择",
|
|
447
|
+
question=question,
|
|
448
|
+
options=interaction_options,
|
|
449
|
+
multiple=False,
|
|
450
|
+
detail=detail,
|
|
451
|
+
)
|
|
452
|
+
except (TypeError, ValueError) as exc:
|
|
453
|
+
raise ValueError(f"启动门禁 {gate} 定义非法: {exc}") from exc
|
|
454
|
+
refresh_startup_todo(
|
|
455
|
+
_startup_todo_phase_for_gate(gate),
|
|
456
|
+
gate=gate,
|
|
457
|
+
reason=detail or question,
|
|
458
|
+
environment=environment,
|
|
459
|
+
)
|
|
460
|
+
result = _interaction.emit_request(interaction_question, environment)
|
|
461
|
+
if result.status != _interaction.NEEDS_DECISION:
|
|
462
|
+
raise RuntimeError(f"无法输出交互请求 {gate}: {result.reason or result.status}")
|
|
463
|
+
return False
|
|
464
|
+
|
|
465
|
+
def pre_has_explicit_startup_choices(argv: list[str]) -> bool:
|
|
466
|
+
"""Whether a non-interactive caller supplied every user startup choice."""
|
|
467
|
+
if "--approve-strategy" in argv or any(
|
|
468
|
+
arg == "--strategy-plan" and i + 1 < len(argv) and argv[i + 1] in ("approve", "approve_and_start", "1")
|
|
469
|
+
or arg.startswith(("--strategy-plan=approve", "--strategy-plan=1"))
|
|
470
|
+
for i, arg in enumerate(argv)
|
|
471
|
+
):
|
|
472
|
+
return True
|
|
473
|
+
if "--startup-interaction" in argv or any(arg.startswith("--startup-interaction=") for arg in argv):
|
|
474
|
+
return True
|
|
475
|
+
return all(option in argv for option in (
|
|
476
|
+
"--review-mode", "--polling", "--fix-mode", "--commit-policy",
|
|
477
|
+
))
|
|
478
|
+
|
|
479
|
+
def project_layout_present() -> bool:
|
|
480
|
+
"""Distinguish a standalone protocol test from an installed project.
|
|
481
|
+
|
|
482
|
+
``uses_project_layout`` intentionally returns false for a broken layout
|
|
483
|
+
so legacy tests can run in a bare directory. Startup version checks must
|
|
484
|
+
still run for a present-but-invalid ``.bugx`` directory and fail closed.
|
|
485
|
+
"""
|
|
486
|
+
try:
|
|
487
|
+
marker = resolve_project_root() / ".bugx"
|
|
488
|
+
if not (marker.exists() or marker.is_symlink()):
|
|
489
|
+
return False
|
|
490
|
+
# Legacy protocol tests may create .bugx/findings only. An installed
|
|
491
|
+
# BugX project is identified by its manifest or explicit project root;
|
|
492
|
+
# Layout 2 has no project core reference.
|
|
493
|
+
return (
|
|
494
|
+
(marker / "manifest.json").exists()
|
|
495
|
+
or bool(os.environ.get("BUGX_PROJECT_ROOT"))
|
|
496
|
+
)
|
|
497
|
+
except (OSError, ValueError, RuntimeError):
|
|
498
|
+
return True
|
|
499
|
+
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
# ---------------------------------------------------------------------------
|
|
503
|
+
# DOC-256: 架构解耦导出:版本门禁与交互决策
|
|
504
|
+
# ---------------------------------------------------------------------------
|
|
505
|
+
from core.launch_phases.startup_version_gate import (
|
|
506
|
+
normalize_cli_version,
|
|
507
|
+
installed_cli_version,
|
|
508
|
+
global_engine_root,
|
|
509
|
+
version_marker,
|
|
510
|
+
startup_release_version,
|
|
511
|
+
startup_version_banner,
|
|
512
|
+
startup_cloud_onboarding,
|
|
513
|
+
run_cloud_boundary_sync,
|
|
514
|
+
startup_version_gate,
|
|
515
|
+
pending_remote_version_result,
|
|
516
|
+
remote_version_check_result,
|
|
517
|
+
clear_remote_version_check_cache,
|
|
518
|
+
record_remote_version_result,
|
|
519
|
+
schedule_startup_remote_version_check,
|
|
520
|
+
startup_remote_version_check,
|
|
521
|
+
emit_version_contract_gate,
|
|
522
|
+
emit_project_layout_gate,
|
|
523
|
+
REMOTE_VERSION_CHECK_TIMEOUT_SECONDS,
|
|
524
|
+
REMOTE_VERSION_LOCK,
|
|
525
|
+
REMOTE_VERSION_RESULT,
|
|
526
|
+
REMOTE_VERSION_THREAD,
|
|
527
|
+
)
|
|
528
|
+
_normalize_cli_version = normalize_cli_version
|
|
529
|
+
_installed_cli_version = installed_cli_version
|
|
530
|
+
_global_engine_root = global_engine_root
|
|
531
|
+
_startup_release_version = startup_release_version
|
|
532
|
+
_pending_remote_version_result = pending_remote_version_result
|
|
533
|
+
_record_remote_version_result = record_remote_version_result
|
|
534
|
+
_startup_remote_version_check = startup_remote_version_check
|
|
535
|
+
_REMOTE_VERSION_LOCK = REMOTE_VERSION_LOCK
|
|
536
|
+
_REMOTE_VERSION_RESULT = REMOTE_VERSION_RESULT
|
|
537
|
+
_REMOTE_VERSION_THREAD = REMOTE_VERSION_THREAD
|
|
538
|
+
|
|
539
|
+
from core.launch_phases.startup_interaction import (
|
|
540
|
+
compile_strategy_plan,
|
|
541
|
+
run_verify_life_direct,
|
|
542
|
+
apply_approved_strategy,
|
|
543
|
+
mark_strategy_customized,
|
|
544
|
+
save_strategy_draft,
|
|
545
|
+
strategy_plan_gate,
|
|
546
|
+
stdin_tty,
|
|
547
|
+
tty_menu_available,
|
|
548
|
+
radio_menu,
|
|
549
|
+
interaction_environment,
|
|
550
|
+
ask_interaction,
|
|
551
|
+
answered_value,
|
|
552
|
+
answered_values,
|
|
553
|
+
map_polling_answer,
|
|
554
|
+
ask_polling_policy,
|
|
555
|
+
map_mode_answer,
|
|
556
|
+
map_commit_policy_answer,
|
|
557
|
+
ask_commit_policy,
|
|
558
|
+
map_review_mode_answer,
|
|
559
|
+
ask_review_mode,
|
|
560
|
+
ask_fix_mode,
|
|
561
|
+
map_report_policy_answer,
|
|
562
|
+
ask_report_policy,
|
|
563
|
+
report_policy_startup_gate,
|
|
564
|
+
interactive_startup_decisions,
|
|
565
|
+
)
|
|
566
|
+
_run_verify_life_direct = run_verify_life_direct
|
|
567
|
+
_apply_approved_strategy = apply_approved_strategy
|
|
568
|
+
_save_strategy_draft = save_strategy_draft
|
|
569
|
+
_stdin_tty = stdin_tty
|
|
570
|
+
_tty_menu_available = tty_menu_available
|
|
571
|
+
_radio_menu = radio_menu
|
|
572
|
+
_interaction_environment = interaction_environment
|
|
573
|
+
_map_polling_answer = map_polling_answer
|
|
574
|
+
_ask_polling_policy = ask_polling_policy
|
|
575
|
+
_map_mode_answer = map_mode_answer
|
|
576
|
+
_map_commit_policy_answer = map_commit_policy_answer
|
|
577
|
+
_ask_commit_policy = ask_commit_policy
|
|
578
|
+
_map_review_mode_answer = map_review_mode_answer
|
|
579
|
+
_ask_review_mode = ask_review_mode
|
|
580
|
+
_ask_fix_mode = ask_fix_mode
|
|
581
|
+
_map_report_policy_answer = map_report_policy_answer
|
|
582
|
+
_ask_report_policy = ask_report_policy
|
|
583
|
+
_report_policy_startup_gate = report_policy_startup_gate
|
|
584
|
+
_interactive_startup_decisions = interactive_startup_decisions
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
def _map_coverage_bootstrap_answer(value: str | None) -> bool | None:
|
|
588
|
+
"""coverage_bootstrap 选择值→动作映射单一真源(TTY / 信箱两通道共用)。
|
|
589
|
+
|
|
590
|
+
TTY 文本菜单经 ``ask_interaction`` 返回选项序号("1"/"2");信箱通道
|
|
591
|
+
(``bugx interaction answer coverage_bootstrap``)经 ``take_answer`` 返回
|
|
592
|
+
结构化门禁的语义 value("bootstrap"/"later")。两通道必须落到同一动作,
|
|
593
|
+
否则语义答案会在 ask 内被消费(consumed_at 已置位)却被映射丢弃,
|
|
594
|
+
门禁无限重发。
|
|
595
|
+
"""
|
|
596
|
+
low = (value or "").strip().lower()
|
|
597
|
+
if low in {"1", "bootstrap"}:
|
|
598
|
+
return True
|
|
599
|
+
if low in {"2", "later"}:
|
|
600
|
+
return False
|
|
601
|
+
return None
|
|
602
|
+
|
|
603
|
+
|
|
604
|
+
def _ask_coverage_bootstrap() -> bool | None:
|
|
605
|
+
"""通过统一组件询问是否创建覆盖清单。"""
|
|
606
|
+
result = ask_interaction(
|
|
607
|
+
"coverage_bootstrap", "覆盖清单尚未建立,是否运行引导创建?", [
|
|
608
|
+
("运行引导创建", "创建本生命周期的最小覆盖单元,完成后继续启动"),
|
|
609
|
+
("下次再说", "停止本轮启动,不创建或修改运行态清单"),
|
|
610
|
+
],
|
|
611
|
+
default=0,
|
|
612
|
+
)
|
|
613
|
+
return _map_coverage_bootstrap_answer(answered_value(result))
|
|
614
|
+
|
|
615
|
+
#: 显式审计范围入口(`autonomous --coverage-manifest` / 手工 ``BUGX_COVERAGE_MANIFEST``)。
|
|
616
|
+
#:
|
|
617
|
+
#: 为什么需要它:gate 的 reconcile 把清单 scope 与**全仓** discovery 结果比对,任何
|
|
618
|
+
#: 「只审一个子集」的清单都会被判成漂移并触发全量重扫。对大仓(引擎自审、monorepo、
|
|
619
|
+
#: 任何带 vendored 目录的项目)这等于宣告无法限定审计范围——实测 worktree 场景下
|
|
620
|
+
#: 458 个引擎文件全部进单元,`--max-turns 4` 必然 INCOMPLETE,而清单 bootstrap 的
|
|
621
|
+
#: 交互门禁在非 TTY 下静默阻塞。显式清单把「审哪些单元」交回调用方,gate 只做
|
|
622
|
+
#: **真实性校验**(文件在、可解析、单元路径真实存在),不再 reconcile 到全仓。
|
|
623
|
+
COVERAGE_MANIFEST_ENV = "BUGX_COVERAGE_MANIFEST"
|
|
624
|
+
|
|
625
|
+
|
|
626
|
+
def _explicit_coverage_manifest() -> Path | None:
|
|
627
|
+
raw = (os.environ.get(COVERAGE_MANIFEST_ENV) or "").strip()
|
|
628
|
+
if not raw:
|
|
629
|
+
return None
|
|
630
|
+
return Path(raw).expanduser()
|
|
631
|
+
|
|
632
|
+
|
|
633
|
+
def _manifest_unit_path(row: object) -> str:
|
|
634
|
+
"""取单元路径(去反引号/``::symbol`` 后缀/尾斜杠),与 reconcile 的 scope 口径一致。"""
|
|
635
|
+
|
|
636
|
+
path = str(getattr(row, "path", "") or "").strip().strip("`").strip()
|
|
637
|
+
if "::" in path:
|
|
638
|
+
path = path.split("::", 1)[0].strip()
|
|
639
|
+
return path.rstrip("/")
|
|
640
|
+
|
|
641
|
+
|
|
642
|
+
def _manifest_has_progress(payload: bytes) -> bool:
|
|
643
|
+
"""清单里是否已有「已覆盖」的真实进度(模板/全 pending 不算)。"""
|
|
644
|
+
|
|
645
|
+
try:
|
|
646
|
+
text = payload.decode("utf-8")
|
|
647
|
+
except UnicodeError:
|
|
648
|
+
return True
|
|
649
|
+
for line in text.splitlines():
|
|
650
|
+
if not line.startswith("|"):
|
|
651
|
+
continue
|
|
652
|
+
cells = [cell.strip() for cell in line.strip().strip("|").split("|")]
|
|
653
|
+
if len(cells) < 13:
|
|
654
|
+
continue
|
|
655
|
+
if "covered" in cells[12]:
|
|
656
|
+
return True
|
|
657
|
+
return False
|
|
658
|
+
|
|
659
|
+
|
|
660
|
+
def _install_explicit_coverage_manifest(root: Path) -> int | None:
|
|
661
|
+
"""把显式清单落位为受信清单;``None`` 表示本次没有显式清单。
|
|
662
|
+
|
|
663
|
+
校验只做**真实性**(对齐 ``coverage_bootstrap`` 的 fail-closed 口径):
|
|
664
|
+
拒绝符号链接、拒绝解析失败、拒绝空清单、拒绝指向项目外或不存在路径的单元。
|
|
665
|
+
校验通过后原样落位到 ``state_root/module-coverage.md``——后续 Supervisor /
|
|
666
|
+
``start --coverage-manifest`` / 校验器读的都是同一个文件,不存在两份真相。
|
|
667
|
+
"""
|
|
668
|
+
|
|
669
|
+
manifest = _explicit_coverage_manifest()
|
|
670
|
+
if manifest is None:
|
|
671
|
+
return None
|
|
672
|
+
if not uses_project_layout():
|
|
673
|
+
print(f"[launch_bugx] ✗ {COVERAGE_MANIFEST_ENV} 只在项目级布局下可用")
|
|
674
|
+
return 1
|
|
675
|
+
if manifest.is_symlink() or not manifest.is_file():
|
|
676
|
+
print(f"[launch_bugx] ✗ 显式覆盖清单不可用: {manifest}")
|
|
677
|
+
return 1
|
|
678
|
+
try:
|
|
679
|
+
rows, errors = module_coverage.parse_manifest(manifest)
|
|
680
|
+
except (OSError, UnicodeError, ValueError) as exc:
|
|
681
|
+
print(f"[launch_bugx] ✗ 显式覆盖清单解析失败: {exc}")
|
|
682
|
+
return 1
|
|
683
|
+
if errors:
|
|
684
|
+
print(f"[launch_bugx] ✗ 显式覆盖清单有解析错误: {errors[0]}")
|
|
685
|
+
return 1
|
|
686
|
+
units = [_manifest_unit_path(row) for row in rows]
|
|
687
|
+
units = [unit for unit in units if unit and unit not in {"-", "待定", "N/A"}]
|
|
688
|
+
if not units:
|
|
689
|
+
print("[launch_bugx] ✗ 显式覆盖清单没有任何可审计单元")
|
|
690
|
+
return 1
|
|
691
|
+
resolved_root = root.resolve()
|
|
692
|
+
outside: list[str] = []
|
|
693
|
+
for unit in units:
|
|
694
|
+
target = (resolved_root / unit).resolve()
|
|
695
|
+
if resolved_root not in target.parents and target != resolved_root:
|
|
696
|
+
outside.append(unit)
|
|
697
|
+
elif not target.exists():
|
|
698
|
+
outside.append(unit)
|
|
699
|
+
if outside:
|
|
700
|
+
print(
|
|
701
|
+
"[launch_bugx] ✗ 显式覆盖清单包含项目外或不存在的单元: "
|
|
702
|
+
+ ", ".join(sorted(outside)[:5])
|
|
703
|
+
)
|
|
704
|
+
return 1
|
|
705
|
+
# 落位前用**同一套**门禁规则预检:post 阶段会用 startup_gate_errors 的质量口径
|
|
706
|
+
# (symbol 级单元 + 符号索引/关系图 marker + 完整 plan 字段)复核清单,
|
|
707
|
+
# 只做轻校验的显式清单会在跑到后段才被拒(实测 anchored 轮次就是这样变成
|
|
708
|
+
# FAILED)。这里提前 fail-fast,把原因在启动阶段说清楚。
|
|
709
|
+
try:
|
|
710
|
+
from core.coverage import coverage_gate
|
|
711
|
+
except ImportError:
|
|
712
|
+
coverage_gate = None
|
|
713
|
+
if coverage_gate is not None:
|
|
714
|
+
try:
|
|
715
|
+
gate_errors = coverage_gate.startup_gate_errors(resolved_root, manifest)
|
|
716
|
+
except (OSError, ValueError, RuntimeError) as exc:
|
|
717
|
+
print(f"[launch_bugx] ✗ 显式覆盖清单预检失败: {exc}")
|
|
718
|
+
return 1
|
|
719
|
+
if gate_errors:
|
|
720
|
+
print(
|
|
721
|
+
"[launch_bugx] ✗ 显式覆盖清单未通过覆盖门禁(需 symbol 级单元 + "
|
|
722
|
+
"符号索引/关系图 marker + 完整计划字段): " + "; ".join(gate_errors[:3])
|
|
723
|
+
)
|
|
724
|
+
return 1
|
|
725
|
+
scope = bugx_paths.require(resolved_root)
|
|
726
|
+
destination = scope.state_root / COVERAGE_MANIFEST_NAME
|
|
727
|
+
try:
|
|
728
|
+
destination.parent.mkdir(parents=True, exist_ok=True)
|
|
729
|
+
payload = manifest.read_bytes()
|
|
730
|
+
if destination.is_file():
|
|
731
|
+
existing = destination.read_bytes()
|
|
732
|
+
if existing != payload:
|
|
733
|
+
# 只在**已有真实进度**时拒绝覆盖。清单是「哪些单元算审计完成」的唯一
|
|
734
|
+
# 账本,抹掉 covered 行就是数据丢失;但全 pending 的清单(模板 / 刚
|
|
735
|
+
# bootstrap 出来还没跑过)没有进度可丢,必须允许显式清单替换——
|
|
736
|
+
# 否则 `run_init_pipeline` 先建的模板清单会把显式审计范围永久挡在门外。
|
|
737
|
+
if _manifest_has_progress(existing):
|
|
738
|
+
print(
|
|
739
|
+
"[launch_bugx] ✗ 项目覆盖清单已有进度,拒绝用显式清单覆盖: "
|
|
740
|
+
f"{destination}(如需改用请先备份并移除该文件)"
|
|
741
|
+
)
|
|
742
|
+
return 1
|
|
743
|
+
destination.write_bytes(payload)
|
|
744
|
+
else:
|
|
745
|
+
destination.write_bytes(payload)
|
|
746
|
+
except OSError as exc:
|
|
747
|
+
print(f"[launch_bugx] ✗ 显式覆盖清单落位失败: {exc}")
|
|
748
|
+
return 1
|
|
749
|
+
print(
|
|
750
|
+
f"[launch_bugx] ✓ 使用显式覆盖清单({len(units)} 个单元,审计范围由调用方声明,"
|
|
751
|
+
"不 reconcile 到全仓)"
|
|
752
|
+
)
|
|
753
|
+
return 0
|
|
754
|
+
|
|
755
|
+
|
|
756
|
+
def coverage_startup_gate(
|
|
757
|
+
bootstrap_confirmed: bool = False, *, autonomous: bool = False,
|
|
758
|
+
) -> int:
|
|
759
|
+
"""Run the host-mediated coverage bootstrap gate before starting a run."""
|
|
760
|
+
explicit = _install_explicit_coverage_manifest(resolve_project_root())
|
|
761
|
+
if explicit is not None:
|
|
762
|
+
return explicit
|
|
763
|
+
if coverage_bootstrap is None or not uses_project_layout():
|
|
764
|
+
return 0
|
|
765
|
+
try:
|
|
766
|
+
state = coverage_bootstrap.inspect(resolve_project_root())
|
|
767
|
+
except (OSError, ValueError, RuntimeError) as exc:
|
|
768
|
+
print(f"[launch_bugx] ✗ 覆盖清单状态无法读取: {exc}")
|
|
769
|
+
return 1
|
|
770
|
+
if state.get("ready"):
|
|
771
|
+
return 0
|
|
772
|
+
if state.get("needs_reconcile"):
|
|
773
|
+
try:
|
|
774
|
+
res = coverage_bootstrap.bootstrap(resolve_project_root(), confirmed=True, reconcile=True)
|
|
775
|
+
# 宿主 AI 是覆盖范围的审核兜底:对账差异(新增/失效移除的具体单元)
|
|
776
|
+
# 必须显性输出,否则引擎自产工件混入审计范围时只会看到一个数量,
|
|
777
|
+
# 审核信号在 bootstrap 内算完即丢(实测 .bugx-project.json 污染
|
|
778
|
+
# 以"1 个单元"静默通过)。
|
|
779
|
+
diff = res.get("inventory_diff") or {}
|
|
780
|
+
added = sorted(str(item) for item in (diff.get("added") or []))
|
|
781
|
+
removed = sorted(str(item) for item in (diff.get("removed") or []))
|
|
782
|
+
detail = ""
|
|
783
|
+
if added:
|
|
784
|
+
detail += "新增: " + ", ".join(added)
|
|
785
|
+
if removed:
|
|
786
|
+
if detail:
|
|
787
|
+
detail += ";"
|
|
788
|
+
detail += "失效移除: " + ", ".join(removed)
|
|
789
|
+
print(
|
|
790
|
+
f"[launch_bugx] ✓ 覆盖清单完成增量对账自愈(清除失效幽灵行并同步新单元):{res.get('units', 0)} 个单元"
|
|
791
|
+
+ (f"({detail})" if detail else "")
|
|
792
|
+
+ ";继续启动。"
|
|
793
|
+
)
|
|
794
|
+
return 0
|
|
795
|
+
except coverage_bootstrap.CoverageBootstrapError as exc:
|
|
796
|
+
print(f"[launch_bugx] ✗ 覆盖清单增量重扫对账失败: {exc}")
|
|
797
|
+
return 1
|
|
798
|
+
if state.get("blocked"):
|
|
799
|
+
print(f"[launch_bugx] ✗ {state.get('detail') or '覆盖清单门禁失败'}")
|
|
800
|
+
print(" 活动生命周期不会被静默重建;请从备份恢复后再继续。")
|
|
801
|
+
return 1
|
|
802
|
+
if bootstrap_confirmed or autonomous:
|
|
803
|
+
choice = True
|
|
804
|
+
else:
|
|
805
|
+
choice = _ask_coverage_bootstrap()
|
|
806
|
+
if choice is None:
|
|
807
|
+
emit_startup_gate(
|
|
808
|
+
"coverage_bootstrap",
|
|
809
|
+
"覆盖清单尚未建立,是否运行引导创建?",
|
|
810
|
+
[
|
|
811
|
+
{
|
|
812
|
+
"label": "运行引导创建",
|
|
813
|
+
"description": "由受控引导创建本生命周期最小覆盖单元,然后自动重试启动",
|
|
814
|
+
"value": "bootstrap",
|
|
815
|
+
"action": "bootstrap_coverage",
|
|
816
|
+
},
|
|
817
|
+
{
|
|
818
|
+
"label": "下次再说",
|
|
819
|
+
"description": "停止本轮启动,不创建或修改任何运行态清单",
|
|
820
|
+
"value": "later",
|
|
821
|
+
"action": "stop_startup",
|
|
822
|
+
},
|
|
823
|
+
],
|
|
824
|
+
detail=str(state.get("detail") or "覆盖清单缺失"),
|
|
825
|
+
)
|
|
826
|
+
return POLLING_DECISION_REQUIRED
|
|
827
|
+
if not choice:
|
|
828
|
+
print("[launch_bugx] 本轮未创建覆盖清单,启动已停止。")
|
|
829
|
+
return POLLING_DECISION_REQUIRED
|
|
830
|
+
try:
|
|
831
|
+
result = coverage_bootstrap.bootstrap(resolve_project_root(), confirmed=True)
|
|
832
|
+
except coverage_bootstrap.CoverageBootstrapError as exc:
|
|
833
|
+
print(f"[launch_bugx] ✗ 覆盖清单引导创建失败({exc.code}): {exc}")
|
|
834
|
+
return 1
|
|
835
|
+
print(
|
|
836
|
+
f"[launch_bugx] ✓ 覆盖清单引导创建完成:{result.get('units', 0)} 个最小单元;"
|
|
837
|
+
"继续启动。"
|
|
838
|
+
)
|
|
839
|
+
return 0
|
|
840
|
+
|
|
841
|
+
def _map_aborted_session_answer(value: str | None) -> str | None:
|
|
842
|
+
"""aborted_session 选择值→动作映射单一真源(TTY / 信箱两通道共用)。
|
|
843
|
+
|
|
844
|
+
TTY 文本菜单经 ``ask_interaction`` 返回选项序号("1"/"2");信箱通道
|
|
845
|
+
(``bugx interaction answer aborted_session``)经 ``take_answer`` 返回
|
|
846
|
+
结构化门禁的语义 value("resume"/"new")。两通道必须落到同一动作,
|
|
847
|
+
否则语义答案会在 ask 内被消费(consumed_at 已置位)却被映射丢弃,
|
|
848
|
+
门禁无限重发。
|
|
849
|
+
"""
|
|
850
|
+
low = (value or "").strip().lower()
|
|
851
|
+
if low in {"1", "resume"}:
|
|
852
|
+
return "resume"
|
|
853
|
+
if low in {"2", "new"}:
|
|
854
|
+
return "new"
|
|
855
|
+
return None
|
|
856
|
+
|
|
857
|
+
|
|
858
|
+
def _ask_aborted_session_choice() -> str | None:
|
|
859
|
+
"""通过统一组件询问已中断会话的显式去向:恢复或新建。"""
|
|
860
|
+
result = ask_interaction(
|
|
861
|
+
"aborted_session", "检测到未完成的已中断会话,如何继续?", [
|
|
862
|
+
("恢复上一次会话", "继续未完成的 Session,保留已结算 Life 和覆盖进度"),
|
|
863
|
+
("新建本次会话", "保留旧 Session 为 abandoned,创建全新 Session/首个 Round"),
|
|
864
|
+
],
|
|
865
|
+
default=0,
|
|
866
|
+
)
|
|
867
|
+
return _map_aborted_session_answer(answered_value(result))
|
|
868
|
+
|
|
869
|
+
def aborted_session_gate(
|
|
870
|
+
previous_runtime: dict, explicit_choice: str | None = None, *,
|
|
871
|
+
autonomous: bool = False,
|
|
872
|
+
) -> tuple[int, str | None]:
|
|
873
|
+
"""已中断 Session 的启动门禁:必须显式选择恢复或新建,不能静默复用。
|
|
874
|
+
|
|
875
|
+
返回 (code, choice)。code==0 且 choice in {"resume","new"} 表示已通过,
|
|
876
|
+
code==2 表示需要用户决策,code==1 表示硬失败。
|
|
877
|
+
"""
|
|
878
|
+
if previous_runtime.get("state") != "aborted":
|
|
879
|
+
return 0, None
|
|
880
|
+
choice = explicit_choice
|
|
881
|
+
if choice not in {"resume", "new"} and autonomous:
|
|
882
|
+
choice = "resume"
|
|
883
|
+
if choice not in {"resume", "new"}:
|
|
884
|
+
choice = _ask_aborted_session_choice()
|
|
885
|
+
if choice is None:
|
|
886
|
+
emit_startup_gate(
|
|
887
|
+
"aborted_session",
|
|
888
|
+
"检测到未完成的已中断会话,选择恢复或新建",
|
|
889
|
+
[
|
|
890
|
+
{
|
|
891
|
+
"label": "恢复上一次会话",
|
|
892
|
+
"description": "继续未完成的 Session,保留已结算 Life 和覆盖进度",
|
|
893
|
+
"value": "resume",
|
|
894
|
+
"action": "resume_session",
|
|
895
|
+
},
|
|
896
|
+
{
|
|
897
|
+
"label": "新建本次会话",
|
|
898
|
+
"description": "保留旧 Session 为 abandoned,创建全新 Session/首个 Round",
|
|
899
|
+
"value": "new",
|
|
900
|
+
"action": "create_new_session",
|
|
901
|
+
},
|
|
902
|
+
],
|
|
903
|
+
detail="aborted 会话不能静默复用;必须显式选择恢复或新建",
|
|
904
|
+
)
|
|
905
|
+
return POLLING_DECISION_REQUIRED, None
|
|
906
|
+
return 0, choice
|
|
907
|
+
|
|
908
|
+
def _discard_stale_draft(root: Path, *, reason: str) -> None:
|
|
909
|
+
"""DOC-236 C4:显式丢弃过期/损坏的作战方案草稿(可观测,绝不静默)。
|
|
910
|
+
|
|
911
|
+
丢弃是**幂等**的:文件不存在即无操作;删除失败只记录,不阻断启动
|
|
912
|
+
(草稿只是中间产物,正式真源是 runtime 内的 ``strategy_plan``)。
|
|
913
|
+
"""
|
|
914
|
+
draft = root / ".bugx" / "state" / "strategy-plan.json"
|
|
915
|
+
if not draft.is_file() and not draft.is_symlink():
|
|
916
|
+
return
|
|
917
|
+
try:
|
|
918
|
+
draft.unlink()
|
|
919
|
+
except OSError as exc:
|
|
920
|
+
print(f"[launch_bugx] 作战方案草稿清理失败({type(exc).__name__}):{draft}")
|
|
921
|
+
return
|
|
922
|
+
print(f"[launch_bugx] 已丢弃作战方案草稿({reason}):{draft}")
|
|
923
|
+
|
|
924
|
+
|
|
925
|
+
|
|
926
|
+
def check_stage_prompts_integrity(root: Path | None = None) -> tuple[bool, str]:
|
|
927
|
+
"""校验阶段与规则提示词的加载完整性(DOC-034 阶段 3 防偷懒门禁)。
|
|
928
|
+
|
|
929
|
+
必须确保:
|
|
930
|
+
1. L0 路由入口 (prompts/l0_router.md) 存在且非空
|
|
931
|
+
2. 全部 L1 阶段卡 (gate, explore, mutate, repair) 存在且可加载
|
|
932
|
+
3. 全部 L2 专项规则 (anti_patterns, concurrency, memory_leak, prompt_injection) 存在且可加载
|
|
933
|
+
"""
|
|
934
|
+
try:
|
|
935
|
+
from core.planning import prompt_harness
|
|
936
|
+
except ImportError as exc:
|
|
937
|
+
return False, f"提示词装配模块缺失: {exc}"
|
|
938
|
+
|
|
939
|
+
target_root = root if root is not None else resolve_project_root()
|
|
940
|
+
prompts_dir = prompt_harness.get_prompts_dir(target_root)
|
|
941
|
+
if not prompts_dir.is_dir():
|
|
942
|
+
return False, f"提示词目录缺失: {prompts_dir}"
|
|
943
|
+
|
|
944
|
+
l0_file = prompts_dir / "l0_router.md"
|
|
945
|
+
if not l0_file.is_file():
|
|
946
|
+
return False, f"L0 路由入口文件缺失: {l0_file}"
|
|
947
|
+
try:
|
|
948
|
+
if not l0_file.read_text(encoding="utf-8").strip():
|
|
949
|
+
return False, f"L0 路由入口文件为空: {l0_file}"
|
|
950
|
+
except Exception as exc:
|
|
951
|
+
return False, f"L0 路由入口读取失败: {exc}"
|
|
952
|
+
|
|
953
|
+
for stage_name in prompt_harness.list_available_stages():
|
|
954
|
+
try:
|
|
955
|
+
content = prompt_harness.load_stage(stage_name, root=target_root)
|
|
956
|
+
if not content.strip():
|
|
957
|
+
return False, f"阶段卡 {stage_name} 内容为空"
|
|
958
|
+
except Exception as exc:
|
|
959
|
+
return False, f"阶段卡 {stage_name} 加载失败: {exc}"
|
|
960
|
+
|
|
961
|
+
for rule_name in sorted(prompt_harness._RULE_MAP.keys()):
|
|
962
|
+
try:
|
|
963
|
+
content = prompt_harness.load_rule(rule_name, root=target_root)
|
|
964
|
+
if not content.strip():
|
|
965
|
+
return False, f"专项规则 {rule_name} 内容为空"
|
|
966
|
+
except Exception as exc:
|
|
967
|
+
return False, f"专项规则 {rule_name} 加载失败: {exc}"
|
|
968
|
+
|
|
969
|
+
return True, "ok"
|
|
970
|
+
|
|
971
|
+
|
|
972
|
+
def check_global_budget_gate(
|
|
973
|
+
project_root: Path | None = None,
|
|
974
|
+
*,
|
|
975
|
+
ignore_budget: bool = False,
|
|
976
|
+
db_path: Path | str | None = None,
|
|
977
|
+
) -> tuple[bool, str]:
|
|
978
|
+
"""检查全局每日 Token 与耗时预算配额门禁 (DOC-049)。
|
|
979
|
+
|
|
980
|
+
支持环境变量配置:
|
|
981
|
+
- BUGX_GLOBAL_DAILY_TOKEN_LIMIT: 单日全机跨项目 Token 上限(整数)
|
|
982
|
+
- BUGX_GLOBAL_DAILY_DURATION_LIMIT: 单日全机跨项目运行耗时上限(秒,浮点或整数)
|
|
983
|
+
|
|
984
|
+
当累计使用量超过任一限制时阻断启动,防止多项目并发或死循环失控刷穿 API 账单。
|
|
985
|
+
可通过 ignore_budget=True 或将环境变量置 0 / 清空绕过。
|
|
986
|
+
任何读取或计算异常均 fail-open 放行,确保不阻断正常业务。
|
|
987
|
+
"""
|
|
988
|
+
if ignore_budget:
|
|
989
|
+
return True, "ok"
|
|
990
|
+
|
|
991
|
+
token_limit_raw = os.getenv("BUGX_GLOBAL_DAILY_TOKEN_LIMIT", "").strip()
|
|
992
|
+
duration_limit_raw = os.getenv("BUGX_GLOBAL_DAILY_DURATION_LIMIT", "").strip()
|
|
993
|
+
|
|
994
|
+
token_limit: int | None = None
|
|
995
|
+
if token_limit_raw:
|
|
996
|
+
try:
|
|
997
|
+
val = int(token_limit_raw)
|
|
998
|
+
if val > 0:
|
|
999
|
+
token_limit = val
|
|
1000
|
+
except ValueError:
|
|
1001
|
+
pass
|
|
1002
|
+
|
|
1003
|
+
duration_limit: float | None = None
|
|
1004
|
+
if duration_limit_raw:
|
|
1005
|
+
try:
|
|
1006
|
+
val = float(duration_limit_raw)
|
|
1007
|
+
if val > 0:
|
|
1008
|
+
duration_limit = val
|
|
1009
|
+
except ValueError:
|
|
1010
|
+
pass
|
|
1011
|
+
|
|
1012
|
+
if token_limit is None and duration_limit is None:
|
|
1013
|
+
return True, "ok"
|
|
1014
|
+
|
|
1015
|
+
try:
|
|
1016
|
+
from core.runtime import global_telemetry
|
|
1017
|
+
except ImportError:
|
|
1018
|
+
return True, "ok"
|
|
1019
|
+
|
|
1020
|
+
try:
|
|
1021
|
+
if token_limit is not None:
|
|
1022
|
+
consumed_tokens = global_telemetry.get_daily_token_consumption(db_path=db_path)
|
|
1023
|
+
if consumed_tokens >= token_limit:
|
|
1024
|
+
msg = (
|
|
1025
|
+
f"今日全局已消耗 {consumed_tokens} Tokens,超过每日预算上限 "
|
|
1026
|
+
f"{token_limit} Tokens。可通过 --ignore-global-budget 忽略或调整 "
|
|
1027
|
+
f"BUGX_GLOBAL_DAILY_TOKEN_LIMIT 环境变量。"
|
|
1028
|
+
)
|
|
1029
|
+
return False, msg
|
|
1030
|
+
|
|
1031
|
+
if duration_limit is not None:
|
|
1032
|
+
consumed_duration = global_telemetry.get_daily_duration_consumption(db_path=db_path)
|
|
1033
|
+
if consumed_duration >= duration_limit:
|
|
1034
|
+
msg = (
|
|
1035
|
+
f"今日全局已运行 {consumed_duration:.1f} 秒,超过每日运行耗时上限 "
|
|
1036
|
+
f"{duration_limit:.1f} 秒。可通过 --ignore-global-budget 忽略或调整 "
|
|
1037
|
+
f"BUGX_GLOBAL_DAILY_DURATION_LIMIT 环境变量。"
|
|
1038
|
+
)
|
|
1039
|
+
return False, msg
|
|
1040
|
+
except Exception as exc:
|
|
1041
|
+
strict = os.environ.get("BUGX_STRICT_BUDGET", "").strip().lower() in {"1", "true", "yes"}
|
|
1042
|
+
print(f"[launch_bugx] ⚠ 全局预算遥测读取异常: {exc}", file=sys.stderr)
|
|
1043
|
+
if strict:
|
|
1044
|
+
return False, f"全局预算门禁检查异常(严格模式阻断): {exc}"
|
|
1045
|
+
return True, "ok"
|
|
1046
|
+
|
|
1047
|
+
return True, "ok"
|
|
1048
|
+
|
|
1049
|
+
|
|
1050
|
+
check_global_budget_gate = check_global_budget_gate
|