bugx-cli 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +55 -0
- package/README.md +280 -2
- package/core/CATALOG.json +141 -0
- package/core/README.md +254 -0
- package/core/adapters/README.md +35 -0
- package/core/adapters/android-interaction.json +81 -0
- package/core/adapters/android.json +24 -0
- package/core/adapters/desktop-macos.json +20 -0
- package/core/adapters/ios-interaction.json +34 -0
- package/core/adapters/ios.json +23 -0
- package/core/adapters/memory-macos.json +24 -0
- package/core/agent/README.md +50 -0
- package/core/agent/__init__.py +146 -0
- package/core/agent/agent_artifacts.py +764 -0
- package/core/agent/agent_eval.py +1073 -0
- package/core/agent/agent_execution.py +552 -0
- package/core/agent/agent_orchestrator.py +1345 -0
- package/core/agent/agent_targets.py +871 -0
- package/core/agent/agent_workspace.py +770 -0
- package/core/assets/README.md +24 -0
- package/core/assets/bugx-avatar-1024.png +0 -0
- package/core/assets/bugx-avatar-512.png +0 -0
- package/core/assets/bugx-avatar-tight.svg +23 -0
- package/core/assets/bugx-avatar.svg +28 -0
- package/core/assets/bugx-hero-cn.png +0 -0
- package/core/assets/bugx-hero-en.png +0 -0
- package/core/assets/project-layout.md +42 -0
- package/core/audit_packs/README.md +37 -0
- package/core/audit_packs/data-audit/manifest.json +94 -0
- package/core/audit_packs/data-audit/stages/00-scope.md +14 -0
- package/core/audit_packs/data-audit/stages/10-schema-inventory.md +14 -0
- package/core/audit_packs/data-audit/stages/20-query-and-integrity.md +14 -0
- package/core/audit_packs/data-audit/stages/80-evidence-regression.md +14 -0
- package/core/audit_packs/desktop-audit/manifest.json +123 -0
- package/core/audit_packs/desktop-audit/stages/00-scope.md +15 -0
- package/core/audit_packs/desktop-audit/stages/10-process-model.md +14 -0
- package/core/audit_packs/desktop-audit/stages/20-package-integrity.md +15 -0
- package/core/audit_packs/desktop-audit/stages/30-ui-behavior.md +14 -0
- package/core/audit_packs/desktop-audit/stages/80-evidence-regression.md +15 -0
- package/core/audit_packs/memory-testing.md +227 -0
- package/core/audit_packs/mobile-audit/manifest.json +155 -0
- package/core/audit_packs/mobile-audit/modules/android.md +19 -0
- package/core/audit_packs/mobile-audit/modules/h5.md +18 -0
- package/core/audit_packs/mobile-audit/modules/ios.md +25 -0
- package/core/audit_packs/mobile-audit/modules/miniprogram.md +26 -0
- package/core/audit_packs/mobile-audit/modules/webview.md +18 -0
- package/core/audit_packs/mobile-audit/stages/00-scope.md +14 -0
- package/core/audit_packs/mobile-audit/stages/10-platform-inventory.md +14 -0
- package/core/audit_packs/mobile-audit/stages/20-masvs-static.md +20 -0
- package/core/audit_packs/mobile-audit/stages/30-component-exposure.md +14 -0
- package/core/audit_packs/mobile-audit/stages/40-device-behavior.md +14 -0
- package/core/audit_packs/mobile-audit/stages/80-evidence-regression.md +13 -0
- package/core/audit_packs/native-audit/manifest.json +127 -0
- package/core/audit_packs/native-audit/stages/00-scope.md +14 -0
- package/core/audit_packs/native-audit/stages/10-static-white-box.md +14 -0
- package/core/audit_packs/native-audit/stages/20-memory-concurrency.md +15 -0
- package/core/audit_packs/native-audit/stages/30-behavior-black-box.md +39 -0
- package/core/audit_packs/native-audit/stages/80-evidence-regression.md +14 -0
- package/core/audit_packs/platform-testing.md +174 -0
- package/core/audit_packs/web-audit/manifest.json +191 -0
- package/core/audit_packs/web-audit/modules/graphql.md +5 -0
- package/core/audit_packs/web-audit/modules/h5.md +18 -0
- package/core/audit_packs/web-audit/modules/multi-tenant.md +4 -0
- package/core/audit_packs/web-audit/modules/oauth.md +4 -0
- package/core/audit_packs/web-audit/modules/upload.md +4 -0
- package/core/audit_packs/web-audit/modules/websocket.md +4 -0
- package/core/audit_packs/web-audit/stages/00-scope.md +13 -0
- package/core/audit_packs/web-audit/stages/10-discovery.md +13 -0
- package/core/audit_packs/web-audit/stages/20-auth-session.md +13 -0
- package/core/audit_packs/web-audit/stages/30-authz-business.md +13 -0
- package/core/audit_packs/web-audit/stages/40-input-output.md +13 -0
- package/core/audit_packs/web-audit/stages/50-state-async.md +13 -0
- package/core/audit_packs/web-audit/stages/60-file-ssrf-deser.md +12 -0
- package/core/audit_packs/web-audit/stages/70-config-dependency.md +12 -0
- package/core/audit_packs/web-audit/stages/80-evidence-regression.md +12 -0
- package/core/autonomous_cve/INTERFACE.md +61 -0
- package/core/autonomous_cve/README.md +58 -0
- package/core/autonomous_cve/SPEC.md +25 -0
- package/core/autonomous_cve/__init__.py +109 -0
- package/core/autonomous_cve/attack_graph.py +1096 -0
- package/core/autonomous_cve/attack_graph_store.py +1822 -0
- package/core/autonomous_cve/audit_campaign.py +1232 -0
- package/core/autonomous_cve/behavior_graph.py +459 -0
- package/core/autonomous_cve/ghsa_advisories.py +174 -0
- package/core/autonomous_cve/models.py +93 -0
- package/core/autonomous_cve/mutator.py +87 -0
- package/core/autonomous_cve/patcher.py +126 -0
- package/core/autonomous_cve/scout.py +278 -0
- package/core/autonomous_cve/synthesizer.py +207 -0
- package/core/autonomous_cve/verifier.py +100 -0
- package/core/bugx.md +1299 -0
- package/core/bugx_paths.py +1846 -0
- package/core/cloud_sync/INTERFACE.md +32 -0
- package/core/cloud_sync/README.md +62 -0
- package/core/cloud_sync/SPEC.md +25 -0
- package/core/cloud_sync/__init__.py +23 -0
- package/core/cloud_sync/auto_sync.py +398 -0
- package/core/cloud_sync/cloud_client.py +1199 -0
- package/core/cloud_sync/cloud_onboard.py +702 -0
- package/core/cloud_sync/cloud_schema.py +648 -0
- package/core/cloud_sync/consent.py +81 -0
- package/core/cloud_sync/device_identity.py +307 -0
- package/core/cloud_sync/endpoint_router.py +415 -0
- package/core/cloud_sync/flywheel_client.py +760 -0
- package/core/cloud_sync/network_transport.py +275 -0
- package/core/cloud_sync/onboard_wizard.py +493 -0
- package/core/cloud_sync/sensitive_filter.py +285 -0
- package/core/cloud_sync/sync_pull.py +695 -0
- package/core/cloud_sync/sync_push.py +721 -0
- package/core/contracts/AGENT_GUIDE.md +362 -0
- package/core/contracts/README.md +34 -0
- package/core/contracts/bugx-blackbox.md +541 -0
- package/core/contracts/bugx-opencode.md +469 -0
- package/core/contracts/bugx-quick.md +44 -0
- package/core/contracts/bugx-runtime-contract.md +353 -0
- package/core/contracts/bugx-worker.md +470 -0
- package/core/contracts/engine_gap_contracts.py +390 -0
- package/core/coverage/README.md +70 -0
- package/core/coverage/__init__.py +106 -0
- package/core/coverage/coverage_ai_review.py +185 -0
- package/core/coverage/coverage_backfill.py +54 -0
- package/core/coverage/coverage_bootstrap.py +713 -0
- package/core/coverage/coverage_business.py +36 -0
- package/core/coverage/coverage_cli.py +715 -0
- package/core/coverage/coverage_discovery.py +859 -0
- package/core/coverage/coverage_evidence.py +977 -0
- package/core/coverage/coverage_forensics.py +115 -0
- package/core/coverage/coverage_gate.py +277 -0
- package/core/coverage/coverage_intelligence.py +734 -0
- package/core/coverage/coverage_manifest.py +396 -0
- package/core/coverage/coverage_platform.py +77 -0
- package/core/coverage/coverage_validate.py +236 -0
- package/core/coverage/module_coverage.py +157 -0
- package/core/dev_harness/INTERFACE.md +20 -0
- package/core/dev_harness/README.md +21 -0
- package/core/dev_harness/SPEC.md +25 -0
- package/core/dev_harness/__init__.py +5 -0
- package/core/dev_harness/interaction_preset.py +408 -0
- package/core/engine-integrity.json +2625 -0
- package/core/fuzzing/README.md +49 -0
- package/core/fuzzing/__init__.py +82 -0
- package/core/fuzzing/concurrency_fuzzer.py +382 -0
- package/core/fuzzing/differential_oracle.py +629 -0
- package/core/fuzzing/fuzz_input.py +1188 -0
- package/core/fuzzing/stateful_fuzzer.py +332 -0
- package/core/governance/README.md +61 -0
- package/core/governance/__init__.py +130 -0
- package/core/governance/capacity_planner.py +124 -0
- package/core/governance/dependency_lock.py +317 -0
- package/core/governance/goal_governor.py +754 -0
- package/core/governance/guide_budget.py +458 -0
- package/core/governance/lockdown.sh +50 -0
- package/core/governance/readonly_enforcer.py +154 -0
- package/core/governance/runtime_tool_gate.py +373 -0
- package/core/governance/secret_redactor.py +772 -0
- package/core/governance/token_budget.py +38 -0
- package/core/host_acp/INTERFACE.md +36 -0
- package/core/host_acp/README.md +51 -0
- package/core/host_acp/SPEC.md +25 -0
- package/core/host_acp/__init__.py +121 -0
- package/core/host_acp/base.py +111 -0
- package/core/host_acp/claude.py +41 -0
- package/core/host_acp/cline.py +235 -0
- package/core/host_acp/codex.py +245 -0
- package/core/host_acp/dsh.py +48 -0
- package/core/host_acp/opencode.py +154 -0
- package/core/host_acp/pi.py +36 -0
- package/core/host_acp/zcode.py +41 -0
- package/core/host_runtime/INTERFACE.md +24 -0
- package/core/host_runtime/README.md +62 -0
- package/core/host_runtime/SPEC.md +25 -0
- package/core/host_runtime/__init__.py +21 -0
- package/core/host_runtime/adapters.py +412 -0
- package/core/host_runtime/autonomous_runner.py +1152 -0
- package/core/host_runtime/cline.py +435 -0
- package/core/host_runtime/common.py +103 -0
- package/core/host_runtime/free_models.py +786 -0
- package/core/host_runtime/host_bootstrap.py +389 -0
- package/core/host_runtime/host_evaluators.py +721 -0
- package/core/host_runtime/host_probe.py +41 -0
- package/core/host_runtime/host_provider_arbitrator.py +777 -0
- package/core/host_runtime/host_registry.py +655 -0
- package/core/host_runtime/host_usage.py +127 -0
- package/core/host_runtime/mcp_process_tracker.py +509 -0
- package/core/host_runtime/mcp_registry_gate.py +368 -0
- package/core/hosts/INTERFACE.md +51 -0
- package/core/hosts/README.md +67 -0
- package/core/hosts/SPEC.md +25 -0
- package/core/hosts/__init__.py +136 -0
- package/core/hosts/_base_usage.py +152 -0
- package/core/hosts/_codex_usage.py +297 -0
- package/core/hosts/_dsh_usage.py +184 -0
- package/core/hosts/_mcp_toml.py +365 -0
- package/core/hosts/_zcode_usage.py +269 -0
- package/core/hosts/base.py +451 -0
- package/core/hosts/claude.py +157 -0
- package/core/hosts/cline.py +225 -0
- package/core/hosts/codex.py +948 -0
- package/core/hosts/dsh.py +518 -0
- package/core/hosts/opencode.py +358 -0
- package/core/hosts/pi.py +151 -0
- package/core/hosts/zcode.py +219 -0
- package/core/i18n.py +252 -0
- package/core/infra/README.md +39 -0
- package/core/infra/__init__.py +15 -0
- package/core/infra/build_info.py +86 -0
- package/core/infra/client_metadata.py +185 -0
- package/core/infra/python_runtime.py +540 -0
- package/core/infra/safe_xml.py +221 -0
- package/core/launch_bugx.py +118 -0
- package/core/launch_phases/INTERFACE.md +31 -0
- package/core/launch_phases/README.md +106 -0
- package/core/launch_phases/SPEC.md +25 -0
- package/core/launch_phases/__init__.py +29 -0
- package/core/launch_phases/candidate_revalidation.py +484 -0
- package/core/launch_phases/common.py +1041 -0
- package/core/launch_phases/finding_confirm_phase.py +387 -0
- package/core/launch_phases/finding_settlement.py +1245 -0
- package/core/launch_phases/findings_adjudication.py +666 -0
- package/core/launch_phases/findings_snapshot.py +357 -0
- package/core/launch_phases/judge_phase.py +791 -0
- package/core/launch_phases/lesson_context.py +536 -0
- package/core/launch_phases/lifecycle_reporter.py +627 -0
- package/core/launch_phases/orchestrator_controls.py +682 -0
- package/core/launch_phases/post_commit.py +567 -0
- package/core/launch_phases/post_coverage_sync.py +591 -0
- package/core/launch_phases/post_dry_run.py +817 -0
- package/core/launch_phases/post_observability.py +367 -0
- package/core/launch_phases/post_phase.py +1087 -0
- package/core/launch_phases/post_receipt.py +362 -0
- package/core/launch_phases/post_round_lifecycle.py +786 -0
- package/core/launch_phases/pre_phase.py +1029 -0
- package/core/launch_phases/pre_recon_scout.py +862 -0
- package/core/launch_phases/pre_state_builder.py +1286 -0
- package/core/launch_phases/report_sharing.py +414 -0
- package/core/launch_phases/round_orchestrator.py +1133 -0
- package/core/launch_phases/session_runtime.py +1623 -0
- package/core/launch_phases/startup_gates.py +1022 -0
- package/core/launch_phases/startup_interaction.py +947 -0
- package/core/launch_phases/startup_version_gate.py +873 -0
- package/core/launch_phases/supervisor_bridge.py +1224 -0
- package/core/launch_phases/supervisor_coverage.py +417 -0
- package/core/launch_phases/supervisor_degraded.py +1219 -0
- package/core/launch_phases/worker_barriers.py +414 -0
- package/core/launch_phases/worker_orchestrator.py +1166 -0
- package/core/launch_phases/worker_prior.py +749 -0
- package/core/ledger/INTERFACE.md +35 -0
- package/core/ledger/README.md +160 -0
- package/core/ledger/SPEC.md +25 -0
- package/core/ledger/__init__.py +67 -0
- package/core/ledger/_facade.py +226 -0
- package/core/ledger/archive_ops.py +572 -0
- package/core/ledger/auto_materialization.py +459 -0
- package/core/ledger/bug-log.md +22 -0
- package/core/ledger/cli.py +270 -0
- package/core/ledger/export_ops.py +549 -0
- package/core/ledger/finding_confirmation.py +1274 -0
- package/core/ledger/finding_io.py +299 -0
- package/core/ledger/finding_lifecycle.py +307 -0
- package/core/ledger/finding_verification.py +369 -0
- package/core/ledger/incidents.py +999 -0
- package/core/ledger/lesson-replay-cases.json +20 -0
- package/core/ledger/lesson_ledger.py +241 -0
- package/core/ledger/lesson_replay.py +272 -0
- package/core/ledger/life_ledger.py +668 -0
- package/core/ledger/mistake-book.md +130 -0
- package/core/ledger/patterns.py +681 -0
- package/core/ledger/receipt_contract.py +253 -0
- package/core/ledger/schema.py +1192 -0
- package/core/ledger/sync_ops.py +935 -0
- package/core/ledger/tool_experience.py +682 -0
- package/core/ledger/verify_life.py +1526 -0
- package/core/lesson-ledger.json +275 -0
- package/core/locales/README.md +19 -0
- package/core/locales/en-US.json +462 -0
- package/core/locales/zh-CN.json +462 -0
- package/core/mcp_handlers/INTERFACE.md +75 -0
- package/core/mcp_handlers/README.md +62 -0
- package/core/mcp_handlers/SPEC.md +25 -0
- package/core/mcp_handlers/__init__.py +128 -0
- package/core/mcp_handlers/base.py +697 -0
- package/core/mcp_handlers/channel_lifecycle.py +696 -0
- package/core/mcp_handlers/graph_handlers.py +222 -0
- package/core/mcp_handlers/knowledge_handlers.py +536 -0
- package/core/mcp_handlers/mining_handlers.py +586 -0
- package/core/mcp_handlers/resource_prompt_table.py +116 -0
- package/core/mcp_handlers/retrieval_handlers.py +239 -0
- package/core/mcp_handlers/rpc_server.py +465 -0
- package/core/mcp_handlers/supervisor_handlers.py +1435 -0
- package/core/mcp_handlers/telemetry_handlers.py +227 -0
- package/core/mcp_handlers/tool_table.py +1015 -0
- package/core/mcp_runtime_support/README.md +21 -0
- package/core/mcp_runtime_support/__init__.py +1 -0
- package/core/mcp_runtime_support/common.py +363 -0
- package/core/mcp_runtime_support/environment.py +605 -0
- package/core/mcp_runtime_support/verifier.py +810 -0
- package/core/metadata.txt +5 -0
- package/core/planning/README.md +157 -0
- package/core/planning/__init__.py +242 -0
- package/core/planning/capability_plan.py +187 -0
- package/core/planning/capability_planner.py +195 -0
- package/core/planning/domain_archetype.py +542 -0
- package/core/planning/domain_router.py +267 -0
- package/core/planning/dynamic_flow_analyzer.py +328 -0
- package/core/planning/impact_pruner.py +435 -0
- package/core/planning/intent_adjudicator.py +175 -0
- package/core/planning/judge_pipeline.py +1163 -0
- package/core/planning/logic_analysis.py +419 -0
- package/core/planning/prompt_harness.py +1702 -0
- package/core/planning/source_inspector.py +267 -0
- package/core/planning/spec_harvester.py +449 -0
- package/core/planning/target_sandbox_manager.py +573 -0
- package/core/planning/test_capability_verifier.py +1364 -0
- package/core/planning/tools-kb.md +38 -0
- package/core/planning/unit_kind.py +122 -0
- package/core/probes/INTERFACE.md +73 -0
- package/core/probes/README.md +51 -0
- package/core/probes/SPEC.md +26 -0
- package/core/probes/__init__.py +70 -0
- package/core/probes/android_probe.py +384 -0
- package/core/probes/base.py +147 -0
- package/core/probes/codebase_memory_probe.py +590 -0
- package/core/probes/desktop_probe.py +238 -0
- package/core/probes/differential_probe.py +356 -0
- package/core/probes/efficiency_probe.py +168 -0
- package/core/probes/ios_binary_probe.py +368 -0
- package/core/probes/memory_probe.py +326 -0
- package/core/probes/miniprogram_probe.py +323 -0
- package/core/probes/mobile_probe.py +281 -0
- package/core/probes/native_probe.py +214 -0
- package/core/probes/openwiki_probe.py +193 -0
- package/core/probes/pattern_probe.py +347 -0
- package/core/probes/platform_probe.py +343 -0
- package/core/probes/probe_registry.py +1669 -0
- package/core/probes/sast_probe.py +1009 -0
- package/core/probes/sast_rules.py +841 -0
- package/core/probes/sca_scanner.py +731 -0
- package/core/probes/web_probe.py +359 -0
- package/core/project_profiler/INTERFACE.md +62 -0
- package/core/project_profiler/README.md +53 -0
- package/core/project_profiler/SPEC.md +28 -0
- package/core/project_profiler/__init__.py +201 -0
- package/core/project_profiler/arbitrator.py +311 -0
- package/core/project_profiler/constants.py +247 -0
- package/core/project_profiler/detector.py +392 -0
- package/core/project_profiler/extractors.py +836 -0
- package/core/project_profiler/fingerprint.py +116 -0
- package/core/project_profiler/storage.py +258 -0
- package/core/project_profiler/strategy.py +265 -0
- package/core/prompts/README.md +35 -0
- package/core/prompts/codex_dialog_dispatch.md +9 -0
- package/core/prompts/command_routing_en.md +42 -0
- package/core/prompts/command_routing_zh.md +42 -0
- package/core/prompts/l0_router.md +47 -0
- package/core/prompts/rules/anti_patterns.md +16 -0
- package/core/prompts/rules/concurrency_rules.md +14 -0
- package/core/prompts/rules/memory_leak_rules.md +13 -0
- package/core/prompts/rules/prompt_injection_defense.md +13 -0
- package/core/prompts/stages/stage_explore.md +31 -0
- package/core/prompts/stages/stage_gate.md +43 -0
- package/core/prompts/stages/stage_mutate.md +42 -0
- package/core/prompts/stages/stage_repair.md +85 -0
- package/core/repair/README.md +74 -0
- package/core/repair/__init__.py +169 -0
- package/core/repair/fix_watchlist.py +391 -0
- package/core/repair/l7_dynamic.py +418 -0
- package/core/repair/l7_repair_loop.py +465 -0
- package/core/repair/l7_selfcheck.py +862 -0
- package/core/repair/minimize_repro.py +466 -0
- package/core/repair/patch_synthesizer.py +617 -0
- package/core/repair/regression_pack.py +379 -0
- package/core/repair/rsi_fixer.py +910 -0
- package/core/repair/rsi_loop.py +313 -0
- package/core/repair/rsi_repair.py +348 -0
- package/core/repair/rsi_rounds.py +212 -0
- package/core/repair/rsi_scope.py +262 -0
- package/core/repair/self_heal.py +604 -0
- package/core/repair/test_generator.py +1108 -0
- package/core/repair/test_quality_auditor.py +410 -0
- package/core/repair/test_strategy.py +511 -0
- package/core/report_engine/INTERFACE.md +59 -0
- package/core/report_engine/README.md +69 -0
- package/core/report_engine/SPEC.md +28 -0
- package/core/report_engine/__init__.py +47 -0
- package/core/report_engine/attestation.py +224 -0
- package/core/report_engine/authority.py +255 -0
- package/core/report_engine/finding_report.py +417 -0
- package/core/report_engine/formal_report_builder.py +924 -0
- package/core/report_engine/html_renderers.py +696 -0
- package/core/report_engine/models.py +761 -0
- package/core/report_engine/pdf_exporter.py +231 -0
- package/core/report_engine/projects_assets.py +730 -0
- package/core/report_engine/report_client.py +743 -0
- package/core/report_engine/report_data_builder.py +388 -0
- package/core/report_engine/report_share.py +459 -0
- package/core/report_engine/sast_bridge.py +116 -0
- package/core/report_engine/server.py +822 -0
- package/core/report_engine/visual_report_builder.py +796 -0
- package/core/report_engine/web-conformance.md +63 -0
- package/core/report_engine/web_conformance.py +459 -0
- package/core/report_engine/workbench_assets.py +484 -0
- package/core/retrieval/INTERFACE.md +20 -0
- package/core/retrieval/README.md +161 -0
- package/core/retrieval/SPEC.md +25 -0
- package/core/retrieval/__init__.py +3 -0
- package/core/retrieval/code_analyzer.py +1684 -0
- package/core/retrieval/codebase_memory_bridge.py +337 -0
- package/core/retrieval/context_assembler.py +234 -0
- package/core/retrieval/corpus_fetch.py +369 -0
- package/core/retrieval/graph_ego.py +597 -0
- package/core/retrieval/knowledge_auto.py +662 -0
- package/core/retrieval/knowledge_sources.py +168 -0
- package/core/retrieval/knowledge_sync.py +909 -0
- package/core/retrieval/memory_store.py +480 -0
- package/core/retrieval/query_planner.py +1020 -0
- package/core/retrieval/rrf_engine.py +137 -0
- package/core/retrieval/slice_extractor.py +1209 -0
- package/core/retrieval/slice_normalizer.py +373 -0
- package/core/retrieval/slice_spec.py +357 -0
- package/core/retrieval/symbol_index.py +1132 -0
- package/core/retrieval/universal_code_matcher.py +437 -0
- package/core/retrieval/xerj_bridge.py +476 -0
- package/core/retrieval/xerj_supervisor.py +362 -0
- package/core/rules/README.md +33 -0
- package/core/rules/ios/PROVENANCE.json +30 -0
- package/core/rules/ios/crypto.yaml +36 -0
- package/core/rules/ios/network.yaml +20 -0
- package/core/rules/ios/resilience.yaml +47 -0
- package/core/rules/ios/storage.yaml +48 -0
- package/core/rules/mastg/LICENSE +173 -0
- package/core/rules/mastg/PROVENANCE.json +270 -0
- package/core/rules/mastg/mastg-android-asymmetric-key-pair-used-for-multiple-purposes.yml +13 -0
- package/core/rules/mastg/mastg-android-backup-manifest.yml +24 -0
- package/core/rules/mastg/mastg-android-biometric-event-bound.yml +49 -0
- package/core/rules/mastg/mastg-android-biometric-invalidated-enrollment.yml +11 -0
- package/core/rules/mastg/mastg-android-biometric-no-confirmation-required.yml +10 -0
- package/core/rules/mastg/mastg-android-biometric-validity-duration.yml +24 -0
- package/core/rules/mastg/mastg-android-broken-encryption-algorithms.yaml +9 -0
- package/core/rules/mastg/mastg-android-broken-encryption-modes.yaml +13 -0
- package/core/rules/mastg/mastg-android-content-provider-exported.yml +35 -0
- package/core/rules/mastg/mastg-android-custom-deeplink-scheme.yml +29 -0
- package/core/rules/mastg/mastg-android-dangerous-app-permissions.yaml +65 -0
- package/core/rules/mastg/mastg-android-data-unencrypted-shared-storage-no-user-interaction-apis.yml +36 -0
- package/core/rules/mastg/mastg-android-data-unencrypted-shared-storage-no-user-interaction-manifest.yml +15 -0
- package/core/rules/mastg/mastg-android-debuggable-flag.yml +10 -0
- package/core/rules/mastg/mastg-android-debugger-checks.yml +12 -0
- package/core/rules/mastg/mastg-android-deeplink-autoverify-missing.yml +33 -0
- package/core/rules/mastg/mastg-android-deeplink-unvalidated-parameter.yml +11 -0
- package/core/rules/mastg/mastg-android-device-passcode-present.yml +17 -0
- package/core/rules/mastg/mastg-android-fileprovider-broad-scope.yml +46 -0
- package/core/rules/mastg/mastg-android-hardcoded-crypto-keys-usage.yml +14 -0
- package/core/rules/mastg/mastg-android-hardcoded-security-provider.yaml +18 -0
- package/core/rules/mastg/mastg-android-implicit-intent-internal-communication.yml +30 -0
- package/core/rules/mastg/mastg-android-implicit-intent-leaking-extras.yml +29 -0
- package/core/rules/mastg/mastg-android-input-field-usage.yml +11 -0
- package/core/rules/mastg/mastg-android-key-generation-with-insufficient-key-length.yml +21 -0
- package/core/rules/mastg/mastg-android-keyboard-cache-input-types.yml +10 -0
- package/core/rules/mastg/mastg-android-local-storage-input-validation.yml +48 -0
- package/core/rules/mastg/mastg-android-native-debugger-checks.yml +12 -0
- package/core/rules/mastg/mastg-android-network-checkservertrusted.yml +12 -0
- package/core/rules/mastg/mastg-android-network-hostname-verification.yml +11 -0
- package/core/rules/mastg/mastg-android-network-insecure-trust-anchors.yml +11 -0
- package/core/rules/mastg/mastg-android-network-onreceivedsslerror.yml +12 -0
- package/core/rules/mastg/mastg-android-non-random-use.yml +16 -0
- package/core/rules/mastg/mastg-android-object-deserialization.yml +14 -0
- package/core/rules/mastg/mastg-android-overlay-protection.yml +68 -0
- package/core/rules/mastg/mastg-android-pendingintent-mutable.yml +39 -0
- package/core/rules/mastg/mastg-android-random-apis-insufficient-entropy.yml +17 -0
- package/core/rules/mastg/mastg-android-root-detection.yaml +59 -0
- package/core/rules/mastg/mastg-android-sdk-version.yml +10 -0
- package/core/rules/mastg/mastg-android-sensitive-data-in-notifications-manifest.yml +17 -0
- package/core/rules/mastg/mastg-android-sensitive-data-in-notifications.yml +11 -0
- package/core/rules/mastg/mastg-android-sensitive-data-in-screenshot.yml +18 -0
- package/core/rules/mastg/mastg-android-sql-injection-contentprovider.yml +17 -0
- package/core/rules/mastg/mastg-android-ssl-socket-hostnameverifier.yml +15 -0
- package/core/rules/mastg/mastg-android-strictmode.yml +10 -0
- package/core/rules/mastg/mastg-android-system-alert-window.yml +9 -0
- package/core/rules/mastg/mastg-android-webview-allow-local-access.yml +15 -0
- package/core/rules/mastg/mastg-android-webview-bridges.yml +28 -0
- package/core/rules/mastg/mastg-android-webview-safebrowsing.yml +20 -0
- package/core/rules/mastg/mastg-android-webview-url-handlers.yml +41 -0
- package/core/rules/miniprogram/PROVENANCE.json +26 -0
- package/core/rules/miniprogram/network.yaml +37 -0
- package/core/rules/miniprogram/platform.yaml +36 -0
- package/core/rules/miniprogram/storage.yaml +48 -0
- package/core/rules/mobsfscan-swift/LICENSE +165 -0
- package/core/rules/mobsfscan-swift/PROVENANCE.json +58 -0
- package/core/rules/mobsfscan-swift/auth.yaml +59 -0
- package/core/rules/mobsfscan-swift/crypto.yaml +66 -0
- package/core/rules/mobsfscan-swift/jailbreak.yaml +14 -0
- package/core/rules/mobsfscan-swift/keyboard.yaml +34 -0
- package/core/rules/mobsfscan-swift/logging.yaml +23 -0
- package/core/rules/mobsfscan-swift/network.yaml +55 -0
- package/core/rules/mobsfscan-swift/resilience.yaml +29 -0
- package/core/rules/mobsfscan-swift/secrets.yaml +33 -0
- package/core/rules/mobsfscan-swift/storage.yaml +29 -0
- package/core/rules/mobsfscan-swift/webview.yaml +32 -0
- package/core/runtime/README.md +198 -0
- package/core/runtime/__init__.py +3 -0
- package/core/runtime/bugx_logging.py +1393 -0
- package/core/runtime/daemon_runner.py +623 -0
- package/core/runtime/fixture_solidify.py +449 -0
- package/core/runtime/global_telemetry.py +549 -0
- package/core/runtime/incident_eval.py +148 -0
- package/core/runtime/interaction.py +605 -0
- package/core/runtime/interaction_store.py +435 -0
- package/core/runtime/interactive_menu.py +95 -0
- package/core/runtime/log_analytics.py +922 -0
- package/core/runtime/mining_quality_framework.py +1387 -0
- package/core/runtime/model_runner.py +769 -0
- package/core/runtime/platform_adapter.py +579 -0
- package/core/runtime/prep_validate.py +476 -0
- package/core/runtime/project_graph.py +827 -0
- package/core/runtime/project_init.py +481 -0
- package/core/runtime/project_profile.py +224 -0
- package/core/runtime/project_settings.py +963 -0
- package/core/runtime/provider_window.py +97 -0
- package/core/runtime/resume_ticket.py +115 -0
- package/core/runtime/scenario_eval.py +814 -0
- package/core/runtime/seed_drill.py +549 -0
- package/core/runtime/self_audit.py +550 -0
- package/core/runtime/session_profile.py +205 -0
- package/core/runtime/setup_ui_env.py +229 -0
- package/core/runtime/startup_environment.py +859 -0
- package/core/runtime/sync_store.py +1421 -0
- package/core/runtime/tool_install_targets.py +18 -0
- package/core/schemas/README.md +35 -0
- package/core/schemas/agent-graph.schema.json +368 -0
- package/core/schemas/attack-graph.schema.json +88 -0
- package/core/schemas/evidence-bundle.schema.json +33 -0
- package/core/schemas/skill-pack.schema.json +230 -0
- package/core/schemas/worker-checkpoint.schema.json +119 -0
- package/core/secure_atomic.py +289 -0
- package/core/seed_corpus/README.md +55 -0
- package/core/seed_corpus/c.txt +29 -0
- package/core/seed_corpus/cpp.txt +32 -0
- package/core/seed_corpus/css.txt +70 -0
- package/core/seed_corpus/go.txt +46 -0
- package/core/seed_corpus/java.txt +30 -0
- package/core/seed_corpus/javascript.txt +55 -0
- package/core/seed_corpus/kotlin.txt +28 -0
- package/core/seed_corpus/python.txt +71 -0
- package/core/seed_corpus/rust.txt +53 -0
- package/core/seed_corpus/swift.txt +29 -0
- package/core/seed_corpus/typescript.txt +29 -0
- package/core/skills/README.md +53 -0
- package/core/skills/__init__.py +189 -0
- package/core/skills/bugx_docs_mcp_server.py +416 -0
- package/core/skills/bugx_mcp_server.py +1134 -0
- package/core/skills/mcp_runtime.py +968 -0
- package/core/skills/mcp_session_proof.py +605 -0
- package/core/skills/mobile_ui_inspector.py +405 -0
- package/core/skills/skill_pack.py +1214 -0
- package/core/skills/skill_synthesizer.py +1153 -0
- package/core/skills/tools_kb.py +313 -0
- package/core/supervisor/INTERFACE.md +121 -0
- package/core/supervisor/README.md +209 -0
- package/core/supervisor/SPEC.md +25 -0
- package/core/supervisor/__init__.py +175 -0
- package/core/supervisor/audit_supervisor.py +1015 -0
- package/core/supervisor/budget_governor.py +760 -0
- package/core/supervisor/checkpoint_handler.py +368 -0
- package/core/supervisor/checkpoint_pipeline.py +1322 -0
- package/core/supervisor/checkpoint_sync.py +640 -0
- package/core/supervisor/claim_events.py +74 -0
- package/core/supervisor/claim_sync.py +590 -0
- package/core/supervisor/cli.py +812 -0
- package/core/supervisor/context_sync.py +55 -0
- package/core/supervisor/coverage_sync.py +115 -0
- package/core/supervisor/finding_commit.py +470 -0
- package/core/supervisor/finding_sync.py +688 -0
- package/core/supervisor/finding_workflow.py +659 -0
- package/core/supervisor/finish_policy.py +224 -0
- package/core/supervisor/finish_sync.py +185 -0
- package/core/supervisor/graph_sync.py +669 -0
- package/core/supervisor/lease_manager.py +788 -0
- package/core/supervisor/lifecycle_blocks.py +124 -0
- package/core/supervisor/next_round_sync.py +126 -0
- package/core/supervisor/observability.py +140 -0
- package/core/supervisor/recovery_sync.py +165 -0
- package/core/supervisor/rejection_remedies.py +308 -0
- package/core/supervisor/round_governor.py +306 -0
- package/core/supervisor/serial_authorization.py +500 -0
- package/core/supervisor/start_sync.py +87 -0
- package/core/supervisor/state_store.py +249 -0
- package/core/supervisor/supervisor_host.py +511 -0
- package/core/supervisor/supervisor_models.py +1143 -0
- package/core/supervisor/systemic_failure.py +104 -0
- package/core/supervisor/task_scheduler.py +1640 -0
- package/core/supervisor/worker_checkpoint.py +223 -0
- package/core/supervisor/worker_execution.py +265 -0
- package/core/supervisor/worker_handoff.py +192 -0
- package/core/supervisor/worker_lifecycle.py +396 -0
- package/core/supervisor/worker_runtime.py +999 -0
- package/core/supervisor/worker_sync.py +89 -0
- package/core/supervisor_types/README.md +36 -0
- package/core/supervisor_types/__init__.py +0 -0
- package/core/supervisor_types/exceptions.py +52 -0
- package/core/supervisor_types/graph_models.py +357 -0
- package/core/supervisor_types/path_containment.py +151 -0
- package/core/supervisor_types/target_fingerprint.py +310 -0
- package/core/supervisor_types/worker_claim.py +402 -0
- package/core/webui/INTERFACE.md +50 -0
- package/core/webui/README.md +57 -0
- package/core/webui/SPEC.md +25 -0
- package/core/webui/__init__.py +11 -0
- package/core/webui/adapters/__init__.py +27 -0
- package/core/webui/adapters/base.py +87 -0
- package/core/webui/adapters/bugx.py +102 -0
- package/core/webui/adapters/claude.py +218 -0
- package/core/webui/adapters/cline.py +399 -0
- package/core/webui/adapters/codex.py +256 -0
- package/core/webui/adapters/dsh.py +173 -0
- package/core/webui/adapters/opencode.py +218 -0
- package/core/webui/adapters/pi.py +272 -0
- package/core/webui/adapters/registry.py +100 -0
- package/core/webui/adapters/zcode.py +312 -0
- package/core/webui/api_routes_post.py +668 -0
- package/core/webui/dispatcher.py +1376 -0
- package/core/webui/docs_session_service.py +473 -0
- package/core/webui/handler.py +674 -0
- package/core/webui/ide_cloud_service.py +526 -0
- package/core/webui/mcp_inspector.py +1743 -0
- package/core/webui/static/assets/index-CXAsl8mr.js +333 -0
- package/core/webui/static/assets/index-DHQUtWtx.css +1 -0
- package/core/webui/static/assets/source-serif-4-cyrillic-400-normal-B8Z6Jvzv.woff +0 -0
- package/core/webui/static/assets/source-serif-4-cyrillic-400-normal-C44pakCn.woff2 +0 -0
- package/core/webui/static/assets/source-serif-4-cyrillic-500-normal-Bb4u56_6.woff +0 -0
- package/core/webui/static/assets/source-serif-4-cyrillic-500-normal-BdVUvljg.woff2 +0 -0
- package/core/webui/static/assets/source-serif-4-cyrillic-ext-400-normal-CWV284fw.woff2 +0 -0
- package/core/webui/static/assets/source-serif-4-cyrillic-ext-400-normal-DLkyKLvH.woff +0 -0
- package/core/webui/static/assets/source-serif-4-cyrillic-ext-500-normal-8-8HP2PF.woff +0 -0
- package/core/webui/static/assets/source-serif-4-cyrillic-ext-500-normal-DaDZE_Na.woff2 +0 -0
- package/core/webui/static/assets/source-serif-4-greek-400-normal-BccYJ-vZ.woff +0 -0
- package/core/webui/static/assets/source-serif-4-greek-400-normal-Cw5-AHNN.woff2 +0 -0
- package/core/webui/static/assets/source-serif-4-greek-500-normal-By8GFJzz.woff2 +0 -0
- package/core/webui/static/assets/source-serif-4-greek-500-normal-z-Q6FFuG.woff +0 -0
- package/core/webui/static/assets/source-serif-4-latin-400-normal-DJ5YJwmz.woff2 +0 -0
- package/core/webui/static/assets/source-serif-4-latin-400-normal-Dn3IlU-Z.woff +0 -0
- package/core/webui/static/assets/source-serif-4-latin-500-normal-CUHe9xxf.woff2 +0 -0
- package/core/webui/static/assets/source-serif-4-latin-500-normal-DVVamBqs.woff +0 -0
- package/core/webui/static/assets/source-serif-4-latin-ext-400-normal-CEpydyUl.woff +0 -0
- package/core/webui/static/assets/source-serif-4-latin-ext-400-normal-Cp7z-ARB.woff2 +0 -0
- package/core/webui/static/assets/source-serif-4-latin-ext-500-normal-BYjRCDVy.woff2 +0 -0
- package/core/webui/static/assets/source-serif-4-latin-ext-500-normal-D-qasQTj.woff +0 -0
- package/core/webui/static/assets/source-serif-4-vietnamese-400-normal-BbG3LG1A.woff2 +0 -0
- package/core/webui/static/assets/source-serif-4-vietnamese-400-normal-DR1UuFon.woff +0 -0
- package/core/webui/static/assets/source-serif-4-vietnamese-500-normal-8N8MYVKB.woff +0 -0
- package/core/webui/static/assets/source-serif-4-vietnamese-500-normal-Bi3OSTTW.woff2 +0 -0
- package/core/webui/static/favicon.png +0 -0
- package/core/webui/static/icon-192.png +0 -0
- package/core/webui/static/index.html +42 -0
- package/core/webui/static/manifest.webmanifest +19 -0
- package/core/webui/static/project-settings.css +6458 -0
- package/core/webui/static/project-settings.js +9602 -0
- package/core/webui/static/sw.js +8 -0
- package/core/webui/workspace_service.py +218 -0
- package/docs/07_distribution/01_README_NPM.md +281 -0
- package/docs/07_distribution/README.md +16 -0
- package/docs/README.md +121 -0
- package/ecosystem/README.md +129 -0
- package/ecosystem/integrations/README.md +38 -0
- package/ecosystem/integrations/cline/skills/bugx/SKILL.md +69 -0
- package/ecosystem/integrations/dsh/agents/bugx.md +27 -0
- package/ecosystem/integrations/dsh/dsh-patch.yml +18 -0
- package/ecosystem/integrations/dsh/mcp/cordis.patch.yml +4 -0
- package/ecosystem/integrations/dsh/mcp/index.js +219 -0
- package/ecosystem/integrations/dsh/mcp/package.json +28 -0
- package/ecosystem/integrations/dsh/skills/bugx/SKILL.md +70 -0
- package/ecosystem/integrations/dsh/skills/bugx-dsh/SKILL.md +229 -0
- package/ecosystem/integrations/dsh/ui/client.js +87 -0
- package/ecosystem/integrations/dsh/ui/cordis.patch.yml +4 -0
- package/ecosystem/integrations/dsh/ui/index.js +7 -0
- package/ecosystem/integrations/dsh/ui/package.json +27 -0
- package/ecosystem/integrations/opencode/bugx-mcp-manifest.json +53 -0
- package/ecosystem/integrations/opencode/mcp-lock.json +3067 -0
- package/ecosystem/integrations/opencode/opencode.json +118 -0
- package/ecosystem/integrations/pi/extensions/bugx/README.md +12 -0
- package/ecosystem/integrations/pi/extensions/bugx/index.ts +299 -0
- package/ecosystem/integrations/pi/extensions/bugx/manifest.json +11 -0
- package/ecosystem/integrations/pi/skills/bugx/SKILL.md +69 -0
- package/ecosystem/integrations/qoder/CONNECTORS.md +54 -0
- package/ecosystem/integrations/qoder/connector-meta.json +21 -0
- package/ecosystem/integrations/workbuddy/connector-meta.json +19 -0
- package/ecosystem/integrations/workbuddy/icon.png +0 -0
- package/ecosystem/integrations/workbuddy/skills/bugx/SKILL.md +70 -0
- package/ecosystem/plugins/README.md +37 -0
- package/ecosystem/plugins/bugx/.claude-plugin/marketplace.json +17 -0
- package/ecosystem/plugins/bugx/.claude-plugin/plugin.json +16 -0
- package/ecosystem/plugins/bugx/.codex-plugin/plugin.json +41 -0
- package/ecosystem/plugins/bugx/.zcode-plugin/plugin.json +19 -0
- package/ecosystem/plugins/bugx/agents/bugx-judge.md +71 -0
- package/ecosystem/plugins/bugx/agents/bugx-worker.md +31 -0
- package/ecosystem/plugins/bugx/agents/bugx.md +74 -0
- package/ecosystem/plugins/bugx/assets/bugx-avatar-512.png +0 -0
- package/ecosystem/plugins/bugx/skills/bugx/SKILL.md +118 -0
- package/ecosystem/plugins/bugx/skills/bugx-claude/SKILL.md +326 -0
- package/ecosystem/plugins/bugx/skills/bugx-dsh/SKILL.md +229 -0
- package/ecosystem/plugins/bugx/skills/bugx-opencode/SKILL.md +129 -0
- package/ecosystem/plugins/bugx/skills/bugx-zcode/SKILL.md +459 -0
- package/interfaces/README.md +143 -0
- package/interfaces/bin/README.md +35 -0
- package/interfaces/bin/bugx.js +80 -0
- package/interfaces/cli/README.md +90 -0
- package/interfaces/cli/bugx_cli/__init__.py +4 -0
- package/interfaces/cli/bugx_cli/cli.py +1678 -0
- package/interfaces/cli/bugx_cli/commands/__init__.py +1 -0
- package/interfaces/cli/bugx_cli/commands/advisory.py +94 -0
- package/interfaces/cli/bugx_cli/commands/agent.py +3944 -0
- package/interfaces/cli/bugx_cli/commands/audit.py +632 -0
- package/interfaces/cli/bugx_cli/commands/autonomous.py +260 -0
- package/interfaces/cli/bugx_cli/commands/cloud.py +1370 -0
- package/interfaces/cli/bugx_cli/commands/daemon.py +50 -0
- package/interfaces/cli/bugx_cli/commands/doctor.py +1345 -0
- package/interfaces/cli/bugx_cli/commands/goal.py +107 -0
- package/interfaces/cli/bugx_cli/commands/interaction.py +244 -0
- package/interfaces/cli/bugx_cli/commands/knowledge.py +617 -0
- package/interfaces/cli/bugx_cli/commands/lifecycle.py +2763 -0
- package/interfaces/cli/bugx_cli/commands/patch.py +1014 -0
- package/interfaces/cli/bugx_cli/commands/plugin.py +2714 -0
- package/interfaces/cli/bugx_cli/commands/plugin_claude.py +1446 -0
- package/interfaces/cli/bugx_cli/commands/plugin_cline.py +269 -0
- package/interfaces/cli/bugx_cli/commands/plugin_codex.py +74 -0
- package/interfaces/cli/bugx_cli/commands/plugin_funide.py +728 -0
- package/interfaces/cli/bugx_cli/commands/plugin_qoder.py +216 -0
- package/interfaces/cli/bugx_cli/commands/plugin_zcode.py +710 -0
- package/interfaces/cli/bugx_cli/commands/project.py +670 -0
- package/interfaces/cli/bugx_cli/commands/report.py +260 -0
- package/interfaces/cli/bugx_cli/commands/skill.py +251 -0
- package/interfaces/cli/bugx_cli/commands/stats.py +133 -0
- package/interfaces/cli/bugx_cli/commands/system.py +2567 -0
- package/interfaces/cli/bugx_cli/common.py +898 -0
- package/interfaces/cli/bugx_cli/host_adapters.py +1917 -0
- package/interfaces/cli/bugx_cli/hosts/__init__.py +80 -0
- package/interfaces/cli/bugx_cli/hosts/base.py +99 -0
- package/interfaces/cli/bugx_cli/hosts/registry.py +571 -0
- package/interfaces/cli/bugx_cli/hosts/template_engine.py +188 -0
- package/interfaces/cli/bugx_cli/infra/__init__.py +209 -0
- package/interfaces/cli/bugx_cli/infra/ai_advisor.py +721 -0
- package/interfaces/cli/bugx_cli/infra/engine_installer.py +1937 -0
- package/interfaces/cli/bugx_cli/infra/host_sync.py +545 -0
- package/interfaces/cli/bugx_cli/infra/mcp_advisor.py +755 -0
- package/interfaces/cli/bugx_cli/infra/security.py +332 -0
- package/package.json +98 -4
- package/pyproject.toml +246 -0
- package/scripts/README.md +118 -0
- package/scripts/ensure-python.mjs +97 -0
- package/scripts/isolate-npm-readme.mjs +40 -0
- package/scripts/runtime.lock.json +31 -0
- package/scripts/sync-version.mjs +37 -0
- package/scripts/test-npm-wrapper.mjs +265 -0
|
@@ -0,0 +1,710 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""src/bugx_cli/commands/plugin_zcode.py - ZCode 插件与用户级智能体适配命令 (DOC-072)。"""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import argparse
|
|
7
|
+
import json
|
|
8
|
+
import os
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
from typing import Any
|
|
11
|
+
|
|
12
|
+
from .. import __version__
|
|
13
|
+
from ..host_adapters import (
|
|
14
|
+
ZCODE_WORKER_INSTALL_PATH,
|
|
15
|
+
get_adapter,
|
|
16
|
+
render_zcode_worker_entry,
|
|
17
|
+
)
|
|
18
|
+
from ..common import (
|
|
19
|
+
CHATGPT_PLUGIN_NAME,
|
|
20
|
+
CliError,
|
|
21
|
+
asset_root,
|
|
22
|
+
global_engine_root,
|
|
23
|
+
_assert_no_symlink_components,
|
|
24
|
+
_atomic_write_global_file,
|
|
25
|
+
_backup_host_resource,
|
|
26
|
+
_i18n_exc,
|
|
27
|
+
_i18n_prompt,
|
|
28
|
+
_remove_empty_parents,
|
|
29
|
+
_resolve_locale_name,
|
|
30
|
+
_resolve_plugin_version,
|
|
31
|
+
_write_host_resource,
|
|
32
|
+
strip_locale_marker,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# ZCode 官方规范(plugin-creator plugin-json-spec)要求 icon 必须是「可达的
|
|
37
|
+
# HTTPS URL;资产缺失时宁可省略也不得伪造」。此前硬编码的
|
|
38
|
+
# raw.githubusercontent.com/bencibro/bug-hunter 镜像地址不成立:本仓库托管在
|
|
39
|
+
# 私有 Gitea(gitea.sp.dev,且仅 LAN 可达),GitHub 上并无该资产,实测 404,
|
|
40
|
+
# ZCode 渲染器加载失败后回退为通用拼图图标。brand-mark.svg 是 bugx.dev 常驻
|
|
41
|
+
# 的 512×512 官方品牌图标(Cloudflare 分发、content-type 正确),作为插件
|
|
42
|
+
# 图标的权威来源;如后续把 bugx-avatar-512.png 上架官网,只需替换本常量。
|
|
43
|
+
ZCODE_PLUGIN_ICON_URL = "https://bugx.dev/brand-mark.svg"
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def _zcode_plugin_manifest(version: str = __version__) -> dict[str, object]:
|
|
47
|
+
"""ZCode 插件清单:声明 ZCode 插件元数据与图标。
|
|
48
|
+
|
|
49
|
+
ZCode 在 ``.zcode-plugin/plugin.json`` 中按目录名加载 ``agents`` 与
|
|
50
|
+
``skills`` 等组件字段;当前镜像贡献主审计 agent 与并发 worker 子智能体。
|
|
51
|
+
UI 渲染器根据 ``icon`` / ``listing.icon`` (https:// 格式) 显示自定义图标。
|
|
52
|
+
"""
|
|
53
|
+
icon_url = ZCODE_PLUGIN_ICON_URL
|
|
54
|
+
return {
|
|
55
|
+
"name": CHATGPT_PLUGIN_NAME,
|
|
56
|
+
"version": version,
|
|
57
|
+
"description": "Autonomous code review and vulnerability hunting agent that uncovers, reproduces, and fixes deep bugs.",
|
|
58
|
+
"homepage": "https://bugx.dev",
|
|
59
|
+
"author": {
|
|
60
|
+
"name": "BugX",
|
|
61
|
+
"url": "https://bugx.dev",
|
|
62
|
+
},
|
|
63
|
+
"source": "local",
|
|
64
|
+
"icon": icon_url,
|
|
65
|
+
"listing": {
|
|
66
|
+
"displayName": "BugX",
|
|
67
|
+
"icon": icon_url,
|
|
68
|
+
"category": "developer-tools",
|
|
69
|
+
},
|
|
70
|
+
"agents": "agents",
|
|
71
|
+
"skills": "skills",
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def _zcode_plugin_boundary_section(agent_ref: str, *, locale: str | None = None) -> str:
|
|
76
|
+
"""插件形态入口共用的用户级边界段;agent_ref 为插件内的完整 agent 命名。"""
|
|
77
|
+
loc = _resolve_locale_name(locale)
|
|
78
|
+
boundary = _i18n_prompt(
|
|
79
|
+
"plugin.zcode_plugin_boundary",
|
|
80
|
+
"## 用户级插件边界(插件形态专用)\n\n"
|
|
81
|
+
f"本入口以 ZCode 插件(agent 命名 `{agent_ref}`)注册,可跨项目使用。"
|
|
82
|
+
"协议由全局引擎通过 `bugx engine path --name bugx-runtime-contract.md` 提供。"
|
|
83
|
+
"操作项目前先运行只读命令 `bugx engine --root . status --json`:仅当返回 `UNINITIALIZED` 时,"
|
|
84
|
+
"才运行 `bugx engine --root . pre` 安全准备新项目。返回 `FATAL_BLOCKED`、其他阻断状态或检查失败时,"
|
|
85
|
+
"保留数据并停止,严禁用 `bugx init`、`bugx reset` 或 `--force` 绕过。"
|
|
86
|
+
"Worker 子智能体遇到布局缺失时只向派发方报告,不得自行运行主控初始化命令;本入口不能替代全局引擎载荷。\n",
|
|
87
|
+
locale=loc,
|
|
88
|
+
agent_ref=agent_ref,
|
|
89
|
+
)
|
|
90
|
+
return "\n\n" + boundary.rstrip() + "\n"
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def _zcode_plugin_agent_content(source: Path, *, locale: str | None = None) -> str:
|
|
94
|
+
"""插件形态的 ZCode Agent 入口:项目级入口 + 用户级插件边界段。"""
|
|
95
|
+
loc = _resolve_locale_name(locale)
|
|
96
|
+
entry = get_adapter("zcode").render(source, locale=loc)
|
|
97
|
+
return entry.rstrip("\n") + _zcode_plugin_boundary_section("bugx:bugx", locale=loc)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def _zcode_plugin_worker_content(*, locale: str | None = None) -> str:
|
|
101
|
+
"""插件形态的 ZCode 并发 worker 子智能体入口。
|
|
102
|
+
|
|
103
|
+
与项目级 worker 入口同源(render_zcode_worker_entry),仅追加用户级
|
|
104
|
+
插件边界段;跨项目派发时 agent 命名为 `bugx:bugx-worker`。
|
|
105
|
+
"""
|
|
106
|
+
loc = _resolve_locale_name(locale)
|
|
107
|
+
entry = render_zcode_worker_entry(locale=loc)
|
|
108
|
+
return entry.rstrip("\n") + _zcode_plugin_boundary_section("bugx:bugx-worker", locale=loc)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def _zcode_storage_dir_override() -> Path:
|
|
112
|
+
"""解析 ZCode 的 storage.dir(桌面端 bootstrap 的 storageRoot)。
|
|
113
|
+
|
|
114
|
+
默认 ``~/.zcode``;可在宿主配置 ``storage.dir`` 中覆盖(``~/`` 前缀按
|
|
115
|
+
HOME 展开,与 ZCode 自身的 ws() 语义一致)。依次探测 CLI 与 v2 配置,
|
|
116
|
+
都未设置时返回默认值。
|
|
117
|
+
"""
|
|
118
|
+
home = Path.home()
|
|
119
|
+
for config_path in (
|
|
120
|
+
home / ".zcode" / "cli" / "config.json",
|
|
121
|
+
home / ".zcode" / "v2" / "config.json",
|
|
122
|
+
):
|
|
123
|
+
try:
|
|
124
|
+
if config_path.is_symlink() or not config_path.is_file():
|
|
125
|
+
continue
|
|
126
|
+
payload = json.loads(config_path.read_text(encoding="utf-8"))
|
|
127
|
+
except (OSError, json.JSONDecodeError):
|
|
128
|
+
continue
|
|
129
|
+
storage = payload.get("storage") if isinstance(payload, dict) else None
|
|
130
|
+
raw = storage.get("dir") if isinstance(storage, dict) else None
|
|
131
|
+
if isinstance(raw, str) and raw.strip():
|
|
132
|
+
raw = raw.strip()
|
|
133
|
+
if raw.startswith("~/"):
|
|
134
|
+
return home / raw[2:]
|
|
135
|
+
if raw.startswith("/"):
|
|
136
|
+
return Path(raw)
|
|
137
|
+
return home / ".zcode"
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def _zcode_user_agents_dir() -> Path:
|
|
141
|
+
"""ZCode 用户级子智能体目录(storageRoot/agents,默认 ``~/.zcode/agents``)。
|
|
142
|
+
|
|
143
|
+
桌面端 bootstrap 以 ``storage.dir/agents`` 为 user 作用域扫描根,
|
|
144
|
+
Settings → Subagents 直接展示;``~/.zcode/cli/agents`` 只是子智能体
|
|
145
|
+
运行输出目录(sess_* 工作区),不是注册面。
|
|
146
|
+
"""
|
|
147
|
+
return _zcode_storage_dir_override() / "agents"
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def _zcode_user_skills_dir() -> Path:
|
|
151
|
+
"""ZCode 用户级 Skill 目录(storageRoot/skills,默认 ``~/.zcode/skills``)。
|
|
152
|
+
|
|
153
|
+
与 agents 同层(storage.dir 可覆盖);ZCode 以目录名作 skill 名发现
|
|
154
|
+
(``<dir>/<skill-name>/SKILL.md``)。
|
|
155
|
+
"""
|
|
156
|
+
return _zcode_storage_dir_override() / "skills"
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def _zcode_usage_skill_path(root: Path, source: Path) -> Path:
|
|
160
|
+
"""定位 bugx-zcode 使用手册 Skill 的唯一权威源。
|
|
161
|
+
|
|
162
|
+
该 Skill 跟随宿主插件一起分发,源码维护于
|
|
163
|
+
``plugins/bugx/skills/bugx-zcode/SKILL.md``;``source`` 为引擎载荷根
|
|
164
|
+
(``asset_root()``,即 wheel 内的 ``share/bugx-agent/core``),其同级
|
|
165
|
+
``plugins/bugx/`` 即同一插件包的打包副本。源码仓库开发态下
|
|
166
|
+
``root/plugins/bugx/`` 为同一文件,作为兜底。
|
|
167
|
+
"""
|
|
168
|
+
candidates = (
|
|
169
|
+
source.parent / "plugins" / "bugx" / "skills" / "bugx-zcode" / "SKILL.md",
|
|
170
|
+
root / "ecosystem" / "plugins" / "bugx" / "skills" / "bugx-zcode" / "SKILL.md",
|
|
171
|
+
root / "plugins" / "bugx" / "skills" / "bugx-zcode" / "SKILL.md",
|
|
172
|
+
)
|
|
173
|
+
for candidate in candidates:
|
|
174
|
+
if not candidate.is_symlink() and candidate.is_file():
|
|
175
|
+
return candidate
|
|
176
|
+
return candidates[0]
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
def _ensure_zcode_user_skill(root: Path, source: Path) -> dict[str, object]:
|
|
180
|
+
"""把 bugx-zcode 使用手册 Skill 写入 ZCode 用户级 skills 目录。
|
|
181
|
+
|
|
182
|
+
与 :func:`_ensure_zcode_user_agents` 同分层(全局层产物,跨项目可见)、
|
|
183
|
+
同纪律:符号链接拒绝、内容一致即 unchanged、已有文件先备份、原子写。
|
|
184
|
+
内容源为宿主插件包内的 ``plugins/bugx/skills/bugx-zcode/SKILL.md``
|
|
185
|
+
(wheel 载荷 ``share/bugx-agent/plugins/bugx/skills/bugx-zcode/SKILL.md``),
|
|
186
|
+
随插件版本演进而非本地手工副本——新环境 ``bugx install --agent zcode``
|
|
187
|
+
即获得。
|
|
188
|
+
"""
|
|
189
|
+
skill_source = _zcode_usage_skill_path(root, source)
|
|
190
|
+
if skill_source.is_symlink() or not skill_source.is_file():
|
|
191
|
+
# 增强件语义:旧 wheel 载荷没有该资产时跳过部署(不阻塞安装),
|
|
192
|
+
# 升级到携带资产的新 wheel 后自动生效。
|
|
193
|
+
return {
|
|
194
|
+
"dir": str(_zcode_user_skills_dir()),
|
|
195
|
+
"written": [],
|
|
196
|
+
"backups": [],
|
|
197
|
+
"status": "skipped_missing_source",
|
|
198
|
+
}
|
|
199
|
+
skills_dir = _zcode_user_skills_dir()
|
|
200
|
+
if skills_dir.is_symlink():
|
|
201
|
+
raise CliError(_i18n_exc(
|
|
202
|
+
"plugin.zcode_symlink_skills_dir",
|
|
203
|
+
f"拒绝写入符号链接 ZCode 用户级 skills 目录: {skills_dir}",
|
|
204
|
+
skills_dir=skills_dir,
|
|
205
|
+
))
|
|
206
|
+
target = skills_dir / "bugx-zcode" / "SKILL.md"
|
|
207
|
+
if target.is_symlink():
|
|
208
|
+
raise CliError(_i18n_exc(
|
|
209
|
+
"plugin.zcode_symlink_skill_refused",
|
|
210
|
+
f"拒绝覆盖符号链接 ZCode 用户级 Skill: {target}",
|
|
211
|
+
target=target,
|
|
212
|
+
))
|
|
213
|
+
payload = skill_source.read_bytes()
|
|
214
|
+
if target.is_file() and target.read_bytes() == payload:
|
|
215
|
+
return {
|
|
216
|
+
"dir": str(skills_dir),
|
|
217
|
+
"written": [{
|
|
218
|
+
"path": str(target), "status": "unchanged",
|
|
219
|
+
"backup": None, "created": False,
|
|
220
|
+
}],
|
|
221
|
+
"backups": [],
|
|
222
|
+
}
|
|
223
|
+
backup = _backup_host_resource(root, "zcode", target) if target.exists() else None
|
|
224
|
+
backups = [backup] if backup is not None else []
|
|
225
|
+
target.parent.mkdir(parents=True, exist_ok=True)
|
|
226
|
+
_atomic_write_global_file(target, payload)
|
|
227
|
+
return {
|
|
228
|
+
"dir": str(skills_dir),
|
|
229
|
+
"written": [{
|
|
230
|
+
"path": str(target),
|
|
231
|
+
"status": "created" if backup is None else "upgraded",
|
|
232
|
+
"backup": str(backup) if backup is not None else None,
|
|
233
|
+
"created": backup is None,
|
|
234
|
+
}],
|
|
235
|
+
"backups": backups,
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
def _zcode_user_agent_boundary(*, locale: str | None = None) -> str:
|
|
240
|
+
"""用户级子智能体入口共用的跨项目边界段。"""
|
|
241
|
+
loc = _resolve_locale_name(locale)
|
|
242
|
+
boundary = _i18n_prompt(
|
|
243
|
+
"plugin.zcode_user_agent_boundary",
|
|
244
|
+
"## 用户级子智能体边界(用户级形态专用)\n\n"
|
|
245
|
+
"本入口安装为 ZCode 用户级子智能体(`~/.zcode/agents/`,"
|
|
246
|
+
"Settings → Subagents 全项目可见),可跨项目使用。"
|
|
247
|
+
"操作项目前先运行只读命令 `bugx engine --root . status --json`:仅当返回 `UNINITIALIZED` 时,"
|
|
248
|
+
"才运行 `bugx engine --root . pre` 安全准备新项目。返回 `FATAL_BLOCKED`、其他阻断状态或检查失败时,"
|
|
249
|
+
"保留数据并停止,严禁用 `bugx init`、`bugx reset` 或 `--force` 绕过。"
|
|
250
|
+
"Worker 子智能体遇到布局缺失时只向派发方报告,不得自行运行主控初始化命令;本入口不能替代全局引擎载荷。\n",
|
|
251
|
+
locale=loc,
|
|
252
|
+
)
|
|
253
|
+
return "\n\n" + boundary.rstrip() + "\n"
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
def _zcode_user_agent_content_main(source: Path, *, locale: str | None = None) -> str:
|
|
257
|
+
"""用户级主审计子智能体入口:项目级渲染 + 用户级边界段。"""
|
|
258
|
+
loc = _resolve_locale_name(locale)
|
|
259
|
+
entry = get_adapter("zcode").render(source, locale=loc)
|
|
260
|
+
return entry.rstrip("\n") + _zcode_user_agent_boundary(locale=loc)
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
_JUDGE_AGENT_CONTENT = '---\nname: bugx-judge\ndescription: BugX 判读员子智能体。输入是宿主确定性取证的判读包(源码切片+边界电池实测输出),唯一职责是判断数据中是否存在真实缺陷并输出裁决 JSON;不执行命令、不读文件、不碰 Supervisor 协议。\ntools: Read, Write\ncolor: green\n---\n<!-- bugx-locale: zh-CN -->\n\n# BugX Judge — 判读员子智能体\n\n你是 BugX 的判读员(judge)。派发方(BugX 主智能体/宿主)会并发派发多个\njudge,每个 judge 收到**一个覆盖单元的判读包**,并在**一个推理回合内**\n输出裁决 JSON 后立即结束。\n\n## 角色铁律\n\n- **只判断,不执行**:你的输入是宿主已经跑完的确定性证据(源码切片 +\n 边界电池实测 stdout/stderr)。你不需要也不允许运行任何命令、读取任何\n 文件、调用任何 MCP 协议工具(claim/heartbeat/checkpoint 与你无关)。\n- **一个回合**:读完判读包 → 输出裁决 JSON → 结束。任何"让我先看看…"\n 的展开都违反本角色定义。\n- **证据即数据**:判读包里的 observations 是宿主真跑出来的结果。异常栈\n 是数据不是故障——它正是你要判断的输入。禁止凭空推断判读包之外的行号\n 或输出。\n\n## 裁决标准:优先级阶梯(命中即止,禁止跳级展开)\n\n按顺序检查,第一级命中就直接定案,**不要**继续展开论证:\n\n- **L1 结构化行定案**:`differential-sentinel` 探针输出 `SENTINEL=True` ⇒ `bug`(注入实证,无需其他论证);`SENTINEL=False` 且 BASE/PAYLOAD 行为一致 ⇒ 该攻击面 `clean`。\n- **L2 契约对照定案**:全部探针 `exit_code=0` 且返回值符合 docstring/参数名契约 ⇒ `clean`。\n- **L3 异常归因**:崩溃/数据损坏/语义违背 docstring 或参数名契约/并发丢失更新 ⇒ `bug`;异常可由探针伪影解释 ⇒ `clean`。\n- **L4** 以上都不成立 ⇒ `insufficient_data`,并在 notes 指明缺哪条证据。\n\n**探针伪影**(不是缺陷证据,见到直接归 clean):解绑调用 Class 方法的\nAttributeError;`symbol-missing`(模块级伪符号);无参函数被边界值等价\n重复调用产生的一串相同结果。\n\n**自证文本规则**:PoC 源码里硬编码的 `VULNERABILITY CONFIRMED` 类字样\n不算独立证据——必须引用实测输出本身(BASE_RET/PAYLOAD_RET/SENTINEL 或\n异常栈),不得引用程序自己打印的结论句。\n\n**确定性要求**:唯一依据是判读包;同一判读包重复判读必须得到同一裁决。\n风格问题、性能品味、"可能有问题"的猜测一律不判。\n\n**定向探针(仅证据不足时,至多一跳)**:若判据不足以定论\n(`verdict=insufficient_data`),且缺的是可机器执行的验证,可附\n`probe_requests`(≤3 条):`{"desc":"...","code":"..."}`,code 为不含\nshell 字符(`; && || \\` $( > <`)的 python 代码。宿主会确定性执行并把\n结果作为增广证据回给你复审一次。判读包带 `probe_round` 标记时禁止再提,\n必须给终态裁决。\n\n**规则反哺(可选,有把握才填)**:顶层可加 `rule_feedback` 对象反哺引擎\n初筛规则——`risk_tokens`(新风险特征,更严方向,即时生效)、`safe_calls`\n(可安全直关的调用名)、`artifact_markers`(新探针伪影标记)。后两类属\n更松方向,需独立出现 ≥3 次才生效。各 ≤5 项,字符串 4–64 字符。\n\n## 输出格式(唯一输出,无其他文字)\n\n```json\n{"unit_id":"<原样返回判读包的 unit_id>","verdict":"clean|bug|insufficient_data",\n "findings":[{"fingerprint":"<file>::<symbol>::<短slug>","title":"...",\n "severity":"low|medium|high","root_cause":"...(引用 observations 中的具体证据)",\n "evidence":[{"path":"<file>","line":<源码切片中的真实行号>}],\n "reproduction":"python3 -c \'...\'(可直接执行,可改写自 observations 中已验证的探针)"}],\n "notes":"<=200字"}\n```\n\n- `verdict=clean` 时 `findings` 为空数组。\n- `reproduction` 必须是一条可直接执行的 python3 命令,宿主会真跑它生成\n 收据;把说明文字拼进命令会导致整条 finding 被丢弃。\n'
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
def _zcode_user_agent_content_judge(*, locale: str | None = None) -> str:
|
|
267
|
+
"""用户级判读员子智能体(DOC-250):判读包进、裁决 JSON 出。"""
|
|
268
|
+
return _JUDGE_AGENT_CONTENT
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
def _zcode_user_agent_content_worker(*, locale: str | None = None) -> str:
|
|
272
|
+
"""用户级并发 worker 子智能体入口:项目级渲染 + 用户级边界段。"""
|
|
273
|
+
loc = _resolve_locale_name(locale)
|
|
274
|
+
entry = render_zcode_worker_entry(locale=loc)
|
|
275
|
+
return entry.rstrip("\n") + _zcode_user_agent_boundary(locale=loc)
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
def _sweep_legacy_zcode_project_entries(
|
|
279
|
+
root: Path, main_entry_rendered: str,
|
|
280
|
+
) -> tuple[list[str], list[Path]]:
|
|
281
|
+
"""安装期清扫旧版本写入的项目级 ZCode 子智能体副本。
|
|
282
|
+
|
|
283
|
+
ZCode 桌面端 Settings → Subagents 以名字合并 user/workspace 作用域且
|
|
284
|
+
项目级同名副本胜出(宿主 list() 先 user 后 workspace 依次覆盖),
|
|
285
|
+
项目级 `.zcode/agents/bugx*.md` 会把同名的用户级条目遮蔽出"用户级"
|
|
286
|
+
列表(0.7.22 实机验证)。0.7.18 及之前版本写过项目级主/worker 入口;
|
|
287
|
+
仅当文件内容与当前模板渲染逐字一致(locale 标记归一后)才认定为
|
|
288
|
+
BugX 自有并删除(先备份),有出入一律保留交由人工处理。
|
|
289
|
+
"""
|
|
290
|
+
swept: list[str] = []
|
|
291
|
+
backups: list[Path] = []
|
|
292
|
+
zcode_adapter = get_adapter("zcode")
|
|
293
|
+
candidates: list[tuple[str, str]] = [
|
|
294
|
+
(zcode_adapter.install_path, main_entry_rendered),
|
|
295
|
+
(ZCODE_WORKER_INSTALL_PATH, render_zcode_worker_entry(locale="zh-CN")),
|
|
296
|
+
(ZCODE_WORKER_INSTALL_PATH, render_zcode_worker_entry(locale="en-US")),
|
|
297
|
+
]
|
|
298
|
+
engine_desc = global_engine_root() / "bugx.md"
|
|
299
|
+
if not engine_desc.is_file():
|
|
300
|
+
engine_desc = asset_root() / "bugx.md"
|
|
301
|
+
if engine_desc.is_file():
|
|
302
|
+
for loc in ("zh-CN", "en-US"):
|
|
303
|
+
try:
|
|
304
|
+
candidates.append((zcode_adapter.install_path, zcode_adapter.render(engine_desc, locale=loc)))
|
|
305
|
+
except Exception:
|
|
306
|
+
pass
|
|
307
|
+
for relative, rendered in candidates:
|
|
308
|
+
target = root / relative
|
|
309
|
+
if target.is_symlink() or not target.is_file():
|
|
310
|
+
continue
|
|
311
|
+
try:
|
|
312
|
+
current = target.read_text(encoding="utf-8")
|
|
313
|
+
except (OSError, UnicodeDecodeError):
|
|
314
|
+
continue
|
|
315
|
+
if strip_locale_marker(current) != strip_locale_marker(rendered):
|
|
316
|
+
continue
|
|
317
|
+
backup = _backup_host_resource(root, "zcode", target)
|
|
318
|
+
if backup is not None:
|
|
319
|
+
backups.append(backup)
|
|
320
|
+
target.unlink()
|
|
321
|
+
swept.append(relative)
|
|
322
|
+
if swept:
|
|
323
|
+
_remove_empty_parents(root, swept)
|
|
324
|
+
return swept, backups
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
def _ensure_zcode_user_agents(
|
|
328
|
+
root: Path, source: Path, *, locale: str | None = None,
|
|
329
|
+
) -> dict[str, object]:
|
|
330
|
+
"""把主/worker 子智能体写入 ZCode 用户级 agents 目录。
|
|
331
|
+
|
|
332
|
+
与用户级 MCP 注册同一分层:这是全局层产物,使 BugX 在任何项目打开
|
|
333
|
+
ZCode 时 Settings → Subagents 均可见。项目作用域不再写同名副本:
|
|
334
|
+
宿主按名字合并各作用域时项目级胜出,双写会把用户级条目遮蔽出
|
|
335
|
+
"用户级"列表(0.7.22 起主/worker 均收敛为仅用户级 + 插件镜像)。
|
|
336
|
+
返回与 `_write_host_mcp_config` 一致的逐文件状态,供安装事务回滚
|
|
337
|
+
与输出。
|
|
338
|
+
"""
|
|
339
|
+
agents_dir = _zcode_user_agents_dir()
|
|
340
|
+
if agents_dir.is_symlink():
|
|
341
|
+
raise CliError(_i18n_exc("plugin.zcode_symlink_agents_dir", f"拒绝写入符号链接 ZCode 用户级 agents 目录: {agents_dir}", agents_dir=agents_dir))
|
|
342
|
+
generated = {
|
|
343
|
+
"bugx.md": _zcode_user_agent_content_main(source, locale=locale),
|
|
344
|
+
"bugx-worker.md": _zcode_user_agent_content_worker(locale=locale),
|
|
345
|
+
"bugx-judge.md": _zcode_user_agent_content_judge(locale=locale),
|
|
346
|
+
}
|
|
347
|
+
written: list[dict[str, object]] = []
|
|
348
|
+
backups: list[Path] = []
|
|
349
|
+
for filename, content in generated.items():
|
|
350
|
+
target = agents_dir / filename
|
|
351
|
+
payload = content.encode("utf-8")
|
|
352
|
+
if target.is_symlink():
|
|
353
|
+
raise CliError(_i18n_exc("plugin.zcode_symlink_agent_refused", f"拒绝覆盖符号链接 ZCode 用户级子智能体: {target}", target=target))
|
|
354
|
+
if target.is_file() and target.read_bytes() == payload:
|
|
355
|
+
written.append({
|
|
356
|
+
"path": str(target), "status": "unchanged",
|
|
357
|
+
"backup": None, "created": False,
|
|
358
|
+
})
|
|
359
|
+
continue
|
|
360
|
+
backup = _backup_host_resource(root, "zcode", target) if target.exists() else None
|
|
361
|
+
if backup is not None:
|
|
362
|
+
backups.append(backup)
|
|
363
|
+
_atomic_write_global_file(target, payload)
|
|
364
|
+
written.append({
|
|
365
|
+
"path": str(target),
|
|
366
|
+
"status": "created" if backup is None else "upgraded",
|
|
367
|
+
"backup": str(backup) if backup is not None else None,
|
|
368
|
+
"created": backup is None,
|
|
369
|
+
})
|
|
370
|
+
return {
|
|
371
|
+
"dir": str(agents_dir),
|
|
372
|
+
"written": written,
|
|
373
|
+
"backups": backups,
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
def _ensure_plugin_gitignored(root: Path, plugin_root: Path) -> None:
|
|
378
|
+
"""把安装器自产插件包自声明进项目 .gitignore(幂等、宽容失败)。
|
|
379
|
+
|
|
380
|
+
插件包(``plugins/bugx/``)是引擎可再生工件而非产品材料;不声明会让
|
|
381
|
+
覆盖发现把它当审计单元(实测首轮审计的 self-pollution)。幂等:已有
|
|
382
|
+
精确匹配行即跳过;.gitignore 不可写时静默放弃——发现层对该路径另有
|
|
383
|
+
指纹排除兜底,不因忽略声明失败而阻断安装。
|
|
384
|
+
"""
|
|
385
|
+
entry = plugin_root.relative_to(root).as_posix().rstrip("/") + "/"
|
|
386
|
+
gitignore = root / ".gitignore"
|
|
387
|
+
try:
|
|
388
|
+
existing = gitignore.read_text(encoding="utf-8") if gitignore.is_file() else ""
|
|
389
|
+
lines = {line.strip() for line in existing.splitlines()}
|
|
390
|
+
if entry in lines:
|
|
391
|
+
return
|
|
392
|
+
block = existing
|
|
393
|
+
if block and not block.endswith("\n"):
|
|
394
|
+
block += "\n"
|
|
395
|
+
block += (
|
|
396
|
+
"\n# BugX engine-generated plugin package (auto-declared by bugx install)\n"
|
|
397
|
+
f"{entry}\n"
|
|
398
|
+
)
|
|
399
|
+
gitignore.write_text(block, encoding="utf-8")
|
|
400
|
+
except OSError:
|
|
401
|
+
return
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
def _ensure_zcode_plugin(
|
|
405
|
+
root: Path, source: Path, *, locale: str | None = None,
|
|
406
|
+
) -> dict[str, object]:
|
|
407
|
+
"""生成 ZCode 本地插件包(清单 + 主 agent + worker 子智能体 + 使用手册),不登记全局状态。
|
|
408
|
+
|
|
409
|
+
ZCode 通过 Settings → Plugin Management 以本地目录/Git 源添加插件;
|
|
410
|
+
BugX 只准备标准插件目录,不写用户级插件登记文件。使用手册 Skill
|
|
411
|
+
随插件包同址生成(``skills/bugx-zcode/``),与全局插件实体保持同构。
|
|
412
|
+
"""
|
|
413
|
+
root = root.resolve()
|
|
414
|
+
plugin_root = root / "plugins" / CHATGPT_PLUGIN_NAME
|
|
415
|
+
manifest_path = plugin_root / ".zcode-plugin" / "plugin.json"
|
|
416
|
+
agent_path = plugin_root / "agents" / "bugx.md"
|
|
417
|
+
worker_agent_path = plugin_root / "agents" / "bugx-worker.md"
|
|
418
|
+
usage_skill_path = plugin_root / "skills" / "bugx-zcode" / "SKILL.md"
|
|
419
|
+
for path in (plugin_root, root / "plugins"):
|
|
420
|
+
if path.is_symlink():
|
|
421
|
+
raise CliError(_i18n_exc("plugin.zcode_symlink_plugin_path", f"拒绝写入符号链接 ZCode Plugin 路径: {path}", path=path))
|
|
422
|
+
|
|
423
|
+
plugin_version = _resolve_plugin_version(root, __version__)
|
|
424
|
+
generated = {
|
|
425
|
+
manifest_path: json.dumps(
|
|
426
|
+
_zcode_plugin_manifest(version=plugin_version), ensure_ascii=False, indent=2,
|
|
427
|
+
) + "\n",
|
|
428
|
+
agent_path: _zcode_plugin_agent_content(source, locale=locale),
|
|
429
|
+
worker_agent_path: _zcode_plugin_worker_content(locale=locale),
|
|
430
|
+
}
|
|
431
|
+
usage_skill = _zcode_usage_skill_path(root, source)
|
|
432
|
+
if usage_skill.is_file() and usage_skill != usage_skill_path:
|
|
433
|
+
generated[usage_skill_path] = usage_skill.read_text(encoding="utf-8")
|
|
434
|
+
copied = skipped = 0
|
|
435
|
+
backups: list[Path] = []
|
|
436
|
+
for target, content in generated.items():
|
|
437
|
+
copied_count, skipped_count, backup = _write_host_resource(
|
|
438
|
+
root, target, content.encode("utf-8"), "zcode",
|
|
439
|
+
)
|
|
440
|
+
copied += copied_count
|
|
441
|
+
skipped += skipped_count
|
|
442
|
+
if backup is not None:
|
|
443
|
+
backups.append(backup)
|
|
444
|
+
_ensure_plugin_gitignored(root, plugin_root)
|
|
445
|
+
|
|
446
|
+
def portable_relative(path: Path) -> str:
|
|
447
|
+
"""Serialize project-relative plugin paths with stable separators."""
|
|
448
|
+
return path.relative_to(root).as_posix()
|
|
449
|
+
|
|
450
|
+
return {
|
|
451
|
+
"status": "prepared",
|
|
452
|
+
"plugin": CHATGPT_PLUGIN_NAME,
|
|
453
|
+
"plugin_path": portable_relative(plugin_root),
|
|
454
|
+
"manifest_path": portable_relative(manifest_path),
|
|
455
|
+
"agent_path": portable_relative(agent_path),
|
|
456
|
+
"worker_agent_path": portable_relative(worker_agent_path),
|
|
457
|
+
"usage_skill_path": (
|
|
458
|
+
portable_relative(usage_skill_path)
|
|
459
|
+
if usage_skill_path.is_file() else None
|
|
460
|
+
),
|
|
461
|
+
"copied": copied,
|
|
462
|
+
"skipped": skipped,
|
|
463
|
+
"backups": backups,
|
|
464
|
+
"next_step": _i18n_prompt(
|
|
465
|
+
"plugin.zcode_next_step",
|
|
466
|
+
"在 ZCode 的 Settings → Plugin Management 中以本地目录添加 "
|
|
467
|
+
f"{plugin_root} 并启用;随后新会话可通过 bugx:bugx 审计、"
|
|
468
|
+
"bugx:bugx-worker 并发派发",
|
|
469
|
+
plugin_root=plugin_root,
|
|
470
|
+
),
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
ZCODE_GLOBAL_PLUGIN_DIR_NAME = "zcode-plugin"
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
def _zcode_global_plugin_root() -> Path:
|
|
478
|
+
"""Return the one BugX-owned ZCode plugin source for this machine.
|
|
479
|
+
|
|
480
|
+
``plugins.dirs`` registration is user-global while the BugX plugin used
|
|
481
|
+
to be generated per project (and in development repositories pointed at
|
|
482
|
+
the source tree). A single user-owned copy under ~/.bugx keeps every
|
|
483
|
+
project's ZCode session on one identical plugin, mirroring the ChatGPT
|
|
484
|
+
global plugin model.
|
|
485
|
+
"""
|
|
486
|
+
override = os.environ.get("BUGX_ZCODE_PLUGIN_ROOT")
|
|
487
|
+
if override:
|
|
488
|
+
return Path(override).expanduser()
|
|
489
|
+
return Path.home() / ".bugx" / ZCODE_GLOBAL_PLUGIN_DIR_NAME
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
def _write_zcode_global_plugin(
|
|
493
|
+
root: Path, source: Path, *, locale: str | None = None,
|
|
494
|
+
) -> Path:
|
|
495
|
+
"""Publish the canonical global ZCode plugin atomically under ~/.bugx."""
|
|
496
|
+
# 延迟导入避免 plugin.py <-> plugin_zcode.py 顶层循环导入。
|
|
497
|
+
from .plugin import _chatgpt_skill_content
|
|
498
|
+
|
|
499
|
+
base = _zcode_global_plugin_root()
|
|
500
|
+
plugin_dir = base / "plugins" / CHATGPT_PLUGIN_NAME
|
|
501
|
+
# macOS exposes /var as a system symlink; validate its physical target
|
|
502
|
+
# while keeping the user-facing path stable for ZCode configuration.
|
|
503
|
+
security_base = (
|
|
504
|
+
base.resolve(strict=False)
|
|
505
|
+
if str(base).startswith("/var/") and Path("/var").is_symlink()
|
|
506
|
+
else base
|
|
507
|
+
)
|
|
508
|
+
_assert_no_symlink_components(security_base)
|
|
509
|
+
generated = {
|
|
510
|
+
plugin_dir / ".zcode-plugin" / "plugin.json": json.dumps(
|
|
511
|
+
_zcode_plugin_manifest(), ensure_ascii=False, indent=2,
|
|
512
|
+
) + "\n",
|
|
513
|
+
plugin_dir / "agents" / "bugx.md": _zcode_plugin_agent_content(
|
|
514
|
+
source, locale=locale,
|
|
515
|
+
),
|
|
516
|
+
plugin_dir / "agents" / "bugx-worker.md": _zcode_plugin_worker_content(
|
|
517
|
+
locale=locale,
|
|
518
|
+
),
|
|
519
|
+
plugin_dir / "agents" / "bugx-judge.md": _JUDGE_AGENT_CONTENT,
|
|
520
|
+
# ZCode 的插件加载器按目录约定扫描 skills/ 子目录;全局实体保持
|
|
521
|
+
# 同结构,宿主侧行为与项目内插件一致。
|
|
522
|
+
plugin_dir / "skills" / CHATGPT_PLUGIN_NAME / "SKILL.md":
|
|
523
|
+
_chatgpt_skill_content(source, locale=locale),
|
|
524
|
+
}
|
|
525
|
+
# ZCode 专属使用手册与插件同址分发:宿主按 skills/ 目录约定发现,
|
|
526
|
+
# 因此该 Skill 随全局插件实体一起生成,而不是散落在别处。
|
|
527
|
+
usage_skill = _zcode_usage_skill_path(root, source)
|
|
528
|
+
if usage_skill.is_file():
|
|
529
|
+
generated[plugin_dir / "skills" / "bugx-zcode" / "SKILL.md"] = (
|
|
530
|
+
usage_skill.read_text(encoding="utf-8")
|
|
531
|
+
)
|
|
532
|
+
for target, content in generated.items():
|
|
533
|
+
if target.is_symlink():
|
|
534
|
+
raise CliError(_i18n_exc(
|
|
535
|
+
"plugin.zcode_global_symlink_refused",
|
|
536
|
+
f"拒绝覆盖符号链接的全局 ZCode 插件文件: {target}", target=target,
|
|
537
|
+
))
|
|
538
|
+
_atomic_write_global_file(target, content.encode("utf-8"))
|
|
539
|
+
|
|
540
|
+
# 同步插件图标本地静态资源,离线时备用
|
|
541
|
+
avatar_src = root / "plugins" / CHATGPT_PLUGIN_NAME / "assets" / "bugx-avatar-512.png"
|
|
542
|
+
if not avatar_src.is_file():
|
|
543
|
+
avatar_src = root / "core" / "assets" / "bugx-avatar-512.png"
|
|
544
|
+
if not avatar_src.is_file():
|
|
545
|
+
avatar_src = asset_root() / "bugx-avatar-512.png"
|
|
546
|
+
if avatar_src.is_file():
|
|
547
|
+
avatar_target = plugin_dir / "assets" / "bugx-avatar-512.png"
|
|
548
|
+
if avatar_target.is_symlink():
|
|
549
|
+
raise CliError(_i18n_exc(
|
|
550
|
+
"plugin.zcode_global_symlink_refused",
|
|
551
|
+
f"拒绝覆盖符号链接的全局 ZCode 插件文件: {avatar_target}", target=avatar_target,
|
|
552
|
+
))
|
|
553
|
+
_atomic_write_global_file(avatar_target, avatar_src.read_bytes())
|
|
554
|
+
return plugin_dir
|
|
555
|
+
|
|
556
|
+
|
|
557
|
+
def _is_legacy_zcode_plugin_dir(candidate: Path) -> bool:
|
|
558
|
+
"""Check whether *candidate* is a BugX plugin dir registered per project."""
|
|
559
|
+
manifest = candidate / ".zcode-plugin" / "plugin.json"
|
|
560
|
+
try:
|
|
561
|
+
if manifest.is_symlink() or not manifest.is_file():
|
|
562
|
+
return False
|
|
563
|
+
payload = json.loads(manifest.read_text(encoding="utf-8"))
|
|
564
|
+
return isinstance(payload, dict) and payload.get("name") == CHATGPT_PLUGIN_NAME
|
|
565
|
+
except (OSError, json.JSONDecodeError):
|
|
566
|
+
return False
|
|
567
|
+
|
|
568
|
+
|
|
569
|
+
def _upsert_zcode_plugin_dirs(
|
|
570
|
+
*, register: Path | None, remove: bool,
|
|
571
|
+
) -> dict[str, object]:
|
|
572
|
+
"""Rewrite plugins.dirs against the global plugin dir.
|
|
573
|
+
|
|
574
|
+
Legacy per-project entries (including ones pointing into a BugX source
|
|
575
|
+
repository) are recognized by their manifest and dropped, so a single
|
|
576
|
+
user-owned registration remains.
|
|
577
|
+
"""
|
|
578
|
+
config_path = _zcode_config_path()
|
|
579
|
+
cfg: dict[str, object] = {}
|
|
580
|
+
if config_path.is_file():
|
|
581
|
+
try:
|
|
582
|
+
loaded = json.loads(config_path.read_text(encoding="utf-8"))
|
|
583
|
+
except (OSError, json.JSONDecodeError) as exc:
|
|
584
|
+
raise CliError(_i18n_exc(
|
|
585
|
+
"plugin.zcode_config_unreadable",
|
|
586
|
+
f"ZCode 配置无法读取,拒绝写入: {config_path}: {exc}",
|
|
587
|
+
config_path=config_path, exc=exc,
|
|
588
|
+
)) from exc
|
|
589
|
+
if not isinstance(loaded, dict):
|
|
590
|
+
raise CliError(_i18n_exc(
|
|
591
|
+
"plugin.zcode_config_not_json_object",
|
|
592
|
+
f"ZCode 配置不是 JSON 对象,拒绝写入: {config_path}",
|
|
593
|
+
config_path=config_path,
|
|
594
|
+
))
|
|
595
|
+
cfg = loaded
|
|
596
|
+
plugins_cfg = cfg.get("plugins")
|
|
597
|
+
if plugins_cfg is not None and not isinstance(plugins_cfg, dict):
|
|
598
|
+
raise CliError(_i18n_exc(
|
|
599
|
+
"plugin.zcode_config_plugins_not_object",
|
|
600
|
+
f"ZCode 配置 plugins 键不是对象,拒绝写入: {config_path}",
|
|
601
|
+
config_path=config_path,
|
|
602
|
+
))
|
|
603
|
+
plugins_cfg = dict(plugins_cfg or {})
|
|
604
|
+
dirs_raw = plugins_cfg.get("dirs")
|
|
605
|
+
if dirs_raw is not None and not isinstance(dirs_raw, list):
|
|
606
|
+
raise CliError(_i18n_exc(
|
|
607
|
+
"plugin.zcode_config_dirs_not_array",
|
|
608
|
+
f"ZCode 配置 plugins.dirs 不是数组,拒绝写入: {config_path}",
|
|
609
|
+
config_path=config_path,
|
|
610
|
+
))
|
|
611
|
+
dirs = [str(item) for item in dirs_raw or []]
|
|
612
|
+
global_dir = _zcode_global_plugin_root() / "plugins" / CHATGPT_PLUGIN_NAME
|
|
613
|
+
global_key = str(global_dir.resolve(strict=False))
|
|
614
|
+
register_key = (
|
|
615
|
+
str(Path(register).resolve(strict=False))
|
|
616
|
+
if register is not None else global_key
|
|
617
|
+
)
|
|
618
|
+
kept: list[str] = []
|
|
619
|
+
migrated: list[str] = []
|
|
620
|
+
for item in dirs:
|
|
621
|
+
key = str(Path(item).resolve(strict=False))
|
|
622
|
+
if key == global_key or key == register_key:
|
|
623
|
+
continue
|
|
624
|
+
if _is_legacy_zcode_plugin_dir(Path(item)):
|
|
625
|
+
migrated.append(item)
|
|
626
|
+
continue
|
|
627
|
+
kept.append(item)
|
|
628
|
+
action = "not-registered"
|
|
629
|
+
if not remove and register_key not in [str(Path(k).resolve(strict=False)) for k in kept]:
|
|
630
|
+
kept.append(register_key)
|
|
631
|
+
action = "registered" if not migrated else "registered+migrated"
|
|
632
|
+
elif remove:
|
|
633
|
+
action = "removed" if migrated or register_key in (
|
|
634
|
+
str(Path(k).resolve(strict=False)) for k in dirs
|
|
635
|
+
) else "not-registered"
|
|
636
|
+
plugins_cfg["dirs"] = kept
|
|
637
|
+
cfg["plugins"] = plugins_cfg
|
|
638
|
+
if config_path.parent.exists() is False:
|
|
639
|
+
config_path.parent.mkdir(parents=True, exist_ok=True)
|
|
640
|
+
_atomic_write_global_file(config_path, json.dumps(
|
|
641
|
+
cfg, ensure_ascii=False, indent=2,
|
|
642
|
+
).encode("utf-8") + b"\n")
|
|
643
|
+
return {
|
|
644
|
+
"action": action, "config": str(config_path),
|
|
645
|
+
"plugin_dir": register_key, "dirs": kept, "migrated": migrated,
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
|
|
649
|
+
def _zcode_config_path() -> Path:
|
|
650
|
+
"""ZCode 用户级配置文件(plugins.dirs 所在层;测试经 HOME 隔离)。"""
|
|
651
|
+
return Path.home() / ".zcode" / "cli" / "config.json"
|
|
652
|
+
|
|
653
|
+
|
|
654
|
+
def _zcode_workspace_mcp_config_path(root: Path) -> Path:
|
|
655
|
+
"""ZCode 工作区级 MCP 配置;项目根是唯一允许的 BugX 绑定边界。"""
|
|
656
|
+
return root.resolve() / ".zcode" / "mcp.json"
|
|
657
|
+
|
|
658
|
+
|
|
659
|
+
def command_plugin_zcode(args: argparse.Namespace) -> int:
|
|
660
|
+
"""Publish the user-global ZCode plugin and register it in plugins.dirs.
|
|
661
|
+
|
|
662
|
+
ZCode loads plugins from user-level ``plugins.dirs`` entries; the BugX
|
|
663
|
+
plugin entity is published once under ``~/.bugx/zcode-plugin`` (never a
|
|
664
|
+
project or source-repository path), and legacy per-project registrations
|
|
665
|
+
are migrated away in the same rewrite.
|
|
666
|
+
"""
|
|
667
|
+
root = args.root.resolve()
|
|
668
|
+
project_manifest = root / "plugins" / CHATGPT_PLUGIN_NAME / ".zcode-plugin" / "plugin.json"
|
|
669
|
+
source = asset_root()
|
|
670
|
+
if not project_manifest.is_file() and not args.remove:
|
|
671
|
+
raise CliError(_i18n_exc(
|
|
672
|
+
"plugin.missing_zcode_manifest",
|
|
673
|
+
f"缺少 ZCode 插件清单: {project_manifest};请先运行 bugx install --root {root} --agent zcode --non-interactive",
|
|
674
|
+
manifest=project_manifest,
|
|
675
|
+
root=root,
|
|
676
|
+
))
|
|
677
|
+
if not args.remove:
|
|
678
|
+
target_locale = getattr(args, "locale", None) or _resolve_locale_name()
|
|
679
|
+
_write_zcode_global_plugin(root, source, locale=target_locale)
|
|
680
|
+
result = _upsert_zcode_plugin_dirs(register=None, remove=bool(args.remove))
|
|
681
|
+
action = str(result["action"])
|
|
682
|
+
migrated = list(result.get("migrated") or [])
|
|
683
|
+
next_step = (
|
|
684
|
+
_i18n_prompt("plugin.zcode_next_step_removed", "已从 ZCode plugins.dirs 移除;已加载会话需重启后失效")
|
|
685
|
+
if args.remove else
|
|
686
|
+
_i18n_prompt("plugin.zcode_next_step_registered", "重启 ZCode 或新开会话后,Subagents/Agent 列表出现 bugx:bugx")
|
|
687
|
+
)
|
|
688
|
+
if migrated and not args.remove:
|
|
689
|
+
next_step = (
|
|
690
|
+
"已把旧的项目内 ZCode 插件注册("
|
|
691
|
+
+ "、".join(migrated[:3])
|
|
692
|
+
+ ")迁移为用户目录全局插件;重启 ZCode 或新开会话后生效"
|
|
693
|
+
)
|
|
694
|
+
payload = {
|
|
695
|
+
"action": action,
|
|
696
|
+
"config": result["config"],
|
|
697
|
+
"plugin_dir": result["plugin_dir"],
|
|
698
|
+
"dirs": result["dirs"],
|
|
699
|
+
"migrated": migrated,
|
|
700
|
+
"next_step": next_step,
|
|
701
|
+
}
|
|
702
|
+
if getattr(args, "json", False):
|
|
703
|
+
print(json.dumps(payload, ensure_ascii=False, indent=2))
|
|
704
|
+
else:
|
|
705
|
+
print(f"[bugx] ZCode 插件目录已更新(用户级全局实体): {result['plugin_dir']}")
|
|
706
|
+
if migrated:
|
|
707
|
+
print(f"[bugx] 已迁移旧项目内注册: {'、'.join(migrated)}")
|
|
708
|
+
print(f"[bugx] 配置: {result['config']} → plugins.dirs = {result['dirs']}")
|
|
709
|
+
print(f"[bugx] {payload['next_step']}")
|
|
710
|
+
return 0
|