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,859 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""BugX 启动环境探测与交互通道选择。
|
|
3
|
+
|
|
4
|
+
启动脚本通常由宿主的 Bash/MCP 子进程执行,子进程本身没有 TTY,不能仅凭
|
|
5
|
+
``stdin.isatty()`` 判断是否可以向用户呈现选择。这里沿进程树识别宿主,区分
|
|
6
|
+
宿主 TUI、ACP/headless 和普通终端,并给启动门禁选择唯一的交互通道。
|
|
7
|
+
|
|
8
|
+
本模块只做只读探测,不执行宿主命令、不写配置、不改变运行态。宿主选择控件仍
|
|
9
|
+
由 Agent 调用;核心只返回可验证的能力契约和结构化门禁所需的环境信息。
|
|
10
|
+
|
|
11
|
+
进程树与 Git 环境在一次会话里不会改变,而 ``detect()`` 单次要同步执行 7 次
|
|
12
|
+
git 子进程与最多 8 层进程祖先 ``ps``(实测 65-108 ms)。因此这两个子探测按
|
|
13
|
+
"一个进程"缓存,见 :func:`clear_cache`。
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
from dataclasses import asdict, dataclass, field
|
|
19
|
+
import functools
|
|
20
|
+
import json
|
|
21
|
+
import os
|
|
22
|
+
from pathlib import Path
|
|
23
|
+
import re
|
|
24
|
+
import shlex
|
|
25
|
+
import shutil
|
|
26
|
+
import subprocess
|
|
27
|
+
import sys
|
|
28
|
+
from typing import Mapping, Sequence
|
|
29
|
+
|
|
30
|
+
try:
|
|
31
|
+
import core.i18n as i18n
|
|
32
|
+
except ImportError: # pragma: no cover - malformed legacy snapshot
|
|
33
|
+
i18n = None
|
|
34
|
+
|
|
35
|
+
try:
|
|
36
|
+
from core.host_runtime import host_registry
|
|
37
|
+
except ImportError: # pragma: no cover - 引擎快照残缺时 fail-closed
|
|
38
|
+
raise ImportError(
|
|
39
|
+
"引擎快照残缺:缺少 core/host_registry.py。宿主清单只能来自 host_registry/"
|
|
40
|
+
"core.hosts 插件,禁止用本地字面量降级;请重新运行 bugx install 修复引擎快照。"
|
|
41
|
+
) from None
|
|
42
|
+
|
|
43
|
+
# 宿主清单来自唯一真源 core/host_registry.py(其数据来源于 core/hosts 插件),
|
|
44
|
+
# 禁止在本模块再写字面量:三份互相漂移的清单曾导致 workbuddy/dsh/chatgpt 永远无法被识别。
|
|
45
|
+
HOSTS = host_registry.HOST_NAMES
|
|
46
|
+
NATIVE_QUESTION_HOSTS = host_registry.NATIVE_QUESTION_HOSTS
|
|
47
|
+
GIT_PROBE_TIMEOUT_SECONDS = 2.0
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _run_git(git: str, root: Path, *args: str) -> subprocess.CompletedProcess[str]:
|
|
51
|
+
"""Run a bounded, shell-free Git probe."""
|
|
52
|
+
return subprocess.run(
|
|
53
|
+
[git, "-C", str(root), *args],
|
|
54
|
+
capture_output=True,
|
|
55
|
+
text=True,
|
|
56
|
+
timeout=GIT_PROBE_TIMEOUT_SECONDS,
|
|
57
|
+
check=False,
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def detect_git(root: Path, *, environ: Mapping[str, str] | None = None) -> dict[str, object]:
|
|
62
|
+
"""Return a read-only Git readiness snapshot for the target project.
|
|
63
|
+
|
|
64
|
+
Git is a startup prerequisite because BugX needs a reproducible baseline,
|
|
65
|
+
rollback boundary and (when selected) a commit target. This probe never
|
|
66
|
+
initializes a repository or writes Git configuration; the host must act on
|
|
67
|
+
the resulting startup gate after an explicit user choice.
|
|
68
|
+
"""
|
|
69
|
+
root = root.expanduser().resolve()
|
|
70
|
+
env = dict(os.environ if environ is None else environ)
|
|
71
|
+
# When a caller supplies an explicit environment, an absent PATH must not
|
|
72
|
+
# silently inherit the host process PATH and produce a false-ready probe.
|
|
73
|
+
git = shutil.which("git", path=env.get("PATH", ""))
|
|
74
|
+
result: dict[str, object] = {
|
|
75
|
+
"status": "missing",
|
|
76
|
+
"ready": False,
|
|
77
|
+
"executable": git,
|
|
78
|
+
"version": None,
|
|
79
|
+
"root": str(root),
|
|
80
|
+
"repository_root": None,
|
|
81
|
+
"head": None,
|
|
82
|
+
"identity": {"name": False, "email": False},
|
|
83
|
+
"git_dir": None,
|
|
84
|
+
"git_dir_writable": False,
|
|
85
|
+
"baseline_readable": False,
|
|
86
|
+
"detail": "未找到 git 可执行文件",
|
|
87
|
+
}
|
|
88
|
+
if not git:
|
|
89
|
+
return result
|
|
90
|
+
|
|
91
|
+
try:
|
|
92
|
+
version_probe = subprocess.run(
|
|
93
|
+
[git, "--version"], capture_output=True, text=True,
|
|
94
|
+
timeout=GIT_PROBE_TIMEOUT_SECONDS, check=False,
|
|
95
|
+
)
|
|
96
|
+
except (OSError, subprocess.SubprocessError) as exc:
|
|
97
|
+
result["detail"] = f"git 无法执行: {exc}"
|
|
98
|
+
return result
|
|
99
|
+
result["version"] = version_probe.stdout.strip() or None
|
|
100
|
+
if version_probe.returncode != 0:
|
|
101
|
+
result["status"] = "unusable"
|
|
102
|
+
result["detail"] = (version_probe.stderr or "git --version 失败").strip()
|
|
103
|
+
return result
|
|
104
|
+
|
|
105
|
+
try:
|
|
106
|
+
repo_probe = _run_git(git, root, "rev-parse", "--show-toplevel")
|
|
107
|
+
except (OSError, subprocess.SubprocessError) as exc:
|
|
108
|
+
result["status"] = "unusable"
|
|
109
|
+
result["detail"] = f"Git 仓库探测失败: {exc}"
|
|
110
|
+
return result
|
|
111
|
+
if repo_probe.returncode != 0:
|
|
112
|
+
result["status"] = "not-repository"
|
|
113
|
+
result["detail"] = "当前项目根目录不是 Git 仓库"
|
|
114
|
+
return result
|
|
115
|
+
try:
|
|
116
|
+
repository_root = Path(repo_probe.stdout.strip()).expanduser().resolve()
|
|
117
|
+
except (OSError, ValueError):
|
|
118
|
+
repository_root = Path(repo_probe.stdout.strip()).expanduser()
|
|
119
|
+
result["repository_root"] = str(repository_root)
|
|
120
|
+
if repository_root != root:
|
|
121
|
+
result["status"] = "wrong-root"
|
|
122
|
+
result["detail"] = f"Git 仓库根目录与项目根目录不一致: {repository_root}"
|
|
123
|
+
return result
|
|
124
|
+
|
|
125
|
+
try:
|
|
126
|
+
head_probe = _run_git(git, root, "rev-parse", "--verify", "HEAD")
|
|
127
|
+
git_dir_probe = _run_git(git, root, "rev-parse", "--git-dir")
|
|
128
|
+
name_probe = _run_git(git, root, "config", "--get", "user.name")
|
|
129
|
+
email_probe = _run_git(git, root, "config", "--get", "user.email")
|
|
130
|
+
status_probe = _run_git(git, root, "status", "--porcelain=v1", "--untracked-files=no")
|
|
131
|
+
except (OSError, subprocess.SubprocessError) as exc:
|
|
132
|
+
result["status"] = "unusable"
|
|
133
|
+
result["detail"] = f"Git 基线探测失败: {exc}"
|
|
134
|
+
return result
|
|
135
|
+
|
|
136
|
+
head = head_probe.stdout.strip() if head_probe.returncode == 0 else ""
|
|
137
|
+
result["head"] = head or None
|
|
138
|
+
result["baseline_readable"] = bool(head) and status_probe.returncode == 0
|
|
139
|
+
identity = {
|
|
140
|
+
"name": name_probe.returncode == 0 and bool(name_probe.stdout.strip()),
|
|
141
|
+
"email": email_probe.returncode == 0 and bool(email_probe.stdout.strip()),
|
|
142
|
+
}
|
|
143
|
+
result["identity"] = identity
|
|
144
|
+
git_dir_text = git_dir_probe.stdout.strip()
|
|
145
|
+
if git_dir_text:
|
|
146
|
+
git_dir = Path(git_dir_text)
|
|
147
|
+
if not git_dir.is_absolute():
|
|
148
|
+
git_dir = root / git_dir
|
|
149
|
+
try:
|
|
150
|
+
git_dir = git_dir.resolve()
|
|
151
|
+
except OSError:
|
|
152
|
+
pass
|
|
153
|
+
result["git_dir"] = str(git_dir)
|
|
154
|
+
result["git_dir_writable"] = git_dir.is_dir() and os.access(git_dir, os.W_OK)
|
|
155
|
+
|
|
156
|
+
if not head:
|
|
157
|
+
result["status"] = "unborn"
|
|
158
|
+
result["detail"] = "Git 仓库没有可读取的 HEAD 基线"
|
|
159
|
+
elif not result["baseline_readable"]:
|
|
160
|
+
result["status"] = "baseline-unreadable"
|
|
161
|
+
result["detail"] = "Git HEAD 或工作树状态不可读取"
|
|
162
|
+
elif not identity["name"] or not identity["email"]:
|
|
163
|
+
result["status"] = "identity-missing"
|
|
164
|
+
result["detail"] = "Git 提交身份未完整配置(需要 user.name 和 user.email)"
|
|
165
|
+
elif not result["git_dir_writable"]:
|
|
166
|
+
result["status"] = "git-dir-readonly"
|
|
167
|
+
result["detail"] = "Git 元数据目录不可写"
|
|
168
|
+
else:
|
|
169
|
+
result["status"] = "ready"
|
|
170
|
+
result["ready"] = True
|
|
171
|
+
result["detail"] = "Git 仓库、HEAD 基线、提交身份和元数据写入能力均可用"
|
|
172
|
+
return result
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
@dataclass(frozen=True)
|
|
176
|
+
class StartupEnvironment:
|
|
177
|
+
"""启动时可审计的宿主与交互能力快照。"""
|
|
178
|
+
|
|
179
|
+
host: str
|
|
180
|
+
host_source: str
|
|
181
|
+
interface: str
|
|
182
|
+
interaction: str
|
|
183
|
+
stdin_tty: bool
|
|
184
|
+
stdout_tty: bool
|
|
185
|
+
term: str
|
|
186
|
+
command_line: tuple[str, ...]
|
|
187
|
+
native_question: bool
|
|
188
|
+
reason: str
|
|
189
|
+
requested_locale: str | None = None
|
|
190
|
+
resolved_locale: str = "en-US"
|
|
191
|
+
locale_source: str = "default"
|
|
192
|
+
locale_fallback_reason: str | None = None
|
|
193
|
+
git: dict[str, object] = field(default_factory=dict)
|
|
194
|
+
|
|
195
|
+
@property
|
|
196
|
+
def interactive(self) -> bool:
|
|
197
|
+
return self.interaction != "blocked"
|
|
198
|
+
|
|
199
|
+
def as_dict(self) -> dict[str, object]:
|
|
200
|
+
payload = asdict(self)
|
|
201
|
+
payload["command_line"] = list(self.command_line)
|
|
202
|
+
payload["interactive"] = self.interactive
|
|
203
|
+
return payload
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
def _command_for_pid(pid: int) -> str:
|
|
207
|
+
"""Read one process command line without invoking a shell."""
|
|
208
|
+
if sys.platform.startswith("linux"):
|
|
209
|
+
try:
|
|
210
|
+
return Path(f"/proc/{pid}/cmdline").read_bytes().replace(
|
|
211
|
+
b"\x00", b" ",
|
|
212
|
+
).decode("utf-8", "replace").strip()
|
|
213
|
+
except OSError:
|
|
214
|
+
return ""
|
|
215
|
+
try:
|
|
216
|
+
result = subprocess.run(
|
|
217
|
+
["ps", "-o", "command=", "-p", str(pid)],
|
|
218
|
+
capture_output=True, text=True, timeout=0.5, check=False,
|
|
219
|
+
)
|
|
220
|
+
except (OSError, subprocess.SubprocessError):
|
|
221
|
+
return ""
|
|
222
|
+
return result.stdout.strip()
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
# --- macOS 原生父链回退 ------------------------------------------------------
|
|
226
|
+
#
|
|
227
|
+
# 沙箱化宿主(WorkBuddy 桌面端等)会用 seatbelt 策略拒绝 ``ps``;此时
|
|
228
|
+
# ``_command_for_pid`` 与 ``ps -o ppid=`` 双双失败,``process_ancestry()`` 会
|
|
229
|
+
# **静默返回空链**,宿主身份随之退化为 ``unknown``,启动门禁在第一步以
|
|
230
|
+
# 「没有宿主原生选择能力」为由硬阻断——原因与真实原因(探测被拒)完全不符。
|
|
231
|
+
#
|
|
232
|
+
# macOS 提供三条不经过 ``ps`` 的等价原语,本模块只用它们做回退:
|
|
233
|
+
# ``libproc.proc_pidpath`` → 某个 pid 的可执行文件路径
|
|
234
|
+
# ``sysctl(KERN_PROC_PID)`` → ``kinfo_proc``,含父 pid
|
|
235
|
+
# ``sysctl(KERN_PROCARGS2)`` → 完整 argv(等价 ``ps -o command=``)
|
|
236
|
+
# 任一原语失败都返回空值,绝不用猜测填补,保持 fail-closed。
|
|
237
|
+
|
|
238
|
+
_DARWIN_CTL_KERN = 1
|
|
239
|
+
_DARWIN_KERN_PROC = 14
|
|
240
|
+
_DARWIN_KERN_PROC_PID = 1
|
|
241
|
+
_DARWIN_KERN_PROCARGS2 = 49
|
|
242
|
+
# ``struct kinfo_proc``(LP64)中 ``kp_proc.p_pid`` / ``kp_eproc.e_ppid`` 的偏移。
|
|
243
|
+
# 缓冲区必须不小于内核的 ``sizeof(kinfo_proc)``(当前 648 字节),否则 ``sysctl``
|
|
244
|
+
# 直接以 ENOMEM 失败、父 pid 永远读不到;取 1 KiB 留出结构体增长余量。
|
|
245
|
+
_DARWIN_KINFO_PID_OFFSET = 40
|
|
246
|
+
_DARWIN_KINFO_PPID_OFFSET = 560
|
|
247
|
+
_DARWIN_KINFO_BUFFER = 1024
|
|
248
|
+
_DARWIN_PIDPATH_BUFFER = 4096
|
|
249
|
+
_DARWIN_PROCARGS2_BUFFER = 1 << 18
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
def _darwin_sysctl(mib: Sequence[int], size: int) -> bytes:
|
|
253
|
+
"""Run one bounded ``sysctl`` read; empty bytes means the probe failed."""
|
|
254
|
+
try:
|
|
255
|
+
import ctypes
|
|
256
|
+
import ctypes.util
|
|
257
|
+
|
|
258
|
+
libc = ctypes.CDLL(ctypes.util.find_library("c") or "/usr/lib/libc.dylib")
|
|
259
|
+
buffer = ctypes.create_string_buffer(size)
|
|
260
|
+
length = ctypes.c_size_t(size)
|
|
261
|
+
array = (ctypes.c_int * len(mib))(*mib)
|
|
262
|
+
if libc.sysctl(array, len(mib), buffer, ctypes.byref(length), None, 0) != 0:
|
|
263
|
+
return b""
|
|
264
|
+
except (OSError, AttributeError, ValueError, TypeError):
|
|
265
|
+
return b""
|
|
266
|
+
return buffer.raw[: length.value]
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
def _darwin_proc_pidpath(pid: int) -> str:
|
|
270
|
+
"""Executable path of ``pid`` through libproc, without spawning ``ps``."""
|
|
271
|
+
try:
|
|
272
|
+
import ctypes
|
|
273
|
+
|
|
274
|
+
libproc = ctypes.CDLL("/usr/lib/libproc.dylib")
|
|
275
|
+
buffer = ctypes.create_string_buffer(_DARWIN_PIDPATH_BUFFER)
|
|
276
|
+
written = libproc.proc_pidpath(
|
|
277
|
+
ctypes.c_int(pid), buffer, ctypes.c_uint32(_DARWIN_PIDPATH_BUFFER),
|
|
278
|
+
)
|
|
279
|
+
except (OSError, AttributeError, ValueError, TypeError):
|
|
280
|
+
return ""
|
|
281
|
+
if written <= 0:
|
|
282
|
+
return ""
|
|
283
|
+
return buffer.value.decode("utf-8", "replace").strip()
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
def _darwin_parent_pid(pid: int) -> int:
|
|
287
|
+
"""Parent pid of ``pid`` from ``kinfo_proc``; ``0`` when unreadable.
|
|
288
|
+
|
|
289
|
+
The parsed ``kp_proc.p_pid`` must equal the requested pid; a mismatch means
|
|
290
|
+
the kernel struct layout is not what this module assumes, so the walk stops
|
|
291
|
+
instead of following a garbage parent.
|
|
292
|
+
"""
|
|
293
|
+
import struct
|
|
294
|
+
|
|
295
|
+
raw = _darwin_sysctl(
|
|
296
|
+
(_DARWIN_CTL_KERN, _DARWIN_KERN_PROC, _DARWIN_KERN_PROC_PID, pid),
|
|
297
|
+
_DARWIN_KINFO_BUFFER,
|
|
298
|
+
)
|
|
299
|
+
if len(raw) < _DARWIN_KINFO_PPID_OFFSET + 4:
|
|
300
|
+
return 0
|
|
301
|
+
if struct.unpack_from("<I", raw, _DARWIN_KINFO_PID_OFFSET)[0] != pid:
|
|
302
|
+
return 0
|
|
303
|
+
return struct.unpack_from("<I", raw, _DARWIN_KINFO_PPID_OFFSET)[0]
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
def _darwin_command_for_pid(pid: int) -> str:
|
|
307
|
+
"""Command line of ``pid`` from ``KERN_PROCARGS2``; path-only on failure."""
|
|
308
|
+
import struct
|
|
309
|
+
|
|
310
|
+
raw = _darwin_sysctl(
|
|
311
|
+
(_DARWIN_CTL_KERN, _DARWIN_KERN_PROCARGS2, pid), _DARWIN_PROCARGS2_BUFFER,
|
|
312
|
+
)
|
|
313
|
+
if len(raw) >= 8:
|
|
314
|
+
argc = struct.unpack_from("<i", raw, 0)[0]
|
|
315
|
+
body = raw[4:]
|
|
316
|
+
terminator = body.find(b"\x00")
|
|
317
|
+
# 布局:argc | exec_path\0 | NUL 填充 | argv[0..argc-1](各自 NUL 结尾)| env
|
|
318
|
+
if 0 < argc <= 4096 and terminator > 0:
|
|
319
|
+
remainder = body[terminator:].lstrip(b"\x00")
|
|
320
|
+
arguments: list[str] = []
|
|
321
|
+
for _ in range(argc):
|
|
322
|
+
if not remainder:
|
|
323
|
+
break
|
|
324
|
+
cut = remainder.find(b"\x00")
|
|
325
|
+
if cut < 0:
|
|
326
|
+
cut = len(remainder)
|
|
327
|
+
arguments.append(remainder[:cut].decode("utf-8", "replace"))
|
|
328
|
+
remainder = remainder[cut + 1:]
|
|
329
|
+
if arguments:
|
|
330
|
+
return " ".join(arguments).strip()
|
|
331
|
+
return _darwin_proc_pidpath(pid)
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
def _darwin_ancestry(max_depth: int) -> tuple[str, ...]:
|
|
335
|
+
"""``ps``-free macOS parent chain, nearest first."""
|
|
336
|
+
commands: list[str] = []
|
|
337
|
+
pid = os.getppid()
|
|
338
|
+
for _ in range(max_depth):
|
|
339
|
+
if pid <= 1:
|
|
340
|
+
break
|
|
341
|
+
command = _darwin_command_for_pid(pid)
|
|
342
|
+
if command:
|
|
343
|
+
commands.append(command)
|
|
344
|
+
next_pid = _darwin_parent_pid(pid)
|
|
345
|
+
if next_pid <= 0 or next_pid == pid:
|
|
346
|
+
break
|
|
347
|
+
pid = next_pid
|
|
348
|
+
return tuple(commands)
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
_WINDOWS_PROC_TABLE: dict[int, tuple[int, str]] | None = None
|
|
352
|
+
_WINDOWS_PROC_TABLE_LOADED = False
|
|
353
|
+
WINDOWS_PROC_TABLE_TIMEOUT_SECONDS = 10.0
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
def _windows_process_table() -> dict[int, tuple[int, str]]:
|
|
357
|
+
"""Snapshot pid → (ppid, command line) for the current process lifetime.
|
|
358
|
+
|
|
359
|
+
``Get-CimInstance Win32_Process`` is the supported Windows replacement for
|
|
360
|
+
``/proc`` and ``ps -o ppid=``; the snapshot is taken once because a host
|
|
361
|
+
identity derived from the ancestry chain cannot change mid-run.
|
|
362
|
+
"""
|
|
363
|
+
global _WINDOWS_PROC_TABLE, _WINDOWS_PROC_TABLE_LOADED
|
|
364
|
+
if _WINDOWS_PROC_TABLE_LOADED:
|
|
365
|
+
return _WINDOWS_PROC_TABLE or {}
|
|
366
|
+
_WINDOWS_PROC_TABLE_LOADED = True
|
|
367
|
+
script = (
|
|
368
|
+
"[Console]::OutputEncoding = [Text.Encoding]::UTF8; "
|
|
369
|
+
"Get-CimInstance Win32_Process | "
|
|
370
|
+
"Select-Object ProcessId, ParentProcessId, CommandLine | "
|
|
371
|
+
"ConvertTo-Json -Compress"
|
|
372
|
+
)
|
|
373
|
+
try:
|
|
374
|
+
result = subprocess.run(
|
|
375
|
+
["powershell", "-NoProfile", "-NonInteractive", "-Command", script],
|
|
376
|
+
capture_output=True, text=True, encoding="utf-8", errors="replace",
|
|
377
|
+
timeout=WINDOWS_PROC_TABLE_TIMEOUT_SECONDS, check=False,
|
|
378
|
+
)
|
|
379
|
+
data = json.loads(result.stdout)
|
|
380
|
+
except (OSError, subprocess.SubprocessError, ValueError):
|
|
381
|
+
_WINDOWS_PROC_TABLE = {}
|
|
382
|
+
return _WINDOWS_PROC_TABLE
|
|
383
|
+
if isinstance(data, dict):
|
|
384
|
+
data = [data]
|
|
385
|
+
table: dict[int, tuple[int, str]] = {}
|
|
386
|
+
for entry in data:
|
|
387
|
+
try:
|
|
388
|
+
pid_value = int(entry["ProcessId"])
|
|
389
|
+
ppid_value = int(entry["ParentProcessId"])
|
|
390
|
+
except (KeyError, TypeError, ValueError):
|
|
391
|
+
continue
|
|
392
|
+
table[pid_value] = (ppid_value, (entry.get("CommandLine") or "").strip())
|
|
393
|
+
_WINDOWS_PROC_TABLE = table
|
|
394
|
+
return table
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
_MSYS_PS_BY_WINPID: dict[int, tuple[int, str]] = {}
|
|
398
|
+
_MSYS_PS_BY_CYGPID: dict[int, tuple[int, int]] = {}
|
|
399
|
+
_MSYS_PS_LOADED = False
|
|
400
|
+
MSYS_PS_PROBE_TIMEOUT_SECONDS = 2.0
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
def _parse_msys_ps_output(
|
|
404
|
+
output: str,
|
|
405
|
+
) -> tuple[dict[int, tuple[int, str]], dict[int, tuple[int, int]]]:
|
|
406
|
+
"""Parse ``ps`` rows into winpid→(cygwin ppid, command) and cygpid→parent maps."""
|
|
407
|
+
by_winpid: dict[int, tuple[int, str]] = {}
|
|
408
|
+
by_cygpid: dict[int, tuple[int, int]] = {}
|
|
409
|
+
for line in output.splitlines()[1:]:
|
|
410
|
+
fields = line.split(None, 7)
|
|
411
|
+
if len(fields) < 7:
|
|
412
|
+
continue
|
|
413
|
+
try:
|
|
414
|
+
cygpid = int(fields[0])
|
|
415
|
+
cygppid = int(fields[1])
|
|
416
|
+
winpid = int(fields[3])
|
|
417
|
+
except ValueError:
|
|
418
|
+
continue
|
|
419
|
+
command = fields[7].strip() if len(fields) > 7 else ""
|
|
420
|
+
if winpid <= 0:
|
|
421
|
+
continue
|
|
422
|
+
by_winpid[winpid] = (cygppid, command)
|
|
423
|
+
by_cygpid[cygpid] = (cygppid, winpid)
|
|
424
|
+
return by_winpid, by_cygpid
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
def _msys_ps_tables() -> tuple[dict[int, tuple[int, str]], dict[int, tuple[int, int]]]:
|
|
428
|
+
"""Snapshot the MSYS ``ps`` table once; it keeps fork-accurate parent links."""
|
|
429
|
+
global _MSYS_PS_BY_WINPID, _MSYS_PS_BY_CYGPID, _MSYS_PS_LOADED
|
|
430
|
+
if _MSYS_PS_LOADED:
|
|
431
|
+
return _MSYS_PS_BY_WINPID, _MSYS_PS_BY_CYGPID
|
|
432
|
+
_MSYS_PS_LOADED = True
|
|
433
|
+
if sys.platform == "win32":
|
|
434
|
+
ps = shutil.which("ps")
|
|
435
|
+
if ps:
|
|
436
|
+
try:
|
|
437
|
+
result = subprocess.run(
|
|
438
|
+
[ps], capture_output=True, text=True, errors="replace",
|
|
439
|
+
timeout=MSYS_PS_PROBE_TIMEOUT_SECONDS, check=False,
|
|
440
|
+
)
|
|
441
|
+
_MSYS_PS_BY_WINPID, _MSYS_PS_BY_CYGPID = _parse_msys_ps_output(
|
|
442
|
+
result.stdout,
|
|
443
|
+
)
|
|
444
|
+
except (OSError, subprocess.SubprocessError):
|
|
445
|
+
pass
|
|
446
|
+
return _MSYS_PS_BY_WINPID, _MSYS_PS_BY_CYGPID
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
def _walk_windows_ancestry(
|
|
450
|
+
table: dict[int, tuple[int, str]],
|
|
451
|
+
ps_by_winpid: dict[int, tuple[int, str]],
|
|
452
|
+
ps_by_cygpid: dict[int, tuple[int, int]],
|
|
453
|
+
start_pid: int,
|
|
454
|
+
max_depth: int,
|
|
455
|
+
) -> tuple[str, ...]:
|
|
456
|
+
"""Collect parent command lines, recovering MSYS fork gaps through ``ps``.
|
|
457
|
+
|
|
458
|
+
fork-spawned MSYS processes (npm shims such as ``sh.exe``, coreutils such
|
|
459
|
+
as ``timeout``) record the transient fork helper as their Windows ppid,
|
|
460
|
+
so a plain ppid walk breaks before reaching the host process. The MSYS
|
|
461
|
+
``ps`` table keeps the logical parent, and its WINPID column maps back
|
|
462
|
+
into the Windows table where the full command line lives. A hole may sit
|
|
463
|
+
at a shim that already exited, so the walker bridges from the nearest
|
|
464
|
+
chain entry that still has a ``ps`` row.
|
|
465
|
+
"""
|
|
466
|
+
commands: list[str] = []
|
|
467
|
+
pid = start_pid
|
|
468
|
+
seen: set[int] = set()
|
|
469
|
+
last_ps_pid = 0
|
|
470
|
+
while pid > 0 and pid not in seen and len(commands) < max_depth:
|
|
471
|
+
seen.add(pid)
|
|
472
|
+
entry = table.get(pid)
|
|
473
|
+
if entry is not None:
|
|
474
|
+
ppid, command = entry
|
|
475
|
+
else:
|
|
476
|
+
ps_row = ps_by_winpid.get(pid)
|
|
477
|
+
if ps_row is None:
|
|
478
|
+
break
|
|
479
|
+
ppid, command = ps_row[0], ps_row[1]
|
|
480
|
+
parent = ps_by_cygpid.get(ppid)
|
|
481
|
+
ppid = parent[1] if parent else 0
|
|
482
|
+
if command:
|
|
483
|
+
commands.append(command)
|
|
484
|
+
if pid in ps_by_winpid:
|
|
485
|
+
last_ps_pid = pid
|
|
486
|
+
if ppid <= 0:
|
|
487
|
+
break
|
|
488
|
+
if ppid in table or ppid in ps_by_winpid:
|
|
489
|
+
pid = ppid
|
|
490
|
+
continue
|
|
491
|
+
# Dangling Windows ppid: jump through the logical parent recorded by
|
|
492
|
+
# the nearest ancestor present in the MSYS process table.
|
|
493
|
+
bridge_pid = 0
|
|
494
|
+
ps_row = ps_by_winpid.get(pid) or ps_by_winpid.get(last_ps_pid)
|
|
495
|
+
if ps_row is not None:
|
|
496
|
+
parent = ps_by_cygpid.get(ps_row[0])
|
|
497
|
+
if parent is not None:
|
|
498
|
+
bridge_pid = parent[1]
|
|
499
|
+
if bridge_pid <= 0 or bridge_pid in seen:
|
|
500
|
+
break
|
|
501
|
+
pid = bridge_pid
|
|
502
|
+
return tuple(commands)
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
def _windows_ancestry(*, max_depth: int) -> tuple[str, ...]:
|
|
506
|
+
table = _windows_process_table()
|
|
507
|
+
ps_by_winpid, ps_by_cygpid = _msys_ps_tables()
|
|
508
|
+
return _walk_windows_ancestry(
|
|
509
|
+
table, ps_by_winpid, ps_by_cygpid, os.getppid(), max_depth,
|
|
510
|
+
)
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
def process_ancestry(*, max_depth: int = 8) -> tuple[str, ...]:
|
|
514
|
+
"""Return parent command lines, nearest first, with bounded traversal.
|
|
515
|
+
|
|
516
|
+
结果按 ``max_depth`` 在进程内缓存(PERF-01):一个进程的祖先链在生命周期
|
|
517
|
+
内不会改变,Windows 分支的 ``_windows_process_table`` / ``_msys_ps_tables``
|
|
518
|
+
早已采用同一"快照一次"的设计。缓存随进程结束失效;需要在同一进程内强制
|
|
519
|
+
重探时调用 ``clear_cache()``。
|
|
520
|
+
"""
|
|
521
|
+
return _process_ancestry_cached(max_depth)
|
|
522
|
+
|
|
523
|
+
|
|
524
|
+
@functools.lru_cache(maxsize=None)
|
|
525
|
+
def _process_ancestry_cached(max_depth: int) -> tuple[str, ...]:
|
|
526
|
+
"""Uncached ancestry walk behind :func:`process_ancestry`."""
|
|
527
|
+
if sys.platform == "win32":
|
|
528
|
+
return _windows_ancestry(max_depth=max_depth)
|
|
529
|
+
commands = _posix_ancestry_via_ps(max_depth)
|
|
530
|
+
if not commands and sys.platform == "darwin":
|
|
531
|
+
# 沙箱宿主会拒绝 ``ps``,使 ps 版祖先链静默变空。空链不是「没有宿主」,
|
|
532
|
+
# 只是「探测被拒」;改用 libproc/sysctl 原生原语重走,避免把可恢复的
|
|
533
|
+
# 探测失败误判成宿主缺失。
|
|
534
|
+
commands = _darwin_ancestry(max_depth)
|
|
535
|
+
return commands
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
def _posix_ancestry_via_ps(max_depth: int) -> tuple[str, ...]:
|
|
539
|
+
"""POSIX parent chain through ``ps`` / ``/proc``."""
|
|
540
|
+
commands: list[str] = []
|
|
541
|
+
pid = os.getppid()
|
|
542
|
+
for _ in range(max_depth):
|
|
543
|
+
if pid <= 1:
|
|
544
|
+
break
|
|
545
|
+
command = _command_for_pid(pid)
|
|
546
|
+
if command:
|
|
547
|
+
commands.append(command)
|
|
548
|
+
if sys.platform.startswith("linux"):
|
|
549
|
+
try:
|
|
550
|
+
status = Path(f"/proc/{pid}/status").read_text(encoding="utf-8")
|
|
551
|
+
parent = next(
|
|
552
|
+
(line.split("\t", 1)[1] for line in status.splitlines()
|
|
553
|
+
if line.startswith("PPid:\t")),
|
|
554
|
+
"1",
|
|
555
|
+
)
|
|
556
|
+
next_pid = int(parent)
|
|
557
|
+
except (OSError, UnicodeError, ValueError):
|
|
558
|
+
break
|
|
559
|
+
else:
|
|
560
|
+
# macOS exposes the same information through ``ps``. Walking more
|
|
561
|
+
# than one level matters for Cline/ACP, where the launcher is often
|
|
562
|
+
# behind a shell or an editor bridge.
|
|
563
|
+
if sys.platform == "darwin":
|
|
564
|
+
try:
|
|
565
|
+
parent_probe = subprocess.run(
|
|
566
|
+
["ps", "-o", "ppid=", "-p", str(pid)],
|
|
567
|
+
capture_output=True, text=True, timeout=0.5, check=False,
|
|
568
|
+
)
|
|
569
|
+
next_pid = int(parent_probe.stdout.strip())
|
|
570
|
+
except (OSError, subprocess.SubprocessError, ValueError):
|
|
571
|
+
break
|
|
572
|
+
else:
|
|
573
|
+
break
|
|
574
|
+
if next_pid == pid:
|
|
575
|
+
break
|
|
576
|
+
pid = next_pid
|
|
577
|
+
return tuple(commands)
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
def _tokens(command: str) -> tuple[str, ...]:
|
|
581
|
+
try:
|
|
582
|
+
return tuple(shlex.split(command))
|
|
583
|
+
except ValueError:
|
|
584
|
+
return tuple(command.split())
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
def _exe_stem(token: str) -> str:
|
|
588
|
+
"""Executable name: basename across both separators, launcher suffix stripped.
|
|
589
|
+
|
|
590
|
+
Windows reports ``ZCode.exe``/``claude.cmd`` where POSIX reports plain
|
|
591
|
+
binary names, and process command lines keep ``\\`` separators even when
|
|
592
|
+
the detector runs on POSIX, so split on both and casefold.
|
|
593
|
+
"""
|
|
594
|
+
name = token.replace("\\", "/").rsplit("/", 1)[-1]
|
|
595
|
+
if name.casefold().endswith((".exe", ".cmd", ".bat")):
|
|
596
|
+
name = name.rsplit(".", 1)[0]
|
|
597
|
+
return name.casefold()
|
|
598
|
+
|
|
599
|
+
|
|
600
|
+
def _command_host(tokens: Sequence[str]) -> str | None:
|
|
601
|
+
"""Identify a host from the executable portion, not from a user prompt.
|
|
602
|
+
|
|
603
|
+
Cline/OpenCode prompts can contain another host's name. Looking through
|
|
604
|
+
every argv token lets that data masquerade as process evidence. Inspect
|
|
605
|
+
the executable first, then only the script token of a small set of known
|
|
606
|
+
launchers (``node``, ``python`` and wrappers such as ``env``/``sudo``).
|
|
607
|
+
"""
|
|
608
|
+
if not tokens:
|
|
609
|
+
return None
|
|
610
|
+
wrappers = {
|
|
611
|
+
"env", "sudo", "node", "nodejs", "python", "python3", "bun", "deno",
|
|
612
|
+
}
|
|
613
|
+
first = _exe_stem(tokens[0])
|
|
614
|
+
if first in HOSTS[:-1]:
|
|
615
|
+
return first
|
|
616
|
+
if first not in wrappers:
|
|
617
|
+
launch_tokens = tokens[:1]
|
|
618
|
+
else:
|
|
619
|
+
launch_tokens = tokens[1:5]
|
|
620
|
+
for token in launch_tokens:
|
|
621
|
+
if first == "env" and "=" in token and not token.startswith("/"):
|
|
622
|
+
continue
|
|
623
|
+
name = _exe_stem(token)
|
|
624
|
+
if name in HOSTS[:-1]:
|
|
625
|
+
return name
|
|
626
|
+
# 别名归一化收敛到 host_registry(claude-code→claude、deepseek→dsh、
|
|
627
|
+
# codebuddy→workbuddy),避免每个调用点各写一套映射。
|
|
628
|
+
alias = host_registry.normalize_host_name(name) if host_registry is not None else None
|
|
629
|
+
if alias:
|
|
630
|
+
return alias
|
|
631
|
+
if name in {"zcode", "zcode.cjs", "zcode.js", "zcode.mjs"} or name.startswith("zcode helper"):
|
|
632
|
+
return "zcode"
|
|
633
|
+
return None
|
|
634
|
+
|
|
635
|
+
|
|
636
|
+
# macOS ``.app`` bundle:``/Applications/WorkBuddy AI.app/...`` → ``WorkBuddy AI``。
|
|
637
|
+
# 打包型宿主(WorkBuddy 的 ``MacOS`` 可执行名就是 ``Electron``)无法从可执行名
|
|
638
|
+
# 识别,只能靠 bundle 名;而 bundle 名可能含空格,``shlex`` 会把
|
|
639
|
+
# ``WorkBuddy AI.app`` 拆成 ``/Applications/WorkBuddy`` + ``AI.app/...``,使旧实现
|
|
640
|
+
# 的命中**纯属巧合**(改名成无空格的 ``WorkBuddy.app`` 即失配)。因此从原始
|
|
641
|
+
# 命令行里读 bundle 名,不经过 ``shlex``。锚定命令行开头,确保只在可执行路径
|
|
642
|
+
# 上生效——出现在参数位置的 ``.app``(``cat /Applications/ZCode.app/...``)是数据,
|
|
643
|
+
# 不是进程证据。路径前缀组件不允许含空格,以便把 ``/bin/cat /Applications/X.app``
|
|
644
|
+
# 这类「命令 + 参数」整体排除。
|
|
645
|
+
_MACOS_APP_BUNDLE = re.compile(
|
|
646
|
+
r"""^["']?/(?:[^/\s]+/)*([^/\s][^/]*)\.app(?=/|["']|\s|$)""",
|
|
647
|
+
)
|
|
648
|
+
|
|
649
|
+
|
|
650
|
+
def _app_bundle_host(command: str) -> str | None:
|
|
651
|
+
"""Identify a host from the leading macOS ``.app`` bundle name."""
|
|
652
|
+
match = _MACOS_APP_BUNDLE.match(command)
|
|
653
|
+
if match is None:
|
|
654
|
+
return None
|
|
655
|
+
for word in re.split(r"[\s_\-]+", match.group(1)):
|
|
656
|
+
name = word.casefold()
|
|
657
|
+
if not name:
|
|
658
|
+
continue
|
|
659
|
+
if name in HOSTS[:-1]:
|
|
660
|
+
return name
|
|
661
|
+
alias = (
|
|
662
|
+
host_registry.normalize_host_name(name)
|
|
663
|
+
if host_registry is not None else None
|
|
664
|
+
)
|
|
665
|
+
if alias:
|
|
666
|
+
return alias
|
|
667
|
+
return None
|
|
668
|
+
|
|
669
|
+
|
|
670
|
+
def _host_from_commands(commands: Sequence[str]) -> tuple[str | None, str, bool]:
|
|
671
|
+
"""Return (host, source, headless) from process command lines."""
|
|
672
|
+
for command in commands:
|
|
673
|
+
lower = command.casefold()
|
|
674
|
+
tokens = _tokens(lower)
|
|
675
|
+
host = _command_host(tokens)
|
|
676
|
+
if host is None:
|
|
677
|
+
# 打包型宿主的 ``MacOS`` 可执行名不是宿主名(WorkBuddy → Electron),
|
|
678
|
+
# 且 ``shlex`` 会破坏含空格的 ``.app`` 路径;改从 bundle 名识别。
|
|
679
|
+
host = _app_bundle_host(lower)
|
|
680
|
+
if host is None:
|
|
681
|
+
continue
|
|
682
|
+
interactive = any(marker in tokens for marker in ("--tui", "-i"))
|
|
683
|
+
headless = not interactive and any(
|
|
684
|
+
marker in tokens
|
|
685
|
+
for marker in ("acp", "--acp", "--json", "run", "exec", "--non-interactive", "--print-logs")
|
|
686
|
+
)
|
|
687
|
+
return host, "process-tree", headless
|
|
688
|
+
return None, "unidentified", False
|
|
689
|
+
|
|
690
|
+
|
|
691
|
+
def _configured_host(root: Path) -> str | None:
|
|
692
|
+
"""Use one project host marker as a diagnostic fallback, never as proof.
|
|
693
|
+
|
|
694
|
+
Multiple host entries are common when a project has been installed for
|
|
695
|
+
more than one AI IDE. In that case a marker cannot identify the current
|
|
696
|
+
host and must not silently select OpenCode (or any other host).
|
|
697
|
+
|
|
698
|
+
Marker table lives in ``host_registry`` so a newly supported host cannot be
|
|
699
|
+
silently missing from this fallback (previously ``.workbuddy`` had no
|
|
700
|
+
branch at all).
|
|
701
|
+
"""
|
|
702
|
+
if host_registry is None: # pragma: no cover - malformed snapshot
|
|
703
|
+
return None
|
|
704
|
+
try:
|
|
705
|
+
return host_registry.configured_host(root)
|
|
706
|
+
except OSError:
|
|
707
|
+
return None
|
|
708
|
+
|
|
709
|
+
|
|
710
|
+
def _bool_env(env: Mapping[str, str], name: str) -> bool:
|
|
711
|
+
return env.get(name, "").strip().casefold() in {"1", "true", "yes", "on"}
|
|
712
|
+
|
|
713
|
+
|
|
714
|
+
@functools.lru_cache(maxsize=None)
|
|
715
|
+
def _git_snapshot_cached(root: str, path_env: str) -> dict[str, object]:
|
|
716
|
+
"""``detect()`` 复用的 Git 快照缓存(键:项目根 + PATH)。
|
|
717
|
+
|
|
718
|
+
``detect_git`` 只把 ``environ`` 用于 ``shutil.which`` 解析 git 可执行文件,
|
|
719
|
+
其内部的 git 子进程一律继承真实 ``os.environ``,所以缓存键只需 PATH。
|
|
720
|
+
|
|
721
|
+
``detect_git()`` 自身的"每次都是新探测"契约保持不变:启动门禁
|
|
722
|
+
(``git_startup_gate``)直接调用它时仍然拿到实时结果,用户修复 Git 后
|
|
723
|
+
不需要重启进程即可重新探测。
|
|
724
|
+
|
|
725
|
+
本函数是内部实现,返回值是缓存里的**共享对象**,调用方一律经
|
|
726
|
+
:func:`_git_snapshot_for_detect` 取副本。
|
|
727
|
+
"""
|
|
728
|
+
return detect_git(Path(root), environ={"PATH": path_env})
|
|
729
|
+
|
|
730
|
+
|
|
731
|
+
def _git_snapshot_for_detect(root: str, path_env: str) -> dict[str, object]:
|
|
732
|
+
"""返回缓存快照的独立副本。
|
|
733
|
+
|
|
734
|
+
``lru_cache`` 会把同一个 dict 交给所有调用方;一旦有调用方就地改写
|
|
735
|
+
(或改写嵌套的 ``identity``),污染会扩散到所有持有该快照的对象——
|
|
736
|
+
缓存的全部价值就是「可安全共享」,因此这里显式复制一层。
|
|
737
|
+
"""
|
|
738
|
+
snapshot = _git_snapshot_cached(root, path_env)
|
|
739
|
+
copied = dict(snapshot)
|
|
740
|
+
identity = snapshot.get("identity")
|
|
741
|
+
if isinstance(identity, dict):
|
|
742
|
+
copied["identity"] = dict(identity)
|
|
743
|
+
return copied
|
|
744
|
+
|
|
745
|
+
|
|
746
|
+
def detect(
|
|
747
|
+
root: Path,
|
|
748
|
+
*,
|
|
749
|
+
environ: Mapping[str, str] | None = None,
|
|
750
|
+
commands: Sequence[str] | None = None,
|
|
751
|
+
stdin_tty: bool | None = None,
|
|
752
|
+
stdout_tty: bool | None = None,
|
|
753
|
+
) -> StartupEnvironment:
|
|
754
|
+
"""Detect host, UI surface and the only safe startup interaction channel.
|
|
755
|
+
|
|
756
|
+
``BUGX_INTERACTION`` is an explicit integration hook for the interaction
|
|
757
|
+
channel only. Host identity is NEVER taken from the environment:
|
|
758
|
+
PE-20261004-004(用户指令)——宿主身份只来自进程祖先链主动探查;
|
|
759
|
+
探查失败 host=None(broken),由引擎显式告知宿主修复运行环境。
|
|
760
|
+
A project config is only reported as a fallback host hint; it cannot
|
|
761
|
+
grant native interaction to a headless process.
|
|
762
|
+
"""
|
|
763
|
+
env = dict(os.environ if environ is None else environ)
|
|
764
|
+
root = root.resolve()
|
|
765
|
+
stdin = bool(sys.stdin.isatty()) if stdin_tty is None else bool(stdin_tty)
|
|
766
|
+
stdout = bool(sys.stdout.isatty()) if stdout_tty is None else bool(stdout_tty)
|
|
767
|
+
ancestry = tuple(commands) if commands is not None else process_ancestry()
|
|
768
|
+
host, source, detected_headless = _host_from_commands(ancestry)
|
|
769
|
+
host_observed = host is not None
|
|
770
|
+
if host is None:
|
|
771
|
+
host = _configured_host(root)
|
|
772
|
+
source = "project-config" if host else "unidentified"
|
|
773
|
+
|
|
774
|
+
explicit_channel = env.get("BUGX_INTERACTION", "").strip().casefold()
|
|
775
|
+
explicit_transport = env.get("BUGX_TRANSPORT", "").strip().casefold()
|
|
776
|
+
explicit_process_mode = env.get("BUGX_PROCESS_MODE", "").strip().casefold()
|
|
777
|
+
explicit_headless = (
|
|
778
|
+
_bool_env(env, "BUGX_ACP")
|
|
779
|
+
or _bool_env(env, "BUGX_HEADLESS")
|
|
780
|
+
or explicit_transport in {"acp", "pipe", "stdio"}
|
|
781
|
+
or explicit_process_mode == "headless"
|
|
782
|
+
)
|
|
783
|
+
# An explicit headless/ACP marker is stronger than a copied TUI hint. ACP
|
|
784
|
+
# brokers commonly inherit BUGX_INTERACTION=question from their desktop
|
|
785
|
+
# host; allowing that hint to win makes the child claim a question tool it
|
|
786
|
+
# cannot actually service and silently misclassifies ACP as TUI.
|
|
787
|
+
if explicit_headless:
|
|
788
|
+
detected_headless = True
|
|
789
|
+
interaction = "blocked"
|
|
790
|
+
reason = "宿主显式声明 ACP/headless,无可用原生单选回调"
|
|
791
|
+
elif explicit_channel in {"question", "native", "native-question"}:
|
|
792
|
+
interaction = "native-question"
|
|
793
|
+
reason = "宿主显式声明原生单选能力"
|
|
794
|
+
elif explicit_channel in {"tty", "tty-radio", "radio"}:
|
|
795
|
+
interaction = "tty-radio"
|
|
796
|
+
reason = "宿主显式声明 TTY 单选能力"
|
|
797
|
+
elif explicit_channel in {"text", "text-menu"}:
|
|
798
|
+
interaction = "text-menu"
|
|
799
|
+
reason = "宿主显式声明文本菜单"
|
|
800
|
+
elif explicit_channel in {"none", "blocked", "headless"}:
|
|
801
|
+
interaction = "blocked"
|
|
802
|
+
reason = "宿主显式声明无交互能力"
|
|
803
|
+
else:
|
|
804
|
+
if host in NATIVE_QUESTION_HOSTS and host_observed and not detected_headless:
|
|
805
|
+
interaction = "native-question"
|
|
806
|
+
reason = "从宿主 TUI 进程树识别到原生交互宿主"
|
|
807
|
+
elif stdin and stdout:
|
|
808
|
+
interaction = "text-menu" if _bool_env(env, "BUGX_TEXT_MENU") else "tty-radio"
|
|
809
|
+
reason = "当前进程拥有真实 TTY"
|
|
810
|
+
else:
|
|
811
|
+
interaction = "blocked"
|
|
812
|
+
reason = "没有宿主原生选择能力,也没有真实 TTY"
|
|
813
|
+
|
|
814
|
+
interface = "headless"
|
|
815
|
+
if host in NATIVE_QUESTION_HOSTS and host_observed and not detected_headless:
|
|
816
|
+
interface = "tui"
|
|
817
|
+
elif stdin and stdout:
|
|
818
|
+
interface = "tty"
|
|
819
|
+
elif detected_headless:
|
|
820
|
+
interface = "acp" if any(
|
|
821
|
+
token in {"acp", "--acp"}
|
|
822
|
+
for command in ancestry
|
|
823
|
+
for token in _tokens(command.casefold())
|
|
824
|
+
) or explicit_transport == "acp" or _bool_env(env, "BUGX_ACP") else "headless"
|
|
825
|
+
|
|
826
|
+
native_question = interaction == "native-question"
|
|
827
|
+
command_line = tuple(ancestry[:3])
|
|
828
|
+
if i18n is not None:
|
|
829
|
+
locale = i18n.resolve_locale(environ=env)
|
|
830
|
+
else: # pragma: no cover - only malformed installations
|
|
831
|
+
locale = None
|
|
832
|
+
return StartupEnvironment(
|
|
833
|
+
host=host or "unknown",
|
|
834
|
+
host_source=source,
|
|
835
|
+
interface=interface,
|
|
836
|
+
interaction=interaction,
|
|
837
|
+
stdin_tty=stdin,
|
|
838
|
+
stdout_tty=stdout,
|
|
839
|
+
term=env.get("TERM", ""),
|
|
840
|
+
command_line=command_line,
|
|
841
|
+
native_question=native_question,
|
|
842
|
+
reason=reason,
|
|
843
|
+
requested_locale=locale.requested_locale if locale else None,
|
|
844
|
+
resolved_locale=locale.resolved_locale if locale else "en-US",
|
|
845
|
+
locale_source=locale.source if locale else "fallback",
|
|
846
|
+
locale_fallback_reason=locale.fallback_reason if locale else "i18n unavailable",
|
|
847
|
+
git=_git_snapshot_for_detect(str(root), env.get("PATH", "")),
|
|
848
|
+
)
|
|
849
|
+
|
|
850
|
+
|
|
851
|
+
def clear_cache() -> None:
|
|
852
|
+
"""清空本模块的进程内探测缓存(进程树祖先 + Git 快照)。
|
|
853
|
+
|
|
854
|
+
缓存生命周期是"一个进程":宿主进程树、TTY 能力与 Git 就绪状态在一次会话里
|
|
855
|
+
不会改变,因此正常启动流程无需清理。测试、或需要在同一进程内强制重新探测
|
|
856
|
+
时调用;清理后下一次 ``detect()`` 会重新执行 git / ps 子进程。
|
|
857
|
+
"""
|
|
858
|
+
_process_ancestry_cached.cache_clear()
|
|
859
|
+
_git_snapshot_cached.cache_clear()
|