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,1371 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import copy
|
|
5
|
+
import hashlib
|
|
6
|
+
import json
|
|
7
|
+
import os
|
|
8
|
+
import re
|
|
9
|
+
import shutil
|
|
10
|
+
import subprocess
|
|
11
|
+
import sys
|
|
12
|
+
import tempfile
|
|
13
|
+
import time
|
|
14
|
+
import uuid
|
|
15
|
+
from pathlib import Path
|
|
16
|
+
from typing import Any
|
|
17
|
+
|
|
18
|
+
from .. import __version__
|
|
19
|
+
from ..common import *
|
|
20
|
+
from .agent import (
|
|
21
|
+
_check_host_mcp_config,
|
|
22
|
+
_check_opencode_config,
|
|
23
|
+
_detected_host_name,
|
|
24
|
+
_ensure_opencode_config,
|
|
25
|
+
)
|
|
26
|
+
from .knowledge import _cloud_login_and_register, _cloud_sync_command
|
|
27
|
+
|
|
28
|
+
MAX_SYNC_BUNDLE_BYTES = 16 * 1024 * 1024
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
_TLS_ERROR_MARKERS = (
|
|
32
|
+
"CERTIFICATE_VERIFY_FAILED",
|
|
33
|
+
"certificate verify failed",
|
|
34
|
+
"self-signed certificate",
|
|
35
|
+
"certificate has expired",
|
|
36
|
+
"SSLCertVerificationError",
|
|
37
|
+
"hostname mismatch",
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _is_tls_failure(error: object) -> bool:
|
|
42
|
+
"""区分 TLS 信任失败与普通网络不可达。
|
|
43
|
+
|
|
44
|
+
两者在 ``verify_auth()`` 中都表现为“联网核验失败”,但处置方式完全不同:
|
|
45
|
+
前者需要信任证书或配置 ``SSL_CERT_FILE``,后者需要排查网络与地址。
|
|
46
|
+
混为一谈会把证书问题误导成“API key 失效”。
|
|
47
|
+
"""
|
|
48
|
+
text = str(error or "")
|
|
49
|
+
return any(marker in text for marker in _TLS_ERROR_MARKERS)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def _is_local_network_privacy_failure(error: object, base_url: str = "") -> bool:
|
|
53
|
+
"""识别 macOS 私网访问被本地网络隐私权限拦截的失败。"""
|
|
54
|
+
data = error if isinstance(error, dict) else getattr(error, "data", None)
|
|
55
|
+
if isinstance(data, dict):
|
|
56
|
+
code = data.get("code")
|
|
57
|
+
nested = data.get("data")
|
|
58
|
+
if isinstance(nested, dict):
|
|
59
|
+
code = nested.get("code", code)
|
|
60
|
+
if str(code or "").upper() == "LOCAL_NETWORK_BLOCKED":
|
|
61
|
+
return True
|
|
62
|
+
|
|
63
|
+
if not base_url:
|
|
64
|
+
return False
|
|
65
|
+
try:
|
|
66
|
+
from core.cloud_sync.cloud_client import diagnose_network_error
|
|
67
|
+
except (ImportError, AttributeError):
|
|
68
|
+
return False
|
|
69
|
+
raw_error = error.get("error") if isinstance(error, dict) else getattr(error, "error", error)
|
|
70
|
+
if not isinstance(raw_error, BaseException):
|
|
71
|
+
raw_error = Exception(str(raw_error or error))
|
|
72
|
+
return bool(diagnose_network_error(raw_error, str(base_url)).get(
|
|
73
|
+
"is_local_network_blocked", False
|
|
74
|
+
))
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def _telemetry_config_path() -> Path:
|
|
78
|
+
default = Path(os.environ.get("BUGX_HOME", str(Path.home() / ".bugx"))) / "cloud-config.json"
|
|
79
|
+
return Path(os.environ.get("BUGX_CLOUD_CONFIG", str(default))).expanduser()
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def _save_data_sharing(value: bool) -> None:
|
|
83
|
+
path = _telemetry_config_path()
|
|
84
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
85
|
+
try:
|
|
86
|
+
current = json.loads(path.read_text(encoding="utf-8")) if path.is_file() else {}
|
|
87
|
+
except (OSError, json.JSONDecodeError):
|
|
88
|
+
current = {}
|
|
89
|
+
if not isinstance(current, dict):
|
|
90
|
+
current = {}
|
|
91
|
+
telemetry = dict(current.get("telemetry") or {})
|
|
92
|
+
telemetry["data_sharing"] = bool(value)
|
|
93
|
+
current["telemetry"] = telemetry
|
|
94
|
+
temporary = path.with_suffix(path.suffix + ".tmp")
|
|
95
|
+
temporary.write_text(json.dumps(current, ensure_ascii=False, indent=2), encoding="utf-8")
|
|
96
|
+
os.replace(temporary, path)
|
|
97
|
+
os.chmod(path, 0o600)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def confirm_data_sharing(args: argparse.Namespace) -> bool:
|
|
101
|
+
"""数据共享同意;**已选择云同步即视为同意**,不再重复询问。
|
|
102
|
+
|
|
103
|
+
为什么这样改(build 297):``--cloud-sync sync`` 与「是否允许共享」在用户
|
|
104
|
+
视角是**同一个决策**——不许上传的话选 sync 毫无意义。此前 ``init`` 末尾会
|
|
105
|
+
再弹一次「允许 BugX 上传脱敏后的攻防数据用于改进平台?」,等于同一个决定
|
|
106
|
+
问两遍,且两套状态各存一处(``cloud-onboard.json`` vs ``cloud-config.json``),
|
|
107
|
+
很容易出现「选了 sync 却因共享未表态而同步不了」。
|
|
108
|
+
|
|
109
|
+
语义收敛:
|
|
110
|
+
* ``--cloud-sync sync`` ⇒ 共享同意落盘为 true(选择即同意);
|
|
111
|
+
* ``--cloud-sync local`` ⇒ **不写**共享状态(只表示本项目不同步,
|
|
112
|
+
不应替用户做「全局撤销」这种跨项目决定);
|
|
113
|
+
* 未指定 cloud-sync ⇒ 保持原有询问/默认逻辑。
|
|
114
|
+
"""
|
|
115
|
+
if str(getattr(args, "cloud_sync", "") or "").strip().lower() == "sync":
|
|
116
|
+
_save_data_sharing(True)
|
|
117
|
+
return True
|
|
118
|
+
if getattr(args, "privacy", "standard") == "strict":
|
|
119
|
+
_save_data_sharing(bool(getattr(args, "accept_data_sharing", False)))
|
|
120
|
+
return bool(getattr(args, "accept_data_sharing", False))
|
|
121
|
+
if getattr(args, "accept_data_sharing", False) or os.environ.get("BUGX_ACCEPT_DATA_SHARING") == "1":
|
|
122
|
+
_save_data_sharing(True)
|
|
123
|
+
return True
|
|
124
|
+
path = _telemetry_config_path()
|
|
125
|
+
try:
|
|
126
|
+
config = json.loads(path.read_text(encoding="utf-8")) if path.is_file() else {}
|
|
127
|
+
stored = (config.get("telemetry") or {}).get("data_sharing")
|
|
128
|
+
except (OSError, json.JSONDecodeError):
|
|
129
|
+
stored = None
|
|
130
|
+
if isinstance(stored, bool):
|
|
131
|
+
return stored
|
|
132
|
+
if (
|
|
133
|
+
os.environ.get("CI", "").lower() == "true"
|
|
134
|
+
or os.environ.get("BUGX_NON_INTERACTIVE") == "1"
|
|
135
|
+
or os.environ.get("BUGX_HEADLESS") == "1"
|
|
136
|
+
or "unittest" in sys.modules
|
|
137
|
+
or "pytest" in sys.modules
|
|
138
|
+
or not sys.stdin.isatty()
|
|
139
|
+
):
|
|
140
|
+
# **不得替用户撤销同意**(build 293 实测缺陷):此前这里
|
|
141
|
+
# ``_save_data_sharing(False)`` 把「本次无法交互确认」永久写成
|
|
142
|
+
# ``data_sharing=false`` ⇒ 一次非交互运行就让该用户此后所有云同步被
|
|
143
|
+
# ``data_sharing_revoked`` 拒绝,而用户从未做过任何撤销动作。
|
|
144
|
+
# 契约是「默认允许、仅显式 false 才拒绝」(``require_sharing`` 只看
|
|
145
|
+
# ``sharing_revoked()``),所以非交互时**不落盘**、按默认允许处理。
|
|
146
|
+
return True
|
|
147
|
+
try:
|
|
148
|
+
answer = input("允许 BugX 上传脱敏后的攻防数据用于改进平台?[y/N] ").strip().lower()
|
|
149
|
+
except (EOFError, OSError):
|
|
150
|
+
answer = "n"
|
|
151
|
+
allowed = answer in {"y", "yes"}
|
|
152
|
+
_save_data_sharing(allowed)
|
|
153
|
+
return allowed
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def command_telemetry(args: argparse.Namespace) -> int:
|
|
157
|
+
"""Inspect and export the independent flywheel outbox/forensic ledger."""
|
|
158
|
+
try:
|
|
159
|
+
_ensure_core_importable()
|
|
160
|
+
from core.cloud_sync.flywheel_client import FlywheelUploader
|
|
161
|
+
uploader = FlywheelUploader(data_sharing=True)
|
|
162
|
+
action = getattr(args, "telemetry_command", "inspect")
|
|
163
|
+
if action == "inspect":
|
|
164
|
+
result = uploader.inspect(latest=bool(getattr(args, "latest", False)))
|
|
165
|
+
if getattr(args, "json", False):
|
|
166
|
+
print(json.dumps(result, ensure_ascii=False, indent=2))
|
|
167
|
+
else:
|
|
168
|
+
for entry in result:
|
|
169
|
+
print(json.dumps(entry, ensure_ascii=False))
|
|
170
|
+
return 0
|
|
171
|
+
if action in {"flush", "upload"}:
|
|
172
|
+
batch_size = int(getattr(args, "batch_size", 20) or 20)
|
|
173
|
+
flushed = uploader.flush(batch_size=batch_size)
|
|
174
|
+
sent = flushed.get("sent", flushed) if isinstance(flushed, dict) else flushed
|
|
175
|
+
print(f"[telemetry] 已推送并清空本地 Outbox:{sent} 条事件")
|
|
176
|
+
return 0
|
|
177
|
+
output = uploader.export_bundle(
|
|
178
|
+
getattr(args, "out"),
|
|
179
|
+
passphrase=getattr(args, "passphrase", None) or os.environ.get("BUGX_TELEMETRY_PASSPHRASE"),
|
|
180
|
+
)
|
|
181
|
+
print(f"[telemetry] 已导出加密穿梭包: {output}")
|
|
182
|
+
return 0
|
|
183
|
+
except Exception as exc: # noqa: BLE001
|
|
184
|
+
print(f"[telemetry] 操作失败: {exc}")
|
|
185
|
+
return 1
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def command_telemetry_config(args: argparse.Namespace) -> int:
|
|
189
|
+
config_key = getattr(args, "config_key", "")
|
|
190
|
+
config_value = getattr(args, "config_value", "")
|
|
191
|
+
if config_key == "telemetry.data_sharing":
|
|
192
|
+
if config_value not in ("true", "false"):
|
|
193
|
+
print("[config] telemetry.data_sharing 只接受 true/false")
|
|
194
|
+
return 2
|
|
195
|
+
enabled = config_value == "true"
|
|
196
|
+
try:
|
|
197
|
+
_save_data_sharing(enabled)
|
|
198
|
+
if not enabled:
|
|
199
|
+
_ensure_core_importable()
|
|
200
|
+
from core.cloud_sync.flywheel_client import FlywheelUploader
|
|
201
|
+
cleared = FlywheelUploader(data_sharing=True).clear_outbox()
|
|
202
|
+
print(f"[config] telemetry.data_sharing=false;已清空 {cleared} 条飞轮记录")
|
|
203
|
+
print("[config] 云端同步已停用:撤销态下 sync_layers/auto_sync 拒绝所有 push/pull")
|
|
204
|
+
else:
|
|
205
|
+
print("[config] telemetry.data_sharing=true")
|
|
206
|
+
return 0
|
|
207
|
+
except Exception as exc: # noqa: BLE001
|
|
208
|
+
print(f"[config] 写入失败: {exc}")
|
|
209
|
+
return 1
|
|
210
|
+
if config_key.startswith("cloud."):
|
|
211
|
+
# DOC-211 同步内容策略键;清飞轮等副作用严格限定在 data_sharing。
|
|
212
|
+
field = config_key[len("cloud."):]
|
|
213
|
+
try:
|
|
214
|
+
from core.cloud_sync.cloud_client import update_cloud_config
|
|
215
|
+
written = update_cloud_config({field: config_value})
|
|
216
|
+
except ValueError as exc:
|
|
217
|
+
print(f"[config] 写入失败: {exc}")
|
|
218
|
+
return 2
|
|
219
|
+
except Exception as exc: # noqa: BLE001
|
|
220
|
+
print(f"[config] 写入失败: {exc}")
|
|
221
|
+
return 1
|
|
222
|
+
print(f"[config] {config_key}={written.get(field)} 已写入 ~/.bugx/cloud-config.json")
|
|
223
|
+
return 0
|
|
224
|
+
return 2
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
def _build_local_sync_bundle(client: Any, root: Path, scope: str,
|
|
228
|
+
detail_mode: str) -> dict[str, Any]:
|
|
229
|
+
from core.cloud_sync.cloud_onboard import get_account_id, get_imports, layer_ledger, resolve_store_path
|
|
230
|
+
from core.cloud_sync.cloud_schema import build_push_envelope
|
|
231
|
+
from core.cloud_sync.sync_push import _private_v2_records
|
|
232
|
+
|
|
233
|
+
ns = get_imports()
|
|
234
|
+
project_id = ""
|
|
235
|
+
if scope == "project":
|
|
236
|
+
from core.cloud_sync.cloud_onboard import load_project_binding
|
|
237
|
+
project_id = load_project_binding(root)
|
|
238
|
+
if not project_id:
|
|
239
|
+
raise ValueError("项目 scope 缺少 .bugx/cloud-project.json 绑定")
|
|
240
|
+
account_id = get_account_id(client)
|
|
241
|
+
store = ns["SyncStore"](resolve_store_path(ns, root, scope))
|
|
242
|
+
try:
|
|
243
|
+
state = store.get_scope_state(account_id, scope, project_id) or {}
|
|
244
|
+
prepared = _private_v2_records(
|
|
245
|
+
ns, layer_ledger(ns, root, scope), detail_mode=detail_mode,
|
|
246
|
+
sync_states=store.get_record_states(account_id, scope, project_id),
|
|
247
|
+
layer=scope,
|
|
248
|
+
)
|
|
249
|
+
finally:
|
|
250
|
+
store.close()
|
|
251
|
+
pid = int(project_id) if project_id else None
|
|
252
|
+
return build_push_envelope(
|
|
253
|
+
scope, pid, prepared["records"],
|
|
254
|
+
snapshot_id=f"export-{uuid.uuid4().hex}",
|
|
255
|
+
operation_id=f"export-op-{uuid.uuid4().hex}",
|
|
256
|
+
base_version=int(state.get("remote_version") or 0),
|
|
257
|
+
device_id=ns["get_device_id"](),
|
|
258
|
+
)
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
def _read_sync_bundle(path: Path) -> dict[str, Any]:
|
|
262
|
+
from core.secure_atomic import reject_symlink_components
|
|
263
|
+
from core.cloud_sync.cloud_schema import validate_push_envelope
|
|
264
|
+
|
|
265
|
+
reject_symlink_components(path)
|
|
266
|
+
if path.is_symlink() or not path.is_file():
|
|
267
|
+
raise ValueError("bundle 必须是普通文件,不能是符号链接")
|
|
268
|
+
if path.stat().st_size > MAX_SYNC_BUNDLE_BYTES:
|
|
269
|
+
raise ValueError(f"bundle 超过 {MAX_SYNC_BUNDLE_BYTES // (1024 * 1024)} MiB 限制")
|
|
270
|
+
try:
|
|
271
|
+
bundle = json.loads(path.read_text(encoding="utf-8"))
|
|
272
|
+
except (OSError, UnicodeError, json.JSONDecodeError) as exc:
|
|
273
|
+
raise ValueError("bundle 不是合法 JSON") from exc
|
|
274
|
+
return validate_push_envelope(bundle)
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
def command_cloud(args: argparse.Namespace) -> int:
|
|
278
|
+
"""云端同步:登录 / 同步 / 项目 / 设备 / onboarding。"""
|
|
279
|
+
try:
|
|
280
|
+
_ensure_core_importable()
|
|
281
|
+
from core.cloud_sync.cloud_client import CloudClient, get_device_id, lesson_to_wire, incident_to_wire
|
|
282
|
+
from core.ledger.lesson_ledger import read as read_ledger, list_incidents
|
|
283
|
+
from core.bugx_paths import global_knowledge_root, project_knowledge_root
|
|
284
|
+
except Exception as exc: # noqa: BLE001
|
|
285
|
+
print(f"[cloud] 依赖加载失败: {exc}")
|
|
286
|
+
return 2
|
|
287
|
+
|
|
288
|
+
root = args.root.resolve()
|
|
289
|
+
act = args.cloud_command
|
|
290
|
+
|
|
291
|
+
if act == "config":
|
|
292
|
+
try:
|
|
293
|
+
from core.cloud_sync.cloud_client import (
|
|
294
|
+
clear_cloud_base_url, cloud_base_url_status,
|
|
295
|
+
load_cloud_config, set_cloud_base_url,
|
|
296
|
+
)
|
|
297
|
+
disable_vc = getattr(args, "disable_version_check", None)
|
|
298
|
+
if getattr(args, "clear_base_url", False):
|
|
299
|
+
clear_cloud_base_url()
|
|
300
|
+
result = cloud_base_url_status()
|
|
301
|
+
message = "[cloud] 已清除持久化 Base URL"
|
|
302
|
+
elif getattr(args, "refresh_route", False):
|
|
303
|
+
from core.cloud_sync.cloud_client import clear_route_cache
|
|
304
|
+
clear_route_cache()
|
|
305
|
+
result = cloud_base_url_status()
|
|
306
|
+
message = f"[cloud] 已刷新路由测速缓存,当前端点: {result['base_url']}(来源: {result['source']})"
|
|
307
|
+
elif getattr(args, "base_url", None):
|
|
308
|
+
normalized = set_cloud_base_url(args.base_url)
|
|
309
|
+
result = cloud_base_url_status()
|
|
310
|
+
message = f"[cloud] 已设置云端 Base URL: {normalized}"
|
|
311
|
+
elif disable_vc is not None:
|
|
312
|
+
# Read current config, update disable_version_check, persist.
|
|
313
|
+
from core.cloud_sync.cloud_client import _cloud_config_path
|
|
314
|
+
from core.report_engine.report_client import _atomic_write_nofollow
|
|
315
|
+
cfg_path = _cloud_config_path()
|
|
316
|
+
existing = load_cloud_config(cfg_path)
|
|
317
|
+
existing["disable_version_check"] = (disable_vc == "true")
|
|
318
|
+
payload = json.dumps(existing, ensure_ascii=False, indent=2).encode("utf-8")
|
|
319
|
+
_atomic_write_nofollow(cfg_path, payload, parent_mode=0o700)
|
|
320
|
+
result = cloud_base_url_status()
|
|
321
|
+
result["disable_version_check"] = existing.get("disable_version_check", False)
|
|
322
|
+
if disable_vc == "true":
|
|
323
|
+
os.environ["BUGX_DISABLE_VERSION_CHECK"] = "1"
|
|
324
|
+
message = "[cloud] 已禁用启动时版本检查"
|
|
325
|
+
else:
|
|
326
|
+
os.environ.pop("BUGX_DISABLE_VERSION_CHECK", None)
|
|
327
|
+
message = "[cloud] 已启用启动时版本检查"
|
|
328
|
+
else:
|
|
329
|
+
result = cloud_base_url_status()
|
|
330
|
+
# Also show disable_version_check status.
|
|
331
|
+
cfg = load_cloud_config()
|
|
332
|
+
result["disable_version_check"] = cfg.get("disable_version_check", False)
|
|
333
|
+
vc_status = "禁用" if result["disable_version_check"] else "启用"
|
|
334
|
+
message = (
|
|
335
|
+
f"[cloud] 当前云端 Base URL: {result['base_url']}"
|
|
336
|
+
f"(来源: {result['source']});版本检查: {vc_status}"
|
|
337
|
+
)
|
|
338
|
+
except (OSError, ValueError, ImportError) as exc:
|
|
339
|
+
# P3d:_cloud_config_path/_atomic_write_nofollow 的二次 import
|
|
340
|
+
# 也会抛 ImportError,不能让它逃逸成未受控堆栈。
|
|
341
|
+
print(f"[cloud] 配置失败: {exc}")
|
|
342
|
+
return 2
|
|
343
|
+
if getattr(args, "json", False):
|
|
344
|
+
print(json.dumps(result, ensure_ascii=False, indent=2))
|
|
345
|
+
else:
|
|
346
|
+
print(message)
|
|
347
|
+
return 0
|
|
348
|
+
|
|
349
|
+
try:
|
|
350
|
+
client = CloudClient()
|
|
351
|
+
except ValueError as exc:
|
|
352
|
+
# DOC-211:坏配置不得裸奔 traceback;cloud config 子命令不经此路径,
|
|
353
|
+
# 修复入口始终可用。
|
|
354
|
+
print(f"[cloud] cloud-config.json 配置非法: {exc}")
|
|
355
|
+
print("[cloud] 修复:bugx config set cloud.<键> <合法值>,"
|
|
356
|
+
"或删除 ~/.bugx/cloud-config.json 后重试")
|
|
357
|
+
return 1
|
|
358
|
+
|
|
359
|
+
if act == "export":
|
|
360
|
+
try:
|
|
361
|
+
bundle = _build_local_sync_bundle(
|
|
362
|
+
client, root, args.bundle_scope,
|
|
363
|
+
getattr(args, "detail_mode", None) or "full",
|
|
364
|
+
)
|
|
365
|
+
output = Path(args.output).expanduser().absolute()
|
|
366
|
+
from core.report_engine.report_client import _atomic_write_nofollow
|
|
367
|
+
_atomic_write_nofollow(
|
|
368
|
+
output,
|
|
369
|
+
json.dumps(bundle, ensure_ascii=False, indent=2).encode("utf-8"),
|
|
370
|
+
parent_mode=0o700,
|
|
371
|
+
)
|
|
372
|
+
except (OSError, ValueError, RuntimeError) as exc:
|
|
373
|
+
print(f"[cloud] JSON 导出失败: {exc}")
|
|
374
|
+
return 1
|
|
375
|
+
print(f"[cloud] 已导出 {bundle['scope']} bundle: {output}")
|
|
376
|
+
return 0
|
|
377
|
+
|
|
378
|
+
if act == "upload":
|
|
379
|
+
try:
|
|
380
|
+
bundle = _read_sync_bundle(Path(args.input).expanduser().absolute())
|
|
381
|
+
# DOC-211:upload 与 sync 同吃一档敏感策略;配置缺失/非法取
|
|
382
|
+
# 安全默认 redact(F-025:原样出网必须显式 allow)。
|
|
383
|
+
try:
|
|
384
|
+
from core.cloud_sync.cloud_client import load_cloud_config
|
|
385
|
+
upload_policy = load_cloud_config().get("sensitive_policy") or "redact"
|
|
386
|
+
except Exception: # noqa: BLE001
|
|
387
|
+
upload_policy = "redact"
|
|
388
|
+
result = client.import_knowledge_bundle(
|
|
389
|
+
bundle, mode=args.mode, sensitive_policy=upload_policy)
|
|
390
|
+
except (OSError, ValueError, RuntimeError) as exc:
|
|
391
|
+
print(f"[cloud] JSON 上传失败: {exc}")
|
|
392
|
+
return 1
|
|
393
|
+
if not result.ok:
|
|
394
|
+
err = client.sync_error(result)
|
|
395
|
+
print(f"[cloud] JSON 上传被拒绝: code={err.code} {err.message or result.error}")
|
|
396
|
+
return 1
|
|
397
|
+
data = client._data(result)
|
|
398
|
+
if args.mode in ("local_authoritative", "merge"):
|
|
399
|
+
try:
|
|
400
|
+
from core.cloud_sync.cloud_onboard import get_account_id, get_imports, resolve_store_path
|
|
401
|
+
from core.cloud_sync.sync_pull import pull_layer
|
|
402
|
+
ns = get_imports()
|
|
403
|
+
account_id = get_account_id(client)
|
|
404
|
+
if account_id:
|
|
405
|
+
project_id = str(bundle.get("project_id") or "") if bundle["scope"] == "project" else ""
|
|
406
|
+
version = data.get("snapshot_version")
|
|
407
|
+
snapshot_id = data.get("snapshot_id")
|
|
408
|
+
if not isinstance(version, int) or isinstance(version, bool) or version < 0 \
|
|
409
|
+
or not isinstance(snapshot_id, str) or not snapshot_id:
|
|
410
|
+
raise ValueError("服务端导入响应缺少可信 snapshot_id/snapshot_version")
|
|
411
|
+
store = ns["SyncStore"](resolve_store_path(ns, root, bundle["scope"]))
|
|
412
|
+
try:
|
|
413
|
+
store.adopt_import_snapshot(
|
|
414
|
+
account_id, bundle["scope"], project_id,
|
|
415
|
+
snapshot_id=snapshot_id, remote_version=version,
|
|
416
|
+
)
|
|
417
|
+
finally:
|
|
418
|
+
store.close()
|
|
419
|
+
pull_result = pull_layer(
|
|
420
|
+
client, ns, root, bundle["scope"], project_id, account_id,
|
|
421
|
+
force_baseline=True,
|
|
422
|
+
)
|
|
423
|
+
if not isinstance(pull_result, dict) or not pull_result.get("ok"):
|
|
424
|
+
raise RuntimeError(
|
|
425
|
+
(pull_result or {}).get("error", "baseline pull failed")
|
|
426
|
+
if isinstance(pull_result, dict) else "baseline pull failed"
|
|
427
|
+
)
|
|
428
|
+
except Exception as exc: # noqa: BLE001
|
|
429
|
+
print(f"[cloud] 本地导入状态未能收敛: {exc}")
|
|
430
|
+
return 1
|
|
431
|
+
if getattr(args, "json", False):
|
|
432
|
+
print(json.dumps(data, ensure_ascii=False, indent=2))
|
|
433
|
+
else:
|
|
434
|
+
print(f"[cloud] JSON 上传完成: scope={bundle['scope']} mode={args.mode}")
|
|
435
|
+
return 0
|
|
436
|
+
|
|
437
|
+
if act == "log-report":
|
|
438
|
+
"""内测期诊断日志上报:打包 bugx.jsonl 尾部 -> POST /agent/log-reports。
|
|
439
|
+
|
|
440
|
+
默认不上报:仅在 AI/用户显式调用本命令时执行;服务端还有登录认证
|
|
441
|
+
与每账号每日限额(后台可配置)。
|
|
442
|
+
"""
|
|
443
|
+
tail_kb = max(1, min(1024, int(getattr(args, "tail_kb", 256) or 256)))
|
|
444
|
+
# 读取方必须跟随写入方的落点:未初始化项目会回退到用户级日志,
|
|
445
|
+
# 直接拼 <root>/.bugx/logs 会永远报"未找到诊断日志"。
|
|
446
|
+
log_file = diagnostic_log_path(root)
|
|
447
|
+
content = ""
|
|
448
|
+
lines = 0
|
|
449
|
+
if log_file.is_file():
|
|
450
|
+
size = log_file.stat().st_size
|
|
451
|
+
with log_file.open("rb") as fh:
|
|
452
|
+
if size > tail_kb * 1024:
|
|
453
|
+
fh.seek(size - tail_kb * 1024)
|
|
454
|
+
fh.readline() # 丢弃不完整的半行
|
|
455
|
+
content = fh.read().decode("utf-8", errors="replace")
|
|
456
|
+
lines = content.count("\n")
|
|
457
|
+
else:
|
|
458
|
+
print("[cloud] 未找到诊断日志(本次会话尚未产生日志),无需上报")
|
|
459
|
+
return 0
|
|
460
|
+
if not content.strip():
|
|
461
|
+
print("[cloud] 诊断日志为空,无需上报")
|
|
462
|
+
return 0
|
|
463
|
+
|
|
464
|
+
from core.cloud_sync.cloud_client import current_version_str
|
|
465
|
+
kind = str(getattr(args, "kind", None) or "cli-diagnostics").strip() or "cli-diagnostics"
|
|
466
|
+
body = {
|
|
467
|
+
"device_id": get_device_id(),
|
|
468
|
+
"client_version": current_version_str(),
|
|
469
|
+
"kind": kind,
|
|
470
|
+
"payload": content,
|
|
471
|
+
}
|
|
472
|
+
if getattr(args, "json", False):
|
|
473
|
+
print(json.dumps({"bytes": len(content.encode("utf-8")), "lines": lines},
|
|
474
|
+
ensure_ascii=False))
|
|
475
|
+
try:
|
|
476
|
+
result = client.post_log_report(body)
|
|
477
|
+
except Exception as exc: # noqa: BLE001
|
|
478
|
+
print(f"[cloud] 日志上报失败: {exc}")
|
|
479
|
+
return 1
|
|
480
|
+
envelope = getattr(result, "data", None)
|
|
481
|
+
payload_data = envelope.get("data") if isinstance(envelope, dict) else None
|
|
482
|
+
remaining = payload_data.get("remaining") if isinstance(payload_data, dict) else None
|
|
483
|
+
if not getattr(result, "ok", False):
|
|
484
|
+
err_text = getattr(result, "error", None) or str(envelope)
|
|
485
|
+
print(f"[cloud] 日志上报被拒绝: {err_text}")
|
|
486
|
+
if isinstance(payload_data, dict) and payload_data.get("limit") is not None:
|
|
487
|
+
print(f"[cloud] 今日配额: 已用 {payload_data.get('used')}/"
|
|
488
|
+
f"{payload_data.get('limit')},请明日再试")
|
|
489
|
+
return 1
|
|
490
|
+
tail_note = f",剩余 {remaining} 次" if remaining is not None else ""
|
|
491
|
+
print(f"[cloud] 日志上报成功({lines} 行{tail_note})")
|
|
492
|
+
return 0
|
|
493
|
+
|
|
494
|
+
if act == "feedback":
|
|
495
|
+
"""错题卡质量闭环:本地 feedback 汇总 -> POST /agent/lessons/hit-feedback。"""
|
|
496
|
+
try:
|
|
497
|
+
from core.ledger.lesson_ledger import feedback_outcomes
|
|
498
|
+
from core.bugx_paths import project_knowledge_root
|
|
499
|
+
except Exception as exc: # noqa: BLE001
|
|
500
|
+
print(f"[cloud] 依赖加载失败: {exc}")
|
|
501
|
+
return 2
|
|
502
|
+
try:
|
|
503
|
+
items = feedback_outcomes(
|
|
504
|
+
project_knowledge_root(root) / "lesson-ledger.sqlite3",
|
|
505
|
+
lifecycle_id=getattr(args, "lifecycle", None) or None,
|
|
506
|
+
limit=max(1, min(100, int(getattr(args, "limit", 100) or 100))),
|
|
507
|
+
)
|
|
508
|
+
except Exception as exc: # noqa: BLE001
|
|
509
|
+
print(f"[cloud] 本地反馈读取失败: {exc}")
|
|
510
|
+
return 2
|
|
511
|
+
if getattr(args, "json", False) or getattr(args, "dry_run", False):
|
|
512
|
+
preview = json.dumps({"items": items, "count": len(items)},
|
|
513
|
+
ensure_ascii=False, indent=2)
|
|
514
|
+
print(preview)
|
|
515
|
+
if getattr(args, "dry_run", False):
|
|
516
|
+
return 0
|
|
517
|
+
if not items:
|
|
518
|
+
print("[cloud] 没有可上报的错题卡反馈")
|
|
519
|
+
return 0
|
|
520
|
+
try:
|
|
521
|
+
result = client.post_lesson_hit_feedback(
|
|
522
|
+
items, run_id=getattr(args, "run_id", "") or "",
|
|
523
|
+
project_name=getattr(args, "project_name", "") or "",
|
|
524
|
+
)
|
|
525
|
+
except Exception as exc: # noqa: BLE001
|
|
526
|
+
print(f"[cloud] hit-feedback 上报失败: {exc}")
|
|
527
|
+
return 1
|
|
528
|
+
envelope = getattr(result, "data", None)
|
|
529
|
+
payload = envelope.get("data") if isinstance(envelope, dict) else None
|
|
530
|
+
updated = payload.get("updated") if isinstance(payload, dict) else "?"
|
|
531
|
+
missing = payload.get("missing") if isinstance(payload, dict) else "?"
|
|
532
|
+
if not getattr(result, "ok", False):
|
|
533
|
+
print(f"[cloud] hit-feedback 上报被拒绝: {getattr(result, 'error', None) or envelope}")
|
|
534
|
+
return 1
|
|
535
|
+
print(f"[cloud] hit-feedback 已上报: updated={updated} missing={missing}")
|
|
536
|
+
return 0
|
|
537
|
+
|
|
538
|
+
if act == "status":
|
|
539
|
+
"""只读展示本地同步状态;不登录、不联网、不创建 sync store。"""
|
|
540
|
+
try:
|
|
541
|
+
from core.runtime.sync_store import SyncStore, SyncStoreError, global_store_path, project_store_path
|
|
542
|
+
except Exception as exc: # noqa: BLE001
|
|
543
|
+
print(f"[cloud] 同步状态依赖加载失败: {exc}")
|
|
544
|
+
return 2
|
|
545
|
+
|
|
546
|
+
scope = getattr(args, "status_scope", "all")
|
|
547
|
+
scopes = ("global", "project") if scope == "all" else (scope,)
|
|
548
|
+
credential = getattr(client, "cred", None)
|
|
549
|
+
user = getattr(credential, "user", None)
|
|
550
|
+
account_id = ""
|
|
551
|
+
if isinstance(user, dict):
|
|
552
|
+
for key in ("id", "user_id", "account_id", "sub"):
|
|
553
|
+
if user.get(key) not in (None, ""):
|
|
554
|
+
account_id = str(user[key])
|
|
555
|
+
break
|
|
556
|
+
auth_state = "missing"
|
|
557
|
+
try:
|
|
558
|
+
auth_state = credential.auth_state() if credential is not None else "missing"
|
|
559
|
+
except Exception: # noqa: BLE001
|
|
560
|
+
auth_state = "unknown"
|
|
561
|
+
|
|
562
|
+
project_id = ""
|
|
563
|
+
binding_path = root / ".bugx" / "cloud-project.json"
|
|
564
|
+
try:
|
|
565
|
+
binding = json.loads(binding_path.read_text(encoding="utf-8"))
|
|
566
|
+
if isinstance(binding, dict):
|
|
567
|
+
project_id = str(binding.get("project_id") or "")
|
|
568
|
+
except (OSError, UnicodeError, json.JSONDecodeError):
|
|
569
|
+
pass
|
|
570
|
+
onboarding = "pending"
|
|
571
|
+
onboarding_path = root / ".bugx" / "cloud-onboard.json"
|
|
572
|
+
try:
|
|
573
|
+
onboarding_data = json.loads(onboarding_path.read_text(encoding="utf-8"))
|
|
574
|
+
if isinstance(onboarding_data, dict):
|
|
575
|
+
onboarding = str(onboarding_data.get("state") or "pending")
|
|
576
|
+
except (OSError, UnicodeError, json.JSONDecodeError):
|
|
577
|
+
pass
|
|
578
|
+
|
|
579
|
+
stores: dict[str, dict] = {}
|
|
580
|
+
errors: list[str] = []
|
|
581
|
+
for layer in scopes:
|
|
582
|
+
store_path = global_store_path() if layer == "global" else project_store_path(root)
|
|
583
|
+
layer_project_id = "" if layer == "global" else project_id
|
|
584
|
+
try:
|
|
585
|
+
stores[layer] = SyncStore.inspect_scope(
|
|
586
|
+
store_path, account_id, layer, layer_project_id,
|
|
587
|
+
)
|
|
588
|
+
except SyncStoreError as exc:
|
|
589
|
+
stores[layer] = {
|
|
590
|
+
"path": str(store_path), "scope": layer,
|
|
591
|
+
"project_id": layer_project_id, "state": "error", "error": str(exc),
|
|
592
|
+
}
|
|
593
|
+
errors.append(f"{layer}: {exc}")
|
|
594
|
+
|
|
595
|
+
payload = {
|
|
596
|
+
"authenticated": bool(credential and credential.is_authenticated()),
|
|
597
|
+
"auth_state": auth_state,
|
|
598
|
+
"auth_source": (
|
|
599
|
+
"api_key" if getattr(credential, "api_key", None) else
|
|
600
|
+
"local_cache" if getattr(credential, "token", None) else "none"
|
|
601
|
+
),
|
|
602
|
+
"auth_verified": None,
|
|
603
|
+
"auth_verification_status": "not_checked",
|
|
604
|
+
"has_account_id": bool(account_id),
|
|
605
|
+
"onboarding": onboarding,
|
|
606
|
+
"project_id": project_id or None,
|
|
607
|
+
"scopes": stores,
|
|
608
|
+
}
|
|
609
|
+
if getattr(args, "json", False):
|
|
610
|
+
print(json.dumps(payload, ensure_ascii=False, indent=2))
|
|
611
|
+
else:
|
|
612
|
+
auth_note = ""
|
|
613
|
+
if auth_state == "expired" and getattr(credential, "auth_state_override", None) == "expired":
|
|
614
|
+
auth_note = "(已记录服务端拒绝;需重新登录或使用 `bugx auth status --verify`)"
|
|
615
|
+
elif payload["auth_verification_status"] == "not_checked" \
|
|
616
|
+
and payload["auth_source"] in {"local_cache", "api_key"}:
|
|
617
|
+
auth_note = "(本地凭据,未联网核验;需 `bugx auth status --verify`)"
|
|
618
|
+
print(f"[cloud] 登录态: {auth_state}{auth_note};onboarding: {onboarding}")
|
|
619
|
+
print(f"[cloud] 项目绑定: {project_id or '未绑定'}")
|
|
620
|
+
for layer, item in stores.items():
|
|
621
|
+
state = item.get("scope_state") or {}
|
|
622
|
+
outbox = item.get("outbox") or {}
|
|
623
|
+
conflicts = item.get("conflicts") or {}
|
|
624
|
+
print(
|
|
625
|
+
f" {layer}: {item.get('state')},"
|
|
626
|
+
f"cursor={state.get('committed_cursor') or '未提交'},"
|
|
627
|
+
f"error={state.get('last_error_code') or '无'},"
|
|
628
|
+
f"pending={outbox.get('pending', 0)},"
|
|
629
|
+
f"inflight={outbox.get('inflight', 0)},"
|
|
630
|
+
f"dead_letter={outbox.get('dead_letter', 0)},"
|
|
631
|
+
f"conflicts_open={conflicts.get('open', 0)}"
|
|
632
|
+
)
|
|
633
|
+
if errors:
|
|
634
|
+
print("[cloud] 状态读取失败: " + "; ".join(errors))
|
|
635
|
+
return 1 if errors else 0
|
|
636
|
+
|
|
637
|
+
if act == "conflicts":
|
|
638
|
+
"""冲突队列治理:list/prune 与 resolve --side local 离线执行;
|
|
639
|
+
resolve --side remote 需要联网拉取远端权威内容后解决。"""
|
|
640
|
+
try:
|
|
641
|
+
from core.runtime.sync_store import (
|
|
642
|
+
SyncStore, SyncStoreError, global_store_path, project_store_path,
|
|
643
|
+
)
|
|
644
|
+
except Exception as exc: # noqa: BLE001
|
|
645
|
+
print(f"[cloud] 冲突队列依赖加载失败: {exc}")
|
|
646
|
+
return 2
|
|
647
|
+
conflict_action = getattr(args, "conflict_action", "list")
|
|
648
|
+
scope = getattr(args, "conflict_scope", "all")
|
|
649
|
+
layers = (("global", global_store_path()), ("project", project_store_path(root)))
|
|
650
|
+
if scope != "all":
|
|
651
|
+
layers = tuple(item for item in layers if item[0] == scope)
|
|
652
|
+
|
|
653
|
+
if conflict_action == "list":
|
|
654
|
+
conflicts: list[dict] = []
|
|
655
|
+
errors = []
|
|
656
|
+
for layer, store_path in layers:
|
|
657
|
+
if not store_path.exists():
|
|
658
|
+
continue
|
|
659
|
+
try:
|
|
660
|
+
store = SyncStore(store_path)
|
|
661
|
+
try:
|
|
662
|
+
conflicts.extend(store.list_conflicts())
|
|
663
|
+
finally:
|
|
664
|
+
store.close()
|
|
665
|
+
except SyncStoreError as exc:
|
|
666
|
+
errors.append(f"{layer}: {exc}")
|
|
667
|
+
if getattr(args, "json", False):
|
|
668
|
+
print(json.dumps({"conflicts": conflicts, "count": len(conflicts)},
|
|
669
|
+
ensure_ascii=False, indent=2))
|
|
670
|
+
elif not conflicts:
|
|
671
|
+
print("[cloud] 没有待治理的同步冲突")
|
|
672
|
+
else:
|
|
673
|
+
print(f"[cloud] 同步冲突队列: {len(conflicts)} 条待治理")
|
|
674
|
+
for item in conflicts:
|
|
675
|
+
print(
|
|
676
|
+
f" [{item.get('scope')}] {item.get('conflict_id')} "
|
|
677
|
+
f"{item.get('record_type')}/{item.get('record_id')} "
|
|
678
|
+
f"local_v={item.get('local_version')} "
|
|
679
|
+
f"remote_v={item.get('remote_version')} "
|
|
680
|
+
f"reason={item.get('reason') or 'unknown'} "
|
|
681
|
+
f"created={item.get('created_at')}"
|
|
682
|
+
)
|
|
683
|
+
if errors:
|
|
684
|
+
print("[cloud] 冲突队列读取失败: " + "; ".join(errors))
|
|
685
|
+
return 1 if errors else 0
|
|
686
|
+
|
|
687
|
+
if conflict_action == "prune":
|
|
688
|
+
account_id = ""
|
|
689
|
+
credential = getattr(client, "cred", None)
|
|
690
|
+
user = getattr(credential, "user", None)
|
|
691
|
+
if isinstance(user, dict):
|
|
692
|
+
for key in ("id", "user_id", "account_id", "sub"):
|
|
693
|
+
if user.get(key) not in (None, ""):
|
|
694
|
+
account_id = str(user[key])
|
|
695
|
+
break
|
|
696
|
+
project_id = ""
|
|
697
|
+
binding_path = root / ".bugx" / "cloud-project.json"
|
|
698
|
+
try:
|
|
699
|
+
binding = json.loads(binding_path.read_text(encoding="utf-8"))
|
|
700
|
+
if isinstance(binding, dict):
|
|
701
|
+
project_id = str(binding.get("project_id") or "")
|
|
702
|
+
except Exception:
|
|
703
|
+
pass
|
|
704
|
+
total_pruned = 0
|
|
705
|
+
errors = []
|
|
706
|
+
for layer, store_path in layers:
|
|
707
|
+
if not store_path.exists():
|
|
708
|
+
continue
|
|
709
|
+
try:
|
|
710
|
+
store = SyncStore(store_path)
|
|
711
|
+
try:
|
|
712
|
+
layer_pid = project_id if layer == "project" else ""
|
|
713
|
+
total_pruned += store.prune_converged_conflicts(
|
|
714
|
+
account_id, layer, layer_pid, resolver_identity="cli-conflicts-prune"
|
|
715
|
+
)
|
|
716
|
+
finally:
|
|
717
|
+
store.close()
|
|
718
|
+
except SyncStoreError as exc:
|
|
719
|
+
errors.append(f"{layer}: {exc}")
|
|
720
|
+
if errors:
|
|
721
|
+
print("[cloud] 冲突修剪失败: " + "; ".join(errors))
|
|
722
|
+
return 1
|
|
723
|
+
print(f"[cloud] 冲突队列修剪完成:已自动关闭 {total_pruned} 条已收敛/无分歧冲突")
|
|
724
|
+
return 0
|
|
725
|
+
|
|
726
|
+
# resolve(G3' 实效化):
|
|
727
|
+
# local = 保留本地——清除该记录的远端版本元数据(本地权威但**不发明
|
|
728
|
+
# 版本**),下一轮正常 push 以变更内容走服务器分配新版本;
|
|
729
|
+
# remote = 接受远端版本——先联网拉取权威内容经既有导入事务写账本并
|
|
730
|
+
# upsert_record_states 对齐 remote_version/remote_hash,再落
|
|
731
|
+
# 解决记账;拉取失败则不解决(fail-closed,冲突保持 open)。
|
|
732
|
+
# resolve 是显式人工命令,没有任何自动触发路径。
|
|
733
|
+
side = getattr(args, "conflict_side", None) or ""
|
|
734
|
+
if side not in {"local", "remote"}:
|
|
735
|
+
print("[cloud] 用法: bugx cloud conflicts resolve <conflict_id>|--all "
|
|
736
|
+
"--side local|remote [--reason-filter <reason>]")
|
|
737
|
+
return 2
|
|
738
|
+
resolution = "resolved_local" if side == "local" else "resolved_remote"
|
|
739
|
+
|
|
740
|
+
def _pull_authoritative(layer: str, project_id: str, account_id: str) -> dict:
|
|
741
|
+
# --side remote 专用:一次翻页 pull(页数受 client.max_pull_pages
|
|
742
|
+
# 约束)拉取权威内容,经 _pull_layer 既有导入事务写账本,并由
|
|
743
|
+
# inbox 提交回写 record_state。
|
|
744
|
+
from core.cloud_sync.cloud_onboard import get_account_id, get_imports
|
|
745
|
+
from core.cloud_sync.sync_pull import pull_layer
|
|
746
|
+
ns = get_imports()
|
|
747
|
+
return pull_layer(client, ns, root, layer, project_id,
|
|
748
|
+
account_id or get_account_id(client),
|
|
749
|
+
resolve_converged_conflicts=True)
|
|
750
|
+
|
|
751
|
+
def _pull_detail(pull: Any) -> str:
|
|
752
|
+
if isinstance(pull, dict):
|
|
753
|
+
return str(pull.get("error") or "unknown")
|
|
754
|
+
return "unknown"
|
|
755
|
+
|
|
756
|
+
if getattr(args, "conflict_all", False):
|
|
757
|
+
# 批量形态:遍历冲突队列逐条按选边解决;单条失败不中断,
|
|
758
|
+
# 收集后汇总 resolved/failed 计数(R6 曾需手工循环 56 次)。
|
|
759
|
+
if getattr(args, "conflict_id", None):
|
|
760
|
+
print("[cloud] --all 与 conflict_id 互斥,不能同时使用")
|
|
761
|
+
return 2
|
|
762
|
+
reason_filter = str(getattr(args, "conflict_reason_filter", "") or "")
|
|
763
|
+
# G3' 限速保护:--side remote 批量解决总数上限 200;网络侧每层
|
|
764
|
+
# 至多一次翻页 pull 会话(优于逐条 pull 的请求放大)。
|
|
765
|
+
remote_budget = 200
|
|
766
|
+
resolved_count = 0
|
|
767
|
+
failed_count = 0
|
|
768
|
+
over_limit = 0
|
|
769
|
+
failures: list[str] = []
|
|
770
|
+
pulled_layers: list[str] = []
|
|
771
|
+
errors = []
|
|
772
|
+
for layer, store_path in layers:
|
|
773
|
+
if not store_path.exists():
|
|
774
|
+
continue
|
|
775
|
+
try:
|
|
776
|
+
store = SyncStore(store_path)
|
|
777
|
+
except SyncStoreError as exc:
|
|
778
|
+
errors.append(f"{layer}: {exc}")
|
|
779
|
+
continue
|
|
780
|
+
try:
|
|
781
|
+
if side == "remote":
|
|
782
|
+
pending_rows = [
|
|
783
|
+
item for item in store.list_conflicts()
|
|
784
|
+
if not reason_filter
|
|
785
|
+
or (item.get("reason") or "") == reason_filter
|
|
786
|
+
]
|
|
787
|
+
if not pending_rows:
|
|
788
|
+
continue
|
|
789
|
+
if remote_budget <= 0:
|
|
790
|
+
over_limit += len(pending_rows)
|
|
791
|
+
continue
|
|
792
|
+
first = pending_rows[0]
|
|
793
|
+
try:
|
|
794
|
+
pull = _pull_authoritative(
|
|
795
|
+
layer, str(first.get("project_id") or ""),
|
|
796
|
+
str(first.get("account_id") or ""))
|
|
797
|
+
except Exception as exc: # noqa: BLE001
|
|
798
|
+
failed_count += len(pending_rows)
|
|
799
|
+
failures.append(
|
|
800
|
+
f"{layer}: 权威内容拉取失败 "
|
|
801
|
+
f"{type(exc).__name__}: {exc}")
|
|
802
|
+
continue
|
|
803
|
+
if not isinstance(pull, dict) or not pull.get("ok"):
|
|
804
|
+
failed_count += len(pending_rows)
|
|
805
|
+
failures.append(
|
|
806
|
+
f"{layer}: 权威内容拉取失败 {_pull_detail(pull)}")
|
|
807
|
+
continue
|
|
808
|
+
pulled_layers.append(layer)
|
|
809
|
+
for item in store.list_conflicts():
|
|
810
|
+
if reason_filter and (item.get("reason") or "") != reason_filter:
|
|
811
|
+
continue
|
|
812
|
+
if side == "remote":
|
|
813
|
+
if remote_budget <= 0:
|
|
814
|
+
over_limit += 1
|
|
815
|
+
continue
|
|
816
|
+
remote_budget -= 1
|
|
817
|
+
try:
|
|
818
|
+
store.resolve_conflict(
|
|
819
|
+
str(item["conflict_id"]), resolution,
|
|
820
|
+
resolver_identity="bugx-cli")
|
|
821
|
+
resolved_count += 1
|
|
822
|
+
except SyncStoreError as exc:
|
|
823
|
+
current = store.get_conflict(str(item["conflict_id"]))
|
|
824
|
+
if current and current.get("state") != "open":
|
|
825
|
+
# pull 的冲突感知导入已把该记录幂等收敛
|
|
826
|
+
resolved_count += 1
|
|
827
|
+
continue
|
|
828
|
+
failed_count += 1
|
|
829
|
+
failures.append(f"{layer}/{item.get('conflict_id')}: {exc}")
|
|
830
|
+
finally:
|
|
831
|
+
store.close()
|
|
832
|
+
note = ("保留本地,丢弃远端记录(该记录远端版本元数据已清除)"
|
|
833
|
+
if side == "local" else "接受远端版本(已拉取权威内容入账本)")
|
|
834
|
+
if errors:
|
|
835
|
+
print("[cloud] 冲突队列读取失败: " + "; ".join(errors))
|
|
836
|
+
if getattr(args, "json", False):
|
|
837
|
+
payload = {
|
|
838
|
+
"all": True, "side": side, "resolution": resolution,
|
|
839
|
+
"reason_filter": reason_filter or None,
|
|
840
|
+
"resolved": resolved_count, "failed": failed_count,
|
|
841
|
+
"failures": failures,
|
|
842
|
+
"pulled": pulled_layers,
|
|
843
|
+
}
|
|
844
|
+
if over_limit:
|
|
845
|
+
payload["over_limit"] = over_limit
|
|
846
|
+
print(json.dumps(payload, ensure_ascii=False))
|
|
847
|
+
else:
|
|
848
|
+
filter_note = f",reason={reason_filter}" if reason_filter else ""
|
|
849
|
+
limit_note = f",超出上限未处理 {over_limit} 条" if over_limit else ""
|
|
850
|
+
print(f"[cloud] 批量解决完成(side={side},{note}{filter_note}): "
|
|
851
|
+
f"resolved={resolved_count} failed={failed_count}{limit_note}")
|
|
852
|
+
for failure in failures:
|
|
853
|
+
print(f" [failed] {failure}")
|
|
854
|
+
return 1 if (errors or failed_count) else 0
|
|
855
|
+
conflict_id = getattr(args, "conflict_id", None) or ""
|
|
856
|
+
if not conflict_id:
|
|
857
|
+
print("[cloud] 用法: bugx cloud conflicts resolve <conflict_id>|--all "
|
|
858
|
+
"--side local|remote [--reason-filter <reason>]")
|
|
859
|
+
return 2
|
|
860
|
+
resolved_scopes: list[str] = []
|
|
861
|
+
resolve_failures: list[str] = []
|
|
862
|
+
errors = []
|
|
863
|
+
for layer, store_path in layers:
|
|
864
|
+
if not store_path.exists():
|
|
865
|
+
continue
|
|
866
|
+
try:
|
|
867
|
+
store = SyncStore(store_path)
|
|
868
|
+
except SyncStoreError as exc:
|
|
869
|
+
errors.append(f"{layer}: {exc}")
|
|
870
|
+
continue
|
|
871
|
+
try:
|
|
872
|
+
row = store.get_conflict(conflict_id)
|
|
873
|
+
if not row or row.get("state") != "open":
|
|
874
|
+
# 该层没有这条 open 冲突;conflict_id 是跨层唯一的确定性哈希。
|
|
875
|
+
continue
|
|
876
|
+
if side == "remote":
|
|
877
|
+
try:
|
|
878
|
+
pull = _pull_authoritative(
|
|
879
|
+
layer, str(row.get("project_id") or ""),
|
|
880
|
+
str(row.get("account_id") or ""))
|
|
881
|
+
except Exception as exc: # noqa: BLE001
|
|
882
|
+
resolve_failures.append(
|
|
883
|
+
f"{layer}: 权威内容拉取失败 {type(exc).__name__}: {exc}")
|
|
884
|
+
continue
|
|
885
|
+
if not isinstance(pull, dict) or not pull.get("ok"):
|
|
886
|
+
resolve_failures.append(
|
|
887
|
+
f"{layer}: 权威内容拉取失败 {_pull_detail(pull)}")
|
|
888
|
+
continue
|
|
889
|
+
try:
|
|
890
|
+
store.resolve_conflict(conflict_id, resolution,
|
|
891
|
+
resolver_identity="bugx-cli")
|
|
892
|
+
except SyncStoreError:
|
|
893
|
+
current = store.get_conflict(conflict_id)
|
|
894
|
+
if not (side == "remote" and current
|
|
895
|
+
and current.get("state") == "resolved_remote"):
|
|
896
|
+
raise # 既未显式解决、pull 也未收敛:按失败处理
|
|
897
|
+
resolved_scopes.append(layer)
|
|
898
|
+
except SyncStoreError as exc:
|
|
899
|
+
resolve_failures.append(f"{layer}: {exc}")
|
|
900
|
+
finally:
|
|
901
|
+
store.close()
|
|
902
|
+
if errors:
|
|
903
|
+
print("[cloud] 冲突队列读取失败: " + "; ".join(errors))
|
|
904
|
+
return 1
|
|
905
|
+
if resolve_failures:
|
|
906
|
+
for failure in resolve_failures:
|
|
907
|
+
print(f"[cloud] {failure}")
|
|
908
|
+
print(f"[cloud] 冲突 {conflict_id} 未能解决:远端权威内容未落地,"
|
|
909
|
+
"冲突保持 open(fail-closed)")
|
|
910
|
+
return 1
|
|
911
|
+
if not resolved_scopes:
|
|
912
|
+
print(f"[cloud] 冲突 {conflict_id} 不存在或已解决")
|
|
913
|
+
return 1
|
|
914
|
+
note = ("保留本地,丢弃远端记录(该记录远端版本元数据已清除,"
|
|
915
|
+
"下一轮 push 由服务器分配新版本)"
|
|
916
|
+
if side == "local" else
|
|
917
|
+
"接受远端版本(已拉取权威内容入账本并回写记录版本元数据)")
|
|
918
|
+
if getattr(args, "json", False):
|
|
919
|
+
print(json.dumps({
|
|
920
|
+
"conflict_id": conflict_id, "resolution": resolution,
|
|
921
|
+
"side": side, "scopes": resolved_scopes,
|
|
922
|
+
}, ensure_ascii=False))
|
|
923
|
+
else:
|
|
924
|
+
print(f"[cloud] 冲突 {conflict_id} 已解决(side={side},{note})"
|
|
925
|
+
f": scopes={','.join(resolved_scopes)}")
|
|
926
|
+
return 0
|
|
927
|
+
|
|
928
|
+
if act == "dead-letter":
|
|
929
|
+
"""本地死信队列治理(不联网):list / purge。
|
|
930
|
+
|
|
931
|
+
purge 必须显式 ``--confirm`` 才删除;缺省只 dry-run 打印将删条数。
|
|
932
|
+
删除前先把将删行整体导出到 ``.bugx/cloud-sync/dead-letter-archive-<ts>.json``
|
|
933
|
+
留档(可追溯),归档失败的层不删除。
|
|
934
|
+
"""
|
|
935
|
+
try:
|
|
936
|
+
from core.runtime.sync_store import (
|
|
937
|
+
SyncStore, SyncStoreError, global_store_path, project_store_path,
|
|
938
|
+
)
|
|
939
|
+
except Exception as exc: # noqa: BLE001
|
|
940
|
+
print(f"[cloud] 死信队列依赖加载失败: {exc}")
|
|
941
|
+
return 2
|
|
942
|
+
dead_action = getattr(args, "dead_letter_action", "list")
|
|
943
|
+
dead_scope = getattr(args, "dead_letter_scope", "all")
|
|
944
|
+
layers = (("global", global_store_path()), ("project", project_store_path(root)))
|
|
945
|
+
if dead_scope != "all":
|
|
946
|
+
layers = tuple(item for item in layers if item[0] == dead_scope)
|
|
947
|
+
try:
|
|
948
|
+
older_than_days = int(getattr(args, "dead_letter_older_than_days", 0) or 0)
|
|
949
|
+
except (TypeError, ValueError):
|
|
950
|
+
print("[cloud] --older-than-days 必须是非负整数")
|
|
951
|
+
return 2
|
|
952
|
+
if older_than_days < 0:
|
|
953
|
+
print("[cloud] --older-than-days 必须是非负整数")
|
|
954
|
+
return 2
|
|
955
|
+
|
|
956
|
+
scanned: list[tuple[str, Path, list[dict]]] = []
|
|
957
|
+
errors: list[str] = []
|
|
958
|
+
for layer, store_path in layers:
|
|
959
|
+
if not store_path.exists():
|
|
960
|
+
continue
|
|
961
|
+
try:
|
|
962
|
+
store = SyncStore(store_path)
|
|
963
|
+
try:
|
|
964
|
+
rows = store.list_dead_letters(older_than_days=older_than_days)
|
|
965
|
+
finally:
|
|
966
|
+
store.close()
|
|
967
|
+
scanned.append((layer, store_path, rows))
|
|
968
|
+
except SyncStoreError as exc:
|
|
969
|
+
errors.append(f"{layer}: {exc}")
|
|
970
|
+
total = sum(len(rows) for _layer, _path, rows in scanned)
|
|
971
|
+
|
|
972
|
+
def dead_letter_view(layer: str, row: dict) -> dict:
|
|
973
|
+
return {
|
|
974
|
+
"layer": layer,
|
|
975
|
+
"scope": row.get("scope"),
|
|
976
|
+
"operation_id": row.get("operation_id"),
|
|
977
|
+
"record_type": row.get("record_type"),
|
|
978
|
+
"record_id": row.get("record_id"),
|
|
979
|
+
"last_error_code": row.get("last_error_code"),
|
|
980
|
+
"created_at": row.get("created_at"),
|
|
981
|
+
"attempts": row.get("attempts"),
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
if dead_action == "list":
|
|
985
|
+
if getattr(args, "json", False):
|
|
986
|
+
payload = {
|
|
987
|
+
"dead_letters": [
|
|
988
|
+
dead_letter_view(layer, row)
|
|
989
|
+
for layer, _path, rows in scanned for row in rows
|
|
990
|
+
],
|
|
991
|
+
"count": total,
|
|
992
|
+
}
|
|
993
|
+
print(json.dumps(payload, ensure_ascii=False, indent=2))
|
|
994
|
+
elif total == 0:
|
|
995
|
+
print("[cloud] 没有滞留的同步死信")
|
|
996
|
+
else:
|
|
997
|
+
print(f"[cloud] 同步死信队列: {total} 条滞留")
|
|
998
|
+
for layer, _path, rows in scanned:
|
|
999
|
+
for row in rows:
|
|
1000
|
+
print(
|
|
1001
|
+
f" [{layer}/{row.get('scope')}] {row.get('operation_id')} "
|
|
1002
|
+
f"{row.get('record_type')}/{row.get('record_id')} "
|
|
1003
|
+
f"error={row.get('last_error_code') or 'unknown'} "
|
|
1004
|
+
f"created={row.get('created_at')} "
|
|
1005
|
+
f"attempts={row.get('attempts')}"
|
|
1006
|
+
)
|
|
1007
|
+
if errors:
|
|
1008
|
+
print("[cloud] 死信队列读取失败: " + "; ".join(errors))
|
|
1009
|
+
return 1 if errors else 0
|
|
1010
|
+
|
|
1011
|
+
# purge
|
|
1012
|
+
if not getattr(args, "dead_letter_confirm", False):
|
|
1013
|
+
# dry-run:只有显式 --confirm 才会真正删除。
|
|
1014
|
+
if getattr(args, "json", False):
|
|
1015
|
+
print(json.dumps({"dry_run": True, "would_purge": total},
|
|
1016
|
+
ensure_ascii=False))
|
|
1017
|
+
elif total:
|
|
1018
|
+
print(f"[cloud] dry-run:将清理 {total} 条死信(先归档后删除);"
|
|
1019
|
+
"追加 --confirm 执行")
|
|
1020
|
+
else:
|
|
1021
|
+
print("[cloud] 没有可清理的死信")
|
|
1022
|
+
if errors:
|
|
1023
|
+
print("[cloud] 死信队列读取失败: " + "; ".join(errors))
|
|
1024
|
+
return 1 if errors else 0
|
|
1025
|
+
|
|
1026
|
+
archive_stamp = time.strftime("%Y%m%dT%H%M%SZ", time.gmtime())
|
|
1027
|
+
purged_total = 0
|
|
1028
|
+
archives: list[str] = []
|
|
1029
|
+
for layer, store_path, rows in scanned:
|
|
1030
|
+
if not rows:
|
|
1031
|
+
continue
|
|
1032
|
+
archive_path = store_path.parent / f"dead-letter-archive-{archive_stamp}.json"
|
|
1033
|
+
if archive_path.exists():
|
|
1034
|
+
# 同秒二次清理:不覆盖前一次留档。
|
|
1035
|
+
archive_path = store_path.parent / (
|
|
1036
|
+
f"dead-letter-archive-{archive_stamp}-{uuid.uuid4().hex[:8]}.json")
|
|
1037
|
+
payload = {
|
|
1038
|
+
"schema_version": 1,
|
|
1039
|
+
"archived_at": archive_stamp,
|
|
1040
|
+
"layer": layer,
|
|
1041
|
+
"source_store": str(store_path),
|
|
1042
|
+
"dead_letters": rows,
|
|
1043
|
+
}
|
|
1044
|
+
try:
|
|
1045
|
+
# 原子留档(同 cloud.py 内 _save_data_sharing 的写法):
|
|
1046
|
+
# 归档失败的层绝不进入删除步骤。
|
|
1047
|
+
temporary = archive_path.with_name(archive_path.name + ".tmp")
|
|
1048
|
+
temporary.write_text(
|
|
1049
|
+
json.dumps(payload, ensure_ascii=False, indent=2),
|
|
1050
|
+
encoding="utf-8")
|
|
1051
|
+
os.replace(temporary, archive_path)
|
|
1052
|
+
os.chmod(archive_path, 0o600)
|
|
1053
|
+
except OSError as exc:
|
|
1054
|
+
errors.append(f"{layer}: 死信归档失败,已跳过删除: {exc}")
|
|
1055
|
+
continue
|
|
1056
|
+
try:
|
|
1057
|
+
store = SyncStore(store_path)
|
|
1058
|
+
try:
|
|
1059
|
+
purged_total += store.purge_dead_letters(
|
|
1060
|
+
[str(row["operation_id"]) for row in rows])
|
|
1061
|
+
finally:
|
|
1062
|
+
store.close()
|
|
1063
|
+
except SyncStoreError as exc:
|
|
1064
|
+
errors.append(f"{layer}: {exc}")
|
|
1065
|
+
continue
|
|
1066
|
+
archives.append(str(archive_path))
|
|
1067
|
+
if getattr(args, "json", False):
|
|
1068
|
+
print(json.dumps({
|
|
1069
|
+
"purged": purged_total, "archives": archives, "errors": errors,
|
|
1070
|
+
}, ensure_ascii=False))
|
|
1071
|
+
else:
|
|
1072
|
+
summary = f"[cloud] 死信清理完成:已清理 {purged_total} 条死信"
|
|
1073
|
+
if archives:
|
|
1074
|
+
summary += ";归档: " + ", ".join(archives)
|
|
1075
|
+
print(summary)
|
|
1076
|
+
if errors:
|
|
1077
|
+
print("[cloud] 死信清理部分失败: " + "; ".join(errors))
|
|
1078
|
+
return 1
|
|
1079
|
+
return 0
|
|
1080
|
+
|
|
1081
|
+
def pattern_list(ledger_path: Path) -> list:
|
|
1082
|
+
try:
|
|
1083
|
+
data = read_ledger(ledger_path)
|
|
1084
|
+
return list((data.get("lessons") or {}).values())
|
|
1085
|
+
except Exception: # noqa: BLE001
|
|
1086
|
+
return []
|
|
1087
|
+
|
|
1088
|
+
def incident_list(ledger_path: Path) -> list:
|
|
1089
|
+
try:
|
|
1090
|
+
return list_incidents(ledger_path)
|
|
1091
|
+
except Exception: # noqa: BLE001
|
|
1092
|
+
return []
|
|
1093
|
+
|
|
1094
|
+
def layer_ledger(layer: str) -> Path:
|
|
1095
|
+
if layer == "global":
|
|
1096
|
+
return global_knowledge_root() / "lesson-ledger.json"
|
|
1097
|
+
return project_knowledge_root(root) / "lesson-ledger.json"
|
|
1098
|
+
|
|
1099
|
+
if act == "auth":
|
|
1100
|
+
auth_action = getattr(args, "auth_action", "")
|
|
1101
|
+
if auth_action == "login":
|
|
1102
|
+
sharing = confirm_data_sharing(args)
|
|
1103
|
+
if not sharing:
|
|
1104
|
+
print("[cloud] 未同意数据反哺;本地保持离线隐私模式")
|
|
1105
|
+
try:
|
|
1106
|
+
_cloud_login_and_register(client, get_device_id)
|
|
1107
|
+
except RuntimeError as exc:
|
|
1108
|
+
print(f"[cloud] 登录失败: {exc}")
|
|
1109
|
+
return 1
|
|
1110
|
+
print("[cloud] 登录成功,凭据已保存")
|
|
1111
|
+
try:
|
|
1112
|
+
from core.cloud_sync.cloud_onboard import get_state, set_state
|
|
1113
|
+
if get_state(root) in {"dismissed", "local"}:
|
|
1114
|
+
set_state(root, "pending")
|
|
1115
|
+
print("[cloud] 已重新开启本项目 onboarding;下次 Agent 启动会询问同步")
|
|
1116
|
+
except Exception as exc: # noqa: BLE001
|
|
1117
|
+
print(f"[cloud] onboarding 状态未更新: {exc}")
|
|
1118
|
+
return 0
|
|
1119
|
+
if auth_action == "set-key":
|
|
1120
|
+
if not args.api_key:
|
|
1121
|
+
raise CliError(_i18n_exc("cloud.auth_set_key_api_key_required", "auth set-key 必须提供 --api-key"))
|
|
1122
|
+
client.set_api_key(args.api_key)
|
|
1123
|
+
print("[cloud] api-key 已保存")
|
|
1124
|
+
return 0
|
|
1125
|
+
if auth_action == "logout":
|
|
1126
|
+
client.logout()
|
|
1127
|
+
print("[cloud] 已退出云端登录;设备身份和本地同步状态未删除")
|
|
1128
|
+
return 0
|
|
1129
|
+
if auth_action == "status":
|
|
1130
|
+
credential = client.cred
|
|
1131
|
+
user = credential.user if isinstance(credential.user, dict) else {}
|
|
1132
|
+
user_id = next(
|
|
1133
|
+
(str(user[key]) for key in ("id", "user_id", "account_id", "sub")
|
|
1134
|
+
if user.get(key) not in (None, "")),
|
|
1135
|
+
"",
|
|
1136
|
+
)
|
|
1137
|
+
payload = {
|
|
1138
|
+
"authenticated": credential.is_authenticated(),
|
|
1139
|
+
"auth_state": credential.auth_state(),
|
|
1140
|
+
"auth_source": (
|
|
1141
|
+
"api_key" if credential.api_key else
|
|
1142
|
+
"local_cache" if credential.token else "none"
|
|
1143
|
+
),
|
|
1144
|
+
"has_api_key": bool(credential.api_key),
|
|
1145
|
+
"has_refresh_token": bool(credential.refresh_token),
|
|
1146
|
+
"user_id": user_id or None,
|
|
1147
|
+
"auth_verified": None,
|
|
1148
|
+
"auth_verification_status": "not_checked",
|
|
1149
|
+
}
|
|
1150
|
+
if getattr(args, "verify_auth", False):
|
|
1151
|
+
verified = client.verify_auth()
|
|
1152
|
+
verification_error = getattr(verified, "error", None)
|
|
1153
|
+
verification_data = getattr(verified, "data", None)
|
|
1154
|
+
if not verification_error and isinstance(verification_data, dict):
|
|
1155
|
+
verification_error = verification_data.get("message") or verification_data.get("error")
|
|
1156
|
+
verification_http_status = getattr(verified, "status", None)
|
|
1157
|
+
payload["auth_verified"] = bool(verified.ok)
|
|
1158
|
+
local_network_blocked = (
|
|
1159
|
+
not verified.ok
|
|
1160
|
+
and _is_local_network_privacy_failure(
|
|
1161
|
+
verified,
|
|
1162
|
+
getattr(client, "base", "") or getattr(client, "base_url", ""),
|
|
1163
|
+
)
|
|
1164
|
+
)
|
|
1165
|
+
payload["auth_verification_status"] = (
|
|
1166
|
+
"valid" if verified.ok else
|
|
1167
|
+
"expired" if verification_http_status == 401 else
|
|
1168
|
+
"local_network_blocked" if local_network_blocked else
|
|
1169
|
+
"tls_untrusted" if _is_tls_failure(verification_error) else
|
|
1170
|
+
"unavailable"
|
|
1171
|
+
)
|
|
1172
|
+
payload["auth_verification_error"] = verification_error
|
|
1173
|
+
payload["auth_verification_http_status"] = verification_http_status
|
|
1174
|
+
payload["auth_state"] = credential.auth_state()
|
|
1175
|
+
if getattr(args, "json", False):
|
|
1176
|
+
print(json.dumps(payload, ensure_ascii=False, indent=2))
|
|
1177
|
+
else:
|
|
1178
|
+
state_note = ""
|
|
1179
|
+
if payload["auth_verification_status"] == "not_checked" \
|
|
1180
|
+
and payload["auth_source"] == "local_cache":
|
|
1181
|
+
state_note = "(本地缓存,未联网验证)"
|
|
1182
|
+
elif payload["auth_verification_status"] == "local_network_blocked":
|
|
1183
|
+
reason = payload.get("auth_verification_error") or "局域网目标不可达"
|
|
1184
|
+
state_note = f"(服务端验证: local_network_blocked,原因: {reason})"
|
|
1185
|
+
elif payload["auth_verification_status"] != "not_checked":
|
|
1186
|
+
state_note = f"(服务端验证: {payload['auth_verification_status']})"
|
|
1187
|
+
if payload.get("auth_verification_error") \
|
|
1188
|
+
and payload["auth_verification_status"] != "local_network_blocked":
|
|
1189
|
+
state_note += f",原因: {payload['auth_verification_error']}"
|
|
1190
|
+
print(f"[cloud] 登录态: {payload['auth_state']}{state_note}")
|
|
1191
|
+
print(f"[cloud] API Key: {'已配置' if payload['has_api_key'] else '未配置'}")
|
|
1192
|
+
print(f"[cloud] Refresh Token: {'已配置' if payload['has_refresh_token'] else '未配置'}")
|
|
1193
|
+
print(f"[cloud] 账号: {payload['user_id'] or '未识别'}")
|
|
1194
|
+
return 0
|
|
1195
|
+
return 2
|
|
1196
|
+
|
|
1197
|
+
if act == "sync":
|
|
1198
|
+
# DOC-211:--scope 缺省时读用户级 sync_scope_default(默认 all);
|
|
1199
|
+
# onboard-on(:1216)刻意传显式 "all",不受配置收窄。
|
|
1200
|
+
try:
|
|
1201
|
+
from core.cloud_sync.cloud_client import load_cloud_config
|
|
1202
|
+
sync_default_scope = load_cloud_config().get("sync_scope_default") or "all"
|
|
1203
|
+
except Exception: # noqa: BLE001
|
|
1204
|
+
sync_default_scope = "all"
|
|
1205
|
+
if getattr(args, "sync_scope", None) is None and sync_default_scope != "all":
|
|
1206
|
+
print(f"[cloud] sync_scope_default={sync_default_scope}(配置生效;显式 --scope 可覆盖)")
|
|
1207
|
+
return _cloud_sync_command(args, client, root, get_device_id,
|
|
1208
|
+
default_scope=sync_default_scope)
|
|
1209
|
+
|
|
1210
|
+
if act == "projects":
|
|
1211
|
+
sub = getattr(args, "cloud_project_action", "list")
|
|
1212
|
+
if sub == "list":
|
|
1213
|
+
r = client.list_projects()
|
|
1214
|
+
data = client._data(r)
|
|
1215
|
+
print("[cloud] 已登记项目:", json.dumps(data, ensure_ascii=False) if data else "(无)")
|
|
1216
|
+
return 0 if r.ok else 1
|
|
1217
|
+
if sub == "add":
|
|
1218
|
+
try:
|
|
1219
|
+
# 显式登记命令保持“缺省创建新身份”的能力(用户意图明确),
|
|
1220
|
+
# 但同样要暴露“身份文件未提交”的跨设备风险(DOC-031 P0)。
|
|
1221
|
+
import importlib
|
|
1222
|
+
cloud_onboard = importlib.import_module("core.cloud_sync.cloud_onboard")
|
|
1223
|
+
_save_project_binding = getattr(cloud_onboard, "_save_project_binding", None) or getattr(cloud_onboard, "save_project_binding")
|
|
1224
|
+
onboard_wizard = importlib.import_module("core.cloud_sync.onboard_wizard")
|
|
1225
|
+
ensure_project_identity = getattr(onboard_wizard, "ensure_project_identity", None) or getattr(onboard_wizard, "_ensure_project_identity")
|
|
1226
|
+
warn_uncommitted_identity = getattr(onboard_wizard, "warn_uncommitted_identity", None) or getattr(onboard_wizard, "_warn_uncommitted_identity")
|
|
1227
|
+
identity = ensure_project_identity(root, args.project_slug)
|
|
1228
|
+
warn_uncommitted_identity(root)
|
|
1229
|
+
except Exception as exc: # noqa: BLE001
|
|
1230
|
+
print(f"[cloud] 项目身份准备失败: {exc}")
|
|
1231
|
+
return 1
|
|
1232
|
+
r = client.register_project(
|
|
1233
|
+
slug=identity["slug"], name=identity["slug"],
|
|
1234
|
+
project_key=identity["project_key"],
|
|
1235
|
+
)
|
|
1236
|
+
print(f"[cloud] 登记项目: status={r.status} {r.error or ''}")
|
|
1237
|
+
if r.ok:
|
|
1238
|
+
pid = client.project_id(r)
|
|
1239
|
+
remote_key = client.project_key(r)
|
|
1240
|
+
if not pid:
|
|
1241
|
+
print("[cloud] 项目登记响应缺少 project_id,拒绝写入项目绑定")
|
|
1242
|
+
return 1
|
|
1243
|
+
if remote_key != identity["project_key"]:
|
|
1244
|
+
print("[cloud] 项目登记响应 project_key 不一致,拒绝写入项目绑定")
|
|
1245
|
+
return 1
|
|
1246
|
+
try:
|
|
1247
|
+
_save_project_binding(
|
|
1248
|
+
root, pid, identity["slug"], identity["project_key"],
|
|
1249
|
+
)
|
|
1250
|
+
print("[cloud] 已写入 .bugx-project.json(请提交到仓库,换机克隆即可对上同一云端项目)")
|
|
1251
|
+
except Exception as exc: # noqa: BLE001
|
|
1252
|
+
print(f"[cloud] 项目绑定/身份文件写入失败: {exc}")
|
|
1253
|
+
return 1
|
|
1254
|
+
return 0 if r.ok else 1
|
|
1255
|
+
return 2
|
|
1256
|
+
|
|
1257
|
+
if act == "devices":
|
|
1258
|
+
r = client.sync_status()
|
|
1259
|
+
data = client._data(r)
|
|
1260
|
+
print("[cloud] 设备同步状态:", json.dumps(data, ensure_ascii=False) if data else "(空)")
|
|
1261
|
+
return 0 if r.ok else 1
|
|
1262
|
+
|
|
1263
|
+
if act == "onboard":
|
|
1264
|
+
# 项目级 onboarding 状态;显式 ``on`` 是“开启并立即同步”,而不是
|
|
1265
|
+
# 只写一个 pending 标记再要求 Agent 解释下一步。
|
|
1266
|
+
try:
|
|
1267
|
+
from core.cloud_sync.cloud_onboard import get_state, set_state
|
|
1268
|
+
cur = get_state(root)
|
|
1269
|
+
except Exception as exc: # noqa: BLE001
|
|
1270
|
+
print(f"[cloud] onboarding 状态读取失败: {exc}")
|
|
1271
|
+
return 1
|
|
1272
|
+
onboard_action = getattr(args, "onboard_action", "status")
|
|
1273
|
+
if onboard_action == "status":
|
|
1274
|
+
print(f"[cloud] 本项目 onboarding: {cur}")
|
|
1275
|
+
return 0
|
|
1276
|
+
if onboard_action == "off":
|
|
1277
|
+
try:
|
|
1278
|
+
set_state(root, "local")
|
|
1279
|
+
except Exception as exc: # noqa: BLE001
|
|
1280
|
+
print(f"[cloud] onboarding 写失败: {exc}")
|
|
1281
|
+
return 1
|
|
1282
|
+
print("[cloud] onboarding 已设为 local(本地模式)")
|
|
1283
|
+
return 0
|
|
1284
|
+
# ``on`` 是显式用户动作:立即走完整登录/设备登记/全量同步链路。
|
|
1285
|
+
try:
|
|
1286
|
+
set_state(root, "pending")
|
|
1287
|
+
except Exception as exc: # noqa: BLE001
|
|
1288
|
+
print(f"[cloud] onboarding 写失败: {exc}")
|
|
1289
|
+
return 1
|
|
1290
|
+
print("[cloud] 已开启云端同步,立即同步 global + project…")
|
|
1291
|
+
sync_args = argparse.Namespace(
|
|
1292
|
+
project_slug=args.project_slug,
|
|
1293
|
+
sync_scope="all",
|
|
1294
|
+
detail_mode=None,
|
|
1295
|
+
)
|
|
1296
|
+
return _cloud_sync_command(sync_args, client, root, get_device_id)
|
|
1297
|
+
|
|
1298
|
+
return 2
|
|
1299
|
+
|
|
1300
|
+
|
|
1301
|
+
def _supervisor_deploy(root: Path) -> int:
|
|
1302
|
+
"""接入 canonical stdio MCP。"""
|
|
1303
|
+
try:
|
|
1304
|
+
status, backup = _ensure_opencode_config(root)
|
|
1305
|
+
except CliError as exc:
|
|
1306
|
+
print(f"[supervisor] OpenCode 配置未修改: {exc}")
|
|
1307
|
+
return 1
|
|
1308
|
+
suffix = f";备份={backup.relative_to(root)}" if backup else ""
|
|
1309
|
+
print(f"[supervisor] 已接入 canonical bugx-supervisor stdio MCP({status}{suffix})")
|
|
1310
|
+
return 0
|
|
1311
|
+
|
|
1312
|
+
|
|
1313
|
+
def _supervisor_status(root: Path) -> int:
|
|
1314
|
+
"""显示运行态和宿主配置状态。
|
|
1315
|
+
|
|
1316
|
+
先检查是否有活跃的 legacy 运行态(audit-supervisor.json),
|
|
1317
|
+
再检查 engine runtime 状态,最后才检查宿主 MCP 配置。
|
|
1318
|
+
避免在运行态正常但宿主配置缺失时误导操作者。
|
|
1319
|
+
"""
|
|
1320
|
+
print(" Supervisor 状态")
|
|
1321
|
+
print("-" * 40)
|
|
1322
|
+
|
|
1323
|
+
# 1. 检查 legacy 运行态
|
|
1324
|
+
legacy_state_path = root / ".bugx" / "audit-supervisor.json"
|
|
1325
|
+
if legacy_state_path.is_file():
|
|
1326
|
+
try:
|
|
1327
|
+
import json
|
|
1328
|
+
raw = json.loads(legacy_state_path.read_text(encoding="utf-8"))
|
|
1329
|
+
status_val = raw.get("status", "unknown")
|
|
1330
|
+
covered = len(raw.get("coverage", {}))
|
|
1331
|
+
covered_count = sum(
|
|
1332
|
+
1 for v in raw.get("coverage", {}).values()
|
|
1333
|
+
if isinstance(v, dict) and v.get("status") == "covered"
|
|
1334
|
+
) if isinstance(raw.get("coverage"), dict) else 0
|
|
1335
|
+
total_units = raw.get("total_units") or covered
|
|
1336
|
+
findings = len(raw.get("findings", []))
|
|
1337
|
+
print(f" 运行态: {status_val}")
|
|
1338
|
+
print(f" 覆盖: {covered_count}/{total_units} 单元")
|
|
1339
|
+
print(f" Findings: {findings}")
|
|
1340
|
+
if status_val in ("BUDGET_EXHAUSTED", "FAILED"):
|
|
1341
|
+
print(f" ⚠ 运行态处于 {status_val},需要处理")
|
|
1342
|
+
except (OSError, ValueError) as exc:
|
|
1343
|
+
print(f" 运行态文件存在但解析失败: {exc}")
|
|
1344
|
+
else:
|
|
1345
|
+
print(" 运行态: 未启动(无 audit-supervisor.json)")
|
|
1346
|
+
|
|
1347
|
+
# 2. 检查 engine runtime
|
|
1348
|
+
runtime_path = root / ".bugx" / "bugx-runtime.json"
|
|
1349
|
+
if runtime_path.is_file():
|
|
1350
|
+
try:
|
|
1351
|
+
import json
|
|
1352
|
+
rt = json.loads(runtime_path.read_text(encoding="utf-8"))
|
|
1353
|
+
lid = rt.get("lifecycle_id", "-")
|
|
1354
|
+
print(f" Lifecycle: {lid}")
|
|
1355
|
+
except (OSError, ValueError):
|
|
1356
|
+
pass
|
|
1357
|
+
|
|
1358
|
+
print("-" * 40)
|
|
1359
|
+
|
|
1360
|
+
# 3. 检查**当前宿主**的 MCP 配置
|
|
1361
|
+
# 缺陷 #12:这里原本无条件调用 OpenCode 的检查器并打印 ``OpenCode canonical
|
|
1362
|
+
# MCP 配置``,于是在 dsh / claude / codex 宿主上 status 永远报「✗ 缺少
|
|
1363
|
+
# opencode.json」,让用户去装一个根本没在用的宿主。宿主名必须来自环境探测,
|
|
1364
|
+
# 配置校验复用 ``_check_host_mcp_config`` 的逐宿主分派。
|
|
1365
|
+
host_name = _detected_host_name(root)
|
|
1366
|
+
config_ok, config_detail = _check_host_mcp_config(root, host_name)
|
|
1367
|
+
display = "未识别宿主" if host_name == "unknown" else host_name
|
|
1368
|
+
print(f" {'✓' if config_ok else '✗'} {display} 宿主 MCP 配置")
|
|
1369
|
+
if not config_ok:
|
|
1370
|
+
print(f" {config_detail}")
|
|
1371
|
+
return 0 if config_ok else 1
|