bugx-cli 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +190 -186
- package/core/README.md +2 -2
- package/core/agent/README.md +2 -1
- package/core/agent/agent_artifacts.py +8 -6
- package/core/agent/agent_eval.py +136 -54
- package/core/agent/agent_execution.py +218 -52
- package/core/agent/agent_orchestrator.py +14 -8
- package/core/agent/agent_targets.py +8 -2
- package/core/agent/feature_baseline.py +150 -0
- package/core/assets/axe-core/LICENSE-3RD-PARTY.txt +66 -0
- package/core/assets/axe-core/LICENSE.txt +362 -0
- package/core/assets/axe-core/UPSTREAM.md +10 -0
- package/core/assets/axe-core/axe.min.js +12 -0
- package/core/assets/bugx-hero-en.svg +74 -0
- package/core/assets/bugx-hero-zh.svg +74 -0
- package/core/assets/codex.png +0 -0
- package/core/assets/dsh.png +0 -0
- package/core/assets/webui-chatgpt.jpg +0 -0
- package/core/assets/webui-session.jpg +0 -0
- package/core/assets/webui-skills.jpg +0 -0
- package/core/assets/webui-studio.jpg +0 -0
- package/core/assets/webui-zcode.jpg +0 -0
- package/core/assets/zcode.png +0 -0
- package/core/autonomous_cve/SPEC.md +1 -1
- package/core/autonomous_cve/attack_graph_store.py +152 -106
- package/core/autonomous_cve/behavior_graph.py +8 -2
- package/core/autonomous_cve/verifier.py +4 -1
- package/core/bugx.md +1 -1
- package/core/bugx_paths.py +43 -8
- package/core/cli-help.txt +66 -0
- package/core/cloud_sync/SPEC.md +1 -1
- package/core/cloud_sync/cloud_client.py +25 -6
- package/core/cloud_sync/cloud_onboard.py +42 -1
- package/core/cloud_sync/flywheel_client.py +16 -7
- package/core/cloud_sync/network_transport.py +24 -3
- package/core/cloud_sync/sensitive_filter.py +2 -2
- package/core/cloud_sync/sync_push.py +12 -10
- package/core/contracts/AGENT_GUIDE.md +6 -9
- package/core/contracts/README.md +2 -2
- package/core/contracts/bugx-runtime-contract.md +1 -1
- package/core/contracts/bugx-worker.md +1 -1
- package/core/contracts/engine_gap_contracts.py +86 -3
- package/core/coverage/coverage_discovery.py +599 -29
- package/core/coverage/coverage_evidence.py +47 -0
- package/core/coverage/coverage_forensics.py +9 -0
- package/core/coverage/coverage_validate.py +6 -1
- package/core/dev_harness/SPEC.md +1 -1
- package/core/engine-integrity.json +591 -419
- package/core/fuzzing/concurrency_fuzzer.py +53 -0
- package/core/fuzzing/differential_oracle.py +562 -27
- package/core/fuzzing/fuzz_input.py +109 -6
- package/core/fuzzing/stateful_fuzzer.py +72 -0
- package/core/governance/secret_redactor.py +22 -10
- package/core/host_acp/SPEC.md +1 -1
- package/core/host_acp/__init__.py +4 -4
- package/core/host_acp/claude.py +59 -1
- package/core/host_acp/cline.py +64 -1
- package/core/host_acp/codex.py +56 -1
- package/core/host_acp/dsh.py +59 -1
- package/core/host_acp/opencode.py +56 -1
- package/core/host_acp/pi.py +59 -1
- package/core/host_acp/zcode.py +59 -1
- package/core/host_runtime/SPEC.md +1 -1
- package/core/host_runtime/adapters.py +1 -1
- package/core/host_runtime/cline.py +13 -0
- package/core/host_runtime/host_evaluators.py +44 -4
- package/core/host_runtime/host_probe.py +1 -1
- package/core/host_runtime/host_provider_arbitrator.py +116 -62
- package/core/host_runtime/host_registry.py +15 -8
- package/core/host_runtime/mcp_registry_gate.py +12 -1
- package/core/host_runtime/pi.py +102 -0
- package/core/host_runtime/provider_facts.py +66 -0
- package/core/hosts/SPEC.md +1 -1
- package/core/hosts/__init__.py +6 -2
- package/core/hosts/_dsh_usage.py +1 -1
- package/core/hosts/base.py +32 -4
- package/core/hosts/claude.py +55 -0
- package/core/hosts/cline.py +6 -2
- package/core/hosts/codex.py +58 -0
- package/core/hosts/dsh.py +9 -1
- package/core/hosts/opencode.py +6 -6
- package/core/hosts/pi.py +159 -2
- package/core/infra/README.md +4 -2
- package/core/infra/__init__.py +2 -0
- package/core/infra/build_info.py +22 -3
- package/core/infra/client_metadata.py +1 -1
- package/core/infra/json_utils.py +22 -0
- package/core/launch_phases/README.md +2 -2
- package/core/launch_phases/SPEC.md +1 -1
- package/core/launch_phases/common.py +21 -2
- package/core/launch_phases/finding_confirm_phase.py +5 -1
- package/core/launch_phases/finding_settlement.py +188 -1
- package/core/launch_phases/judge_phase.py +69 -12
- package/core/launch_phases/orchestrator_controls.py +11 -7
- package/core/launch_phases/post_coverage_sync.py +9 -2
- package/core/launch_phases/post_phase.py +139 -3
- package/core/launch_phases/post_receipt.py +12 -1
- package/core/launch_phases/pre_phase.py +3 -3
- package/core/launch_phases/pre_recon_scout.py +53 -36
- package/core/launch_phases/pre_state_builder.py +23 -176
- package/core/launch_phases/round_orchestrator.py +15 -32
- package/core/launch_phases/session_runtime.py +56 -9
- package/core/launch_phases/startup_gates.py +36 -8
- package/core/launch_phases/startup_interaction.py +68 -12
- package/core/launch_phases/startup_version_gate.py +9 -3
- package/core/launch_phases/supervisor_bridge.py +46 -17
- package/core/launch_phases/supervisor_coverage.py +8 -2
- package/core/launch_phases/supervisor_degraded.py +1 -9
- package/core/launch_phases/worker_barriers.py +15 -5
- package/core/launch_phases/worker_orchestrator.py +105 -25
- package/core/ledger/README.md +1 -1
- package/core/ledger/SPEC.md +1 -1
- package/core/ledger/_facade.py +2 -1
- package/core/ledger/archive_ops.py +60 -2
- package/core/ledger/cli.py +6 -1
- package/core/ledger/export_ops.py +6 -1
- package/core/ledger/finding_confirmation.py +48 -6
- package/core/ledger/finding_lifecycle.py +428 -5
- package/core/ledger/finding_verification.py +44 -8
- package/core/ledger/incidents.py +10 -4
- package/core/ledger/patterns.py +10 -7
- package/core/ledger/receipt_contract.py +17 -1
- package/core/ledger/sync_ops.py +21 -16
- package/core/ledger/tool_experience.py +2 -1
- package/core/ledger/verify_life.py +88 -17
- package/core/locales/en-US.json +2 -2
- package/core/locales/zh-CN.json +2 -2
- package/core/mcp_handlers/SPEC.md +1 -1
- package/core/mcp_handlers/base.py +23 -3
- package/core/mcp_handlers/channel_lifecycle.py +85 -30
- package/core/mcp_handlers/retrieval_handlers.py +11 -1
- package/core/mcp_handlers/rpc_server.py +6 -1
- package/core/mcp_handlers/supervisor_handlers.py +32 -6
- package/core/mcp_handlers/tool_table.py +15 -0
- package/core/mcp_runtime_support/environment.py +0 -38
- package/core/mcp_runtime_support/verifier.py +0 -52
- package/core/metadata.txt +2 -3
- package/core/planning/README.md +1 -1
- package/core/planning/domain_router.py +4 -2
- package/core/planning/dynamic_flow_analyzer.py +219 -14
- package/core/planning/judge_pipeline.py +87 -4
- package/core/planning/prompt_harness.py +7 -5
- package/core/planning/spec_harvester.py +4 -4
- package/core/probes/INTERFACE.md +11 -1
- package/core/probes/SPEC.md +11 -1
- package/core/probes/__init__.py +46 -40
- package/core/probes/android_probe.py +177 -9
- package/core/probes/codebase_memory_probe.py +57 -0
- package/core/probes/desktop_probe.py +104 -0
- package/core/probes/differential_probe.py +99 -21
- package/core/probes/efficiency_probe.py +64 -0
- package/core/probes/ios_binary_probe.py +105 -1
- package/core/probes/memory_probe.py +66 -0
- package/core/probes/miniprogram_probe.py +75 -13
- package/core/probes/mobile_probe.py +215 -30
- package/core/probes/native_probe.py +88 -0
- package/core/probes/openwiki_probe.py +70 -0
- package/core/probes/pattern_probe.py +106 -0
- package/core/probes/platform_probe.py +81 -0
- package/core/probes/probe_registry.py +108 -7
- package/core/probes/sast_fixture_corpus.py +340 -0
- package/core/probes/sast_probe.py +553 -52
- package/core/probes/sast_rules.py +668 -28
- package/core/probes/sca_scanner.py +48 -0
- package/core/probes/ui_accessibility.py +149 -0
- package/core/probes/ui_audit.py +513 -0
- package/core/probes/ui_contract.py +273 -0
- package/core/probes/ui_evidence.py +212 -0
- package/core/probes/ui_measurements.py +314 -0
- package/core/probes/ui_repair.py +250 -0
- package/core/probes/ui_review.py +133 -0
- package/core/probes/ui_storybook.py +107 -0
- package/core/probes/ui_tokens.py +185 -0
- package/core/probes/ui_visual_diff.py +131 -0
- package/core/probes/web_probe.py +373 -18
- package/core/project_profiler/SPEC.md +1 -1
- package/core/project_profiler/arbitrator.py +6 -1
- package/core/project_profiler/detector.py +8 -1
- package/core/project_profiler/strategy.py +51 -15
- package/core/prompts/command_routing_en.md +2 -2
- package/core/prompts/command_routing_zh.md +2 -2
- package/core/prompts/stages/stage_repair.md +1 -1
- package/core/repair/README.md +1 -1
- package/core/repair/l7_repair_loop.py +1 -4
- package/core/repair/rsi_fixer.py +4 -4
- package/core/repair/rsi_loop.py +1 -3
- package/core/repair/rsi_repair.py +7 -7
- package/core/repair/rsi_scope.py +27 -8
- package/core/report_engine/SPEC.md +1 -1
- package/core/report_engine/attestation.py +8 -4
- package/core/report_engine/finding_report.py +2 -1
- package/core/report_engine/models.py +7 -9
- package/core/report_engine/sast_bridge.py +2 -2
- package/core/report_engine/server.py +18 -8
- package/core/report_engine/web-conformance.md +123 -18
- package/core/report_engine/web_conformance.py +21 -52
- package/core/retrieval/README.md +1 -1
- package/core/retrieval/SPEC.md +1 -1
- package/core/retrieval/code_analyzer.py +50 -14
- package/core/retrieval/context_assembler.py +7 -1
- package/core/retrieval/knowledge_sync.py +108 -14
- package/core/retrieval/symbol_index.py +25 -6
- package/core/retrieval/universal_code_matcher.py +234 -49
- package/core/runtime/README.md +1 -1
- package/core/runtime/bugx_logging.py +78 -7
- package/core/runtime/fixture_solidify.py +5 -10
- package/core/runtime/incident_eval.py +1 -1
- package/core/runtime/model_runner.py +4 -41
- package/core/runtime/platform_adapter.py +2 -2
- package/core/runtime/prep_validate.py +4 -2
- package/core/runtime/project_settings.py +2 -1
- package/core/runtime/scenario_eval.py +50 -8
- package/core/skills/bugx_docs_mcp_server.py +3 -1
- package/core/skills/bugx_mcp_server.py +29 -2
- package/core/skills/tools_kb.py +1 -1
- package/core/supervisor/README.md +1 -1
- package/core/supervisor/SPEC.md +1 -1
- package/core/supervisor/budget_governor.py +503 -9
- package/core/supervisor/checkpoint_pipeline.py +248 -6
- package/core/supervisor/checkpoint_sync.py +13 -0
- package/core/supervisor/claim_events.py +1 -1
- package/core/supervisor/finding_workflow.py +22 -5
- package/core/supervisor/lease_manager.py +1 -1
- package/core/supervisor/lifecycle_blocks.py +6 -1
- package/core/supervisor/rejection_remedies.py +52 -5
- package/core/supervisor/serial_authorization.py +48 -4
- package/core/supervisor/task_scheduler.py +2 -2
- package/core/supervisor/worker_checkpoint.py +8 -1
- package/core/supervisor/worker_runtime.py +8 -2
- package/core/supervisor_types/worker_claim.py +9 -0
- package/core/webui/README.md +1 -1
- package/core/webui/SPEC.md +2 -1
- package/core/webui/adapters/claude.py +5 -1
- package/core/webui/adapters/cline.py +10 -2
- package/core/webui/adapters/codex.py +5 -1
- package/core/webui/adapters/dsh.py +5 -1
- package/core/webui/docs_session_service.py +2 -2
- package/core/webui/mcp_inspector.py +11 -7
- package/core/webui/static/00-base.css +1060 -0
- package/core/webui/static/01-monitoring.css +802 -0
- package/core/webui/static/02-header-actions.css +321 -0
- package/core/webui/static/03-trigger-popover.css +697 -0
- package/core/webui/static/04-composer.css +628 -0
- package/core/webui/static/05-skills-center.css +878 -0
- package/core/webui/static/06-mcp-center.css +623 -0
- package/core/webui/static/07-skill-detail.css +265 -0
- package/core/webui/static/08-files-management.css +167 -0
- package/core/webui/static/09-files-center.css +386 -0
- package/core/webui/static/10-icons.css +105 -0
- package/core/webui/static/11-project-options.css +185 -0
- package/core/webui/static/12-profile-tab.css +383 -0
- package/core/webui/static/design-tokens.css +113 -0
- package/core/webui/static/index.html +14 -1
- package/core/webui/workspace_service.py +1 -1
- package/docs/07_distribution/01_README_NPM.md +190 -186
- package/ecosystem/integrations/README.md +1 -1
- package/ecosystem/integrations/dsh/mcp/package.json +1 -1
- package/ecosystem/integrations/dsh/skills/bugx-dsh/SKILL.md +1 -1
- package/ecosystem/integrations/dsh/ui/package.json +1 -1
- package/ecosystem/integrations/opencode/bugx-mcp-manifest.json +4 -4
- package/ecosystem/integrations/opencode/mcp-lock.json +14 -6
- package/ecosystem/integrations/opencode/opencode.json +23 -12
- package/ecosystem/integrations/pi/extensions/bugx/manifest.json +1 -1
- package/ecosystem/integrations/qoder/connector-meta.json +1 -1
- package/ecosystem/integrations/workbuddy/connector-meta.json +1 -1
- package/ecosystem/integrations/workbuddy/skills/bugx/SKILL.md +1 -1
- package/ecosystem/plugins/bugx/.claude-plugin/plugin.json +1 -1
- package/ecosystem/plugins/bugx/.codex-plugin/plugin.json +1 -1
- package/ecosystem/plugins/bugx/.zcode-plugin/plugin.json +1 -1
- package/ecosystem/plugins/bugx/skills/bugx/SKILL.md +2 -2
- package/ecosystem/plugins/bugx/skills/bugx-dsh/SKILL.md +1 -1
- package/ecosystem/plugins/bugx/skills/bugx-opencode/SKILL.md +1 -1
- package/ecosystem/plugins/bugx/skills/bugx-zcode/SKILL.md +1 -1
- package/interfaces/bin/bugx.js +37 -0
- package/interfaces/cli/bugx_cli/__init__.py +4 -2
- package/interfaces/cli/bugx_cli/cli.py +11 -4
- package/interfaces/cli/bugx_cli/commands/advisory.py +1 -1
- package/interfaces/cli/bugx_cli/commands/agent.py +339 -73
- package/interfaces/cli/bugx_cli/commands/audit.py +2 -2
- package/interfaces/cli/bugx_cli/commands/autonomous.py +1 -1
- package/interfaces/cli/bugx_cli/commands/cloud.py +4 -3
- package/interfaces/cli/bugx_cli/commands/doctor.py +449 -204
- package/interfaces/cli/bugx_cli/commands/interaction.py +5 -1
- package/interfaces/cli/bugx_cli/commands/knowledge.py +2 -0
- package/interfaces/cli/bugx_cli/commands/lifecycle.py +3 -3
- package/interfaces/cli/bugx_cli/commands/plugin.py +55 -20
- package/interfaces/cli/bugx_cli/commands/plugin_claude.py +7 -7
- package/interfaces/cli/bugx_cli/commands/plugin_funide.py +2 -1
- package/interfaces/cli/bugx_cli/commands/plugin_zcode.py +1 -1
- package/interfaces/cli/bugx_cli/commands/report.py +2 -6
- package/interfaces/cli/bugx_cli/commands/system.py +11 -11
- package/interfaces/cli/bugx_cli/common.py +15 -7
- package/interfaces/cli/bugx_cli/host_adapters.py +29 -54
- package/interfaces/cli/bugx_cli/hosts/registry.py +8 -6
- package/interfaces/cli/bugx_cli/infra/ai_advisor.py +157 -27
- package/interfaces/cli/bugx_cli/infra/engine_installer.py +18 -10
- package/interfaces/cli/bugx_cli/infra/host_sync.py +11 -8
- package/interfaces/cli/bugx_cli/infra/mcp_advisor.py +76 -5
- package/interfaces/cli/bugx_cli/infra/security.py +13 -6
- package/package.json +2 -1
- package/pyproject.toml +20 -8
- package/scripts/ensure-python.mjs +7 -7
- package/scripts/sync-version.mjs +10 -21
- package/scripts/test-npm-wrapper.mjs +1 -1
- package/core/webui/static/project-settings.css +0 -6458
- package/docs/07_distribution/README.md +0 -16
- package/docs/README.md +0 -121
- package/interfaces/README.md +0 -143
- package/interfaces/bin/README.md +0 -35
- package/interfaces/cli/README.md +0 -90
- package/scripts/README.md +0 -118
|
@@ -10,8 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
本模块是引擎侧唯一的宿主名与项目标记来源。``supervisor_host`` 与
|
|
12
12
|
``startup_environment`` 都必须从这里取,不得再写本地字面量;CLI 侧
|
|
13
|
-
``host_adapters.HOST_ADAPTERS``
|
|
14
|
-
双向一致性守护。
|
|
13
|
+
``host_adapters.HOST_ADAPTERS`` 与本清单由宿主注册完整性检查做双向一致性守护。
|
|
15
14
|
|
|
16
15
|
依赖约束:本模块只允许依赖标准库,避免成为新的 import 环。
|
|
17
16
|
"""
|
|
@@ -30,7 +29,7 @@ except ImportError:
|
|
|
30
29
|
|
|
31
30
|
# 受支持宿主(顺序即稳定展示顺序)。新增宿主必须同时更新:
|
|
32
31
|
# 1. 本清单;2. HOST_MARKERS;3. CLI 侧 src/bugx_cli/host_adapters.py。
|
|
33
|
-
#
|
|
32
|
+
# 缺任何一处都会被宿主注册完整性检查拦下。
|
|
34
33
|
SUPPORTED_HOSTS: tuple[str, ...] = (
|
|
35
34
|
"opencode",
|
|
36
35
|
"claude",
|
|
@@ -540,12 +539,20 @@ def build_recon_scout_env(host_name: str, root: Path) -> dict[str, str]:
|
|
|
540
539
|
|
|
541
540
|
def host_project_mcp_relpaths() -> list[str]:
|
|
542
541
|
"""返回所有已适配宿主声明的项目级 MCP 配置相对路径 (DOC-243 消除硬编码宿主事实字面量)。"""
|
|
543
|
-
|
|
542
|
+
|
|
543
|
+
return list(host_project_mcp_containers())
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
def host_project_mcp_containers() -> dict[str, str | None]:
|
|
547
|
+
"""项目级 MCP 配置相对路径 → 该宿主的容器键(点分,如 ``mcp.servers``)。"""
|
|
548
|
+
|
|
549
|
+
containers: dict[str, str | None] = {}
|
|
544
550
|
for plugin in _HOST_PLUGINS.values():
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
551
|
+
facet = getattr(plugin, "mcp_write", None)
|
|
552
|
+
rel = getattr(facet, "project_relpath", None)
|
|
553
|
+
if rel and isinstance(rel, str):
|
|
554
|
+
containers.setdefault(rel, getattr(facet, "container_key", None) or None)
|
|
555
|
+
return containers
|
|
549
556
|
|
|
550
557
|
|
|
551
558
|
def resolve_scout_host(root: Path, preferred: str | None = None) -> str:
|
|
@@ -31,7 +31,7 @@ MCP_REGISTRY: tuple[dict[str, object], ...] = (
|
|
|
31
31
|
"package": "@bencibro/postmcp",
|
|
32
32
|
"source": "https://github.com/Bencibr/postmcp",
|
|
33
33
|
"trust": "B",
|
|
34
|
-
"audit": ("DOC-236 采用路径 A2(2026-10-21):**自研项目**(origin =
|
|
34
|
+
"audit": ("DOC-236 采用路径 A2(2026-10-21):**自研项目**(origin = 私有 Gitea(LAN)自研项目 postmcp,"
|
|
35
35
|
"MIT)已发布 1.0.4——改用 Node 内置 `node:sqlite` 移除原生 `sqlite3`,"
|
|
36
36
|
"消除 `--ignore-scripts` 下的 `Could not locate the bindings file` 启动失败;"
|
|
37
37
|
"实测 `npm install --ignore-scripts` + MCP 握手 42 工具通过,dist/src 无遥测标记。"
|
|
@@ -46,6 +46,17 @@ MCP_REGISTRY: tuple[dict[str, object], ...] = (
|
|
|
46
46
|
"audit": ("npm 元数据实测 maintainers 含 microsoft-oss-releases/microsoft1es;"
|
|
47
47
|
"载荷经 mcp_runtime lock-hash 安装(DOC-233 设计项 4)"),
|
|
48
48
|
},
|
|
49
|
+
{
|
|
50
|
+
"name": "codindex", "tier": "optional", "status": "active",
|
|
51
|
+
"credentials": {"env": (), "require_any": False},
|
|
52
|
+
"applies": {}, "installer": "npm",
|
|
53
|
+
"package": "codindex", "source": "https://github.com/Bencibr/codindex",
|
|
54
|
+
"trust": "B",
|
|
55
|
+
"audit": ("codindex@0.1.2(MIT)固定 npm dist.integrity;Node >=22.5。"
|
|
56
|
+
"包的 MCP 握手在 npm --ignore-scripts 临时安装后通过;"
|
|
57
|
+
"运行默认走 Node 内置 node:sqlite,不设置 CODINDEX_SQLITE=better-sqlite3,"
|
|
58
|
+
"避免 better-sqlite3 原生 ABI 与安装脚本成为启动前置条件。"),
|
|
59
|
+
},
|
|
49
60
|
{
|
|
50
61
|
"name": "bugx-docs", "tier": "optional", "status": "active",
|
|
51
62
|
"credentials": {"env": (), "require_any": False},
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""core/host_runtime/pi.py - Pi 宿主 Worker 预算透传执行器。
|
|
3
|
+
|
|
4
|
+
**实现体**,不是声明点:预算基数(600s)声明在 ``core/hosts/pi.py`` 的
|
|
5
|
+
``WorkerRuntimeFacet.worker_timeout_seconds``;本模块只把它接到引擎默认执行器上。
|
|
6
|
+
|
|
7
|
+
集成验证实测根因(2026-11-17):pi 此前无 ``runner_module``,Worker 由引擎默认
|
|
8
|
+
执行器 ``worker_runtime._execute_autonomous_worker`` 驱动,模型 CLI 超时回落
|
|
9
|
+
tier 阶梯(recon=180s)。codex 模型在 checkpoint 准备阶段超过 180s 即被
|
|
10
|
+
``run_model`` 击杀(与 E1 cline FAIL 同根因,build.566 只覆盖了 cline)。
|
|
11
|
+
|
|
12
|
+
设计边界:
|
|
13
|
+
|
|
14
|
+
* **不复制审计逻辑**:心跳保活、artifact、差分验证、checkpoint、UCB1 记账
|
|
15
|
+
仍由 ``worker_runtime._execute_autonomous_worker`` 独家承载;本模块只注入
|
|
16
|
+
预算基数。
|
|
17
|
+
* **注入通道**是 ``resolve_worker_timeout`` 的设计扩展点 ``BUGX_WORKER_TIMEOUT``
|
|
18
|
+
环境变量(``core/supervisor/worker_runtime.py``:无 ``base_override`` 时以其
|
|
19
|
+
为基准基数)。预算只在委托调用窗口内生效:入口保存、``finally`` 恢复,
|
|
20
|
+
异常路径同样恢复;窗口外进程 env 与调用前逐字节一致。
|
|
21
|
+
* **语义与 cline 的 ``base_override`` 逐字节一致**:``600 * 1.5**(attempt-1)``
|
|
22
|
+
重试退避保留、exploit 保底 600s、``[10s, 1800s]`` 钳制;profile 预算优先于
|
|
23
|
+
用户全局 ``BUGX_WORKER_TIMEOUT``(宿主事实比全局 env 更具体,字段契约见
|
|
24
|
+
``core/hosts/base.py``)——注入窗口内 env 即 profile 值。
|
|
25
|
+
* **并发安全**:pi 声明 ``mode="serial"`` 且 ``max_concurrency=1``,进程池逃逸口
|
|
26
|
+
的单批并发上限也取 ``worker_runtime.max_concurrency``(即 1);引擎进程单宿主
|
|
27
|
+
会话语义保证窗口内不存在其他 ``resolve_worker_timeout`` 并发调用者。
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
from __future__ import annotations
|
|
31
|
+
|
|
32
|
+
import os
|
|
33
|
+
from pathlib import Path
|
|
34
|
+
from typing import Any
|
|
35
|
+
|
|
36
|
+
import core.hosts as host_plugins
|
|
37
|
+
|
|
38
|
+
__all__ = ["execute_worker", "profile_budget_base"]
|
|
39
|
+
|
|
40
|
+
#: 引擎默认执行器的预算基准环境变量(``resolve_worker_timeout`` 扩展点)。
|
|
41
|
+
_TIMEOUT_ENV = "BUGX_WORKER_TIMEOUT"
|
|
42
|
+
|
|
43
|
+
#: 宿主名由模块名派生(``core/host_runtime/<host>.py``),实现体不写字面量。
|
|
44
|
+
_HOST_NAME = __name__.rsplit(".", 1)[-1]
|
|
45
|
+
_PLUGIN = host_plugins.get(_HOST_NAME)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def profile_budget_base() -> float | None:
|
|
49
|
+
"""宿主 profile 预算基数(``worker_timeout_seconds``)的正数规范化。
|
|
50
|
+
|
|
51
|
+
与 ``core/host_runtime/cline.py`` 的 ``base_override`` 归一化同规则:
|
|
52
|
+
非 int/float、bool、非正数一律回 ``None``(维持引擎 tier 阶梯既有行为)。
|
|
53
|
+
"""
|
|
54
|
+
budget = getattr(_PLUGIN.worker_runtime, "worker_timeout_seconds", None)
|
|
55
|
+
if isinstance(budget, bool) or not isinstance(budget, (int, float)):
|
|
56
|
+
return None
|
|
57
|
+
budget = float(budget)
|
|
58
|
+
return budget if budget > 0 else None
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def execute_worker(
|
|
62
|
+
*,
|
|
63
|
+
workspace_root: Path,
|
|
64
|
+
claim: Any,
|
|
65
|
+
task_spec: str,
|
|
66
|
+
supervisor: Any = None,
|
|
67
|
+
stage_name: str = "00-scope",
|
|
68
|
+
executable: str | None = None,
|
|
69
|
+
model: str | None = None,
|
|
70
|
+
provider: str | None = None,
|
|
71
|
+
) -> dict[str, Any]:
|
|
72
|
+
"""引擎统一 Worker 入口(``worker_runtime._host_runner`` 按名调用)。
|
|
73
|
+
|
|
74
|
+
延迟导入并直接委托引擎默认执行器:公有
|
|
75
|
+
``worker_runtime.execute_autonomous_worker`` 会重新走 ``_host_runner``
|
|
76
|
+
分派回本模块(无限递归),而模块内私有执行器正是 pi 无 runner 时代的
|
|
77
|
+
唯一驱动路径——审计行为零漂移,本模块只叠加预算注入。
|
|
78
|
+
"""
|
|
79
|
+
from core.supervisor.worker_runtime import _execute_autonomous_worker
|
|
80
|
+
|
|
81
|
+
kwargs: dict[str, Any] = dict(
|
|
82
|
+
workspace_root=workspace_root,
|
|
83
|
+
claim=claim,
|
|
84
|
+
task_spec=task_spec,
|
|
85
|
+
stage_name=stage_name,
|
|
86
|
+
provider=provider,
|
|
87
|
+
executable=executable,
|
|
88
|
+
supervisor=supervisor,
|
|
89
|
+
scheduler=None,
|
|
90
|
+
)
|
|
91
|
+
budget = profile_budget_base()
|
|
92
|
+
if budget is None:
|
|
93
|
+
return _execute_autonomous_worker(**kwargs)
|
|
94
|
+
saved = os.environ.get(_TIMEOUT_ENV)
|
|
95
|
+
os.environ[_TIMEOUT_ENV] = str(budget)
|
|
96
|
+
try:
|
|
97
|
+
return _execute_autonomous_worker(**kwargs)
|
|
98
|
+
finally:
|
|
99
|
+
if saved is None:
|
|
100
|
+
os.environ.pop(_TIMEOUT_ENV, None)
|
|
101
|
+
else:
|
|
102
|
+
os.environ[_TIMEOUT_ENV] = saved
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""provider_facts.py - 宿主通道可用性事实共享提取模块(E1 观察 #2 评估层补全)。
|
|
3
|
+
|
|
4
|
+
bugx 受控事实库(存储侧 0600 落盘):~/.bugx/facts/cline_provider_facts.json。
|
|
5
|
+
通道声明未携带余额字段时,从这里读取机器本地实测可用性事实;用户充值/事实变化后
|
|
6
|
+
删除或改写该文件即可恢复通道优先级(显式通道声明优先于本文件)。
|
|
7
|
+
|
|
8
|
+
消费方(依赖方向单向,本模块仅依赖标准库,处于依赖图叶子,可被上下游同时导入):
|
|
9
|
+
- host_provider_arbitrator(聚合层守卫:rank 分区降级留痕);
|
|
10
|
+
- host_evaluators.evaluate_cline_provider(评估层守卫:is_free_model 命名短路判定
|
|
11
|
+
前查事实,credits 耗尽通道跳过 TIER_1_FREE 短路,按常规梯队参与排序)。
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import json
|
|
17
|
+
from collections.abc import Mapping
|
|
18
|
+
from pathlib import Path
|
|
19
|
+
from typing import Any
|
|
20
|
+
|
|
21
|
+
__all__ = [
|
|
22
|
+
"PROVIDER_FACTS_FILE",
|
|
23
|
+
"load_provider_availability_facts",
|
|
24
|
+
"credits_exhausted",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
# bugx 受控事实库路径(存储侧以 0600 权限落盘;读取侧 fail-open:缺失/损坏返回空,不阻断裁决)。
|
|
28
|
+
PROVIDER_FACTS_FILE = Path.home() / ".bugx" / "facts" / "cline_provider_facts.json"
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def load_provider_availability_facts(facts_file: Path | None = None) -> dict[str, Any]:
|
|
32
|
+
"""读取通道可用性事实声明(缺失/损坏时 fail-open 返回空,不阻断裁决)。"""
|
|
33
|
+
path = facts_file or PROVIDER_FACTS_FILE
|
|
34
|
+
try:
|
|
35
|
+
raw = json.loads(path.read_text(encoding="utf-8"))
|
|
36
|
+
except (OSError, ValueError):
|
|
37
|
+
return {}
|
|
38
|
+
provs = raw.get("providers", {}) if isinstance(raw, Mapping) else {}
|
|
39
|
+
return dict(provs) if isinstance(provs, Mapping) else {}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def credits_exhausted(
|
|
43
|
+
p_name: str,
|
|
44
|
+
p_info: Mapping[str, Any],
|
|
45
|
+
external_facts: Mapping[str, Any] | None = None,
|
|
46
|
+
) -> bool:
|
|
47
|
+
"""判定通道是否携带 credits 耗尽 / 0 余额可用性事实。
|
|
48
|
+
|
|
49
|
+
优先级:通道条目显式声明(facts/条目/settings 下的 credits_exhausted 布尔值
|
|
50
|
+
或 balance/credits 数值)> bugx 事实库声明 > 无事实(返回 False,行为不变)。
|
|
51
|
+
"""
|
|
52
|
+
entry = p_info if isinstance(p_info, Mapping) else {}
|
|
53
|
+
settings = entry.get("settings") if isinstance(entry.get("settings"), Mapping) else {}
|
|
54
|
+
facts = entry.get("facts") if isinstance(entry.get("facts"), Mapping) else {}
|
|
55
|
+
for scope in (facts, entry, settings):
|
|
56
|
+
flag = scope.get("credits_exhausted")
|
|
57
|
+
if isinstance(flag, bool):
|
|
58
|
+
return flag
|
|
59
|
+
for key in ("balance", "credits", "credits_remaining", "creditsRemaining"):
|
|
60
|
+
val = scope.get(key)
|
|
61
|
+
if isinstance(val, (int, float)) and not isinstance(val, bool):
|
|
62
|
+
return val <= 0
|
|
63
|
+
prov_fact = (external_facts or {}).get(p_name)
|
|
64
|
+
if isinstance(prov_fact, Mapping):
|
|
65
|
+
return prov_fact.get("credits_exhausted") is True
|
|
66
|
+
return False
|
package/core/hosts/SPEC.md
CHANGED
|
@@ -21,5 +21,5 @@ plugin = get_host_plugin('claude')
|
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
## 5. Maintenance & Verification
|
|
24
|
-
-
|
|
24
|
+
- Verification is performed with short-lived tests outside the repository; no persistent `tests/` registry is retained.
|
|
25
25
|
- Changes to exported interfaces must be synchronized via `python3 scripts/gen_interface_spec.py --package core/hosts --write`.
|
package/core/hosts/__init__.py
CHANGED
|
@@ -59,11 +59,15 @@ __all__ = [
|
|
|
59
59
|
]
|
|
60
60
|
|
|
61
61
|
#: 注册表 schema 版本:``HostPlugin`` 字段/面语义变化时递增。
|
|
62
|
-
|
|
62
|
+
#: v3: ``WorkerRuntimeFacet.worker_timeout_seconds``(单 claim 墙钟预算基数)。
|
|
63
|
+
#: v4: ``McpWriteFacet.config_format`` 新增 ``yaml_patch`` 取值(dsh 用户级 YAML
|
|
64
|
+
#: patch 的解析器声明:探针/诊断按它分派 ``yaml.safe_load``,通用 JSON 骨架
|
|
65
|
+
#: 不得接管;导入期校验强制 bootstrap/remove/inspect 三件套插件自有)。
|
|
66
|
+
REGISTRY_VERSION = 4
|
|
63
67
|
|
|
64
68
|
#: 显式登记为「尚未迁移到插件模型」的受支持宿主(DOC-239 逐宿主切片):
|
|
65
69
|
#: 它们仍能被**识别**(走既有实现),但不得被当成插件 ``ready`` 消费。
|
|
66
|
-
#:
|
|
70
|
+
#: 账目一致性契约以本注释为准(ready/todo/unavailable 与 SUPPORTED_HOSTS 双向核对)。
|
|
67
71
|
TODO_HOSTS: tuple[str, ...] = (
|
|
68
72
|
"chatgpt",
|
|
69
73
|
"workbuddy",
|
package/core/hosts/_dsh_usage.py
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
输出同 _zcode_usage:仅进本地运行态(runtime 报告行 + lifecycle state/dsh-usage.json 明细),绝不上云。
|
|
8
8
|
|
|
9
9
|
宿主插件层只做纯解析与路径推导:解压 `.zstd` 依赖外部进程,由引擎侧注入 `read_lines`
|
|
10
|
-
(宿主模块不得 import subprocess/shutil
|
|
10
|
+
(宿主模块不得 import subprocess/shutil,依赖方向门禁以本注释为契约)。
|
|
11
11
|
"""
|
|
12
12
|
|
|
13
13
|
from __future__ import annotations
|
package/core/hosts/base.py
CHANGED
|
@@ -227,6 +227,13 @@ class WorkerRuntimeFacet:
|
|
|
227
227
|
autonomous_cli: bool = False
|
|
228
228
|
#: CLI ``--workers`` 合法区间(原 ``autonomous`` 的 2~6 硬校验)。
|
|
229
229
|
concurrency_bounds: tuple[int, int] | None = None
|
|
230
|
+
#: 单 claim 墙钟预算基数(秒)。``None`` 表示维持引擎 tier 阶梯与重试退避的
|
|
231
|
+
#: 既有行为(recon 180s / exploit 600s / verify 300s,``1.5**(attempt-1)`` 退避);
|
|
232
|
+
#: 声明了该字段的宿主,其 ``runner_module`` 执行器以它作为
|
|
233
|
+
#: ``resolve_worker_timeout`` 的预算基数(``base_override``),用于慢宿主
|
|
234
|
+
#: (如 cline 全 agent 闭环实测 ~6min)的预算对齐。同一宿主上
|
|
235
|
+
#: ``BUGX_WORKER_TIMEOUT`` 环境变量让位于本字段(宿主事实比全局 env 更具体)。
|
|
236
|
+
worker_timeout_seconds: float | None = None
|
|
230
237
|
|
|
231
238
|
|
|
232
239
|
@dataclass(frozen=True)
|
|
@@ -245,9 +252,15 @@ class McpWriteFacet:
|
|
|
245
252
|
#: 该宿主的 MCP 写入由 CLI 侧专用写入器负责(如 opencode.json 的
|
|
246
253
|
#: permission/plugin 合并)。为真时通用 JSON 骨架不得接管。
|
|
247
254
|
custom_writer: bool = False
|
|
248
|
-
#:
|
|
249
|
-
#: TOML(如 Codex,
|
|
250
|
-
#:
|
|
255
|
+
#: 本 facet 拥有的 MCP 配置文件(项目级路径,或用户级唯一被加载层)的序列化
|
|
256
|
+
#: 格式。``json`` 走通用 JSON 骨架;``toml`` 表示宿主只读 TOML(如 Codex,
|
|
257
|
+
#: 2026-10-23 实测 ``.codex/config.json`` 永不被加载),写入/清理/诊断一律
|
|
258
|
+
#: 委托给 ``bootstrap`` / ``remove`` / ``inspect``;``yaml_patch`` 表示宿主
|
|
259
|
+
#: 配置是 YAML patch(如 dsh 的 cordis patch:``container_key="insert"`` 是
|
|
260
|
+
#: server 条目列表,无 JSON「名字→条目」映射形态),通用 JSON 骨架同样解析
|
|
261
|
+
#: 不了,写入/清理/诊断必须由插件拥有,探针/诊断按本声明分派
|
|
262
|
+
#: ``yaml.safe_load`` 解析——没有该声明时 YAML 会被当 JSON 解析失败而误判
|
|
263
|
+
#: 「未配置」(结构性假阴性)。
|
|
251
264
|
config_format: str = "json"
|
|
252
265
|
#: 引擎侧启动期写入实现:``(root, servers) -> 回执``。用于配置形态无法用
|
|
253
266
|
#: 「JSON 容器键」表达的宿主(如 codex 的 TOML 表 + 运行期回执)。
|
|
@@ -381,7 +394,7 @@ def validate_plugin(plugin: HostPlugin) -> HostPlugin:
|
|
|
381
394
|
f"{identity.name}: mcp_write 必须给出 project_relpath 或 global_scope",
|
|
382
395
|
)
|
|
383
396
|
_require(
|
|
384
|
-
mcp.config_format in {"json", "toml"},
|
|
397
|
+
mcp.config_format in {"json", "toml", "yaml_patch"},
|
|
385
398
|
f"{identity.name}: 非法 mcp_write.config_format: {mcp.config_format!r}",
|
|
386
399
|
)
|
|
387
400
|
if mcp.config_format == "toml":
|
|
@@ -395,6 +408,13 @@ def validate_plugin(plugin: HostPlugin) -> HostPlugin:
|
|
|
395
408
|
str(mcp.project_relpath).endswith(".toml"),
|
|
396
409
|
f"{identity.name}: TOML mcp_write.project_relpath 必须是 .toml 文件",
|
|
397
410
|
)
|
|
411
|
+
if mcp.config_format == "yaml_patch":
|
|
412
|
+
# YAML patch 与 TOML 同类:通用 JSON 骨架读不了它(dsh 的 cordis patch 是
|
|
413
|
+
# 顶层 ``- insert:`` 列表)。写入/清理/诊断三件必须全部由插件拥有,否则
|
|
414
|
+
# CLI 会按 JSON 解析 YAML 并静默跳过,探针则结构性误报「未配置」。
|
|
415
|
+
_require(callable(mcp.bootstrap), f"{identity.name}: yaml_patch mcp_write 必须提供 bootstrap")
|
|
416
|
+
_require(callable(mcp.remove), f"{identity.name}: yaml_patch mcp_write 必须提供 remove")
|
|
417
|
+
_require(callable(mcp.inspect), f"{identity.name}: yaml_patch mcp_write 必须提供 inspect")
|
|
398
418
|
|
|
399
419
|
runtime = plugin.worker_runtime
|
|
400
420
|
assert runtime is not None
|
|
@@ -431,6 +451,14 @@ def validate_plugin(plugin: HostPlugin) -> HostPlugin:
|
|
|
431
451
|
runtime.autonomous_cli,
|
|
432
452
|
f"{identity.name}: 声明 concurrency_bounds 必须同时声明 autonomous_cli",
|
|
433
453
|
)
|
|
454
|
+
if runtime.worker_timeout_seconds is not None:
|
|
455
|
+
budget = runtime.worker_timeout_seconds
|
|
456
|
+
_require(
|
|
457
|
+
isinstance(budget, (int, float))
|
|
458
|
+
and not isinstance(budget, bool)
|
|
459
|
+
and budget > 0,
|
|
460
|
+
f"{identity.name}: worker_timeout_seconds 必须是正数(秒): {budget!r}",
|
|
461
|
+
)
|
|
434
462
|
if runtime.autonomous_cli:
|
|
435
463
|
_require(
|
|
436
464
|
bool(runtime.runner_module),
|
package/core/hosts/claude.py
CHANGED
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
from __future__ import annotations
|
|
25
25
|
|
|
26
|
+
import shutil
|
|
26
27
|
from pathlib import Path
|
|
27
28
|
|
|
28
29
|
from .base import (
|
|
@@ -155,3 +156,57 @@ PLUGIN = HostPlugin(
|
|
|
155
156
|
),
|
|
156
157
|
acp=AcpFacet(plugin=_NAME),
|
|
157
158
|
)
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def is_available() -> tuple[bool, str]:
|
|
162
|
+
"""降级契约:机械探活 Claude Code CLI 是否安装(零子进程 ``shutil.which``)。
|
|
163
|
+
|
|
164
|
+
宿主探活语义:CLI 缺失时 headless(``claude -p``)、自治通道与宿主原生
|
|
165
|
+
Task 派发全部不可用,调用方必须走 ``run_static_degraded`` 输出静态事实
|
|
166
|
+
声明,禁止伪装宿主可用。
|
|
167
|
+
"""
|
|
168
|
+
path = shutil.which("claude")
|
|
169
|
+
if path is None:
|
|
170
|
+
return False, "claude 可执行文件未安装;headless(claude -p)与宿主原生 Task 派发不可用"
|
|
171
|
+
return True, path
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def run_static_degraded(root: Path | None = None) -> dict:
|
|
175
|
+
"""Claude Code CLI 缺失时的静态降级输出:只声明插件事实,绝不伪装宿主健康。
|
|
176
|
+
|
|
177
|
+
输出与宿主真实可用状态字段级可区分:``status="degraded"`` + ``degraded=True``
|
|
178
|
+
+ ``degraded_reason``,且 ``headless_available`` / ``native_task_available``
|
|
179
|
+
跟随真实探活结果,绝不给出虚假的「宿主就绪」结论。
|
|
180
|
+
"""
|
|
181
|
+
available, availability_detail = is_available()
|
|
182
|
+
return {
|
|
183
|
+
"plugin": _NAME,
|
|
184
|
+
"schema_version": 1,
|
|
185
|
+
"success": available,
|
|
186
|
+
"status": "degraded",
|
|
187
|
+
"degraded": True,
|
|
188
|
+
"degraded_reason": (
|
|
189
|
+
"static_facts_only" if available else "claude_cli_not_installed"
|
|
190
|
+
),
|
|
191
|
+
"probe_mode": "static_degraded",
|
|
192
|
+
"headless_available": available,
|
|
193
|
+
"native_task_available": bool(available and PLUGIN.engine_run.native_task),
|
|
194
|
+
"identity": {
|
|
195
|
+
"executable": PLUGIN.identity.executable,
|
|
196
|
+
"aliases": list(PLUGIN.identity.aliases),
|
|
197
|
+
"markers": list(PLUGIN.identity.markers),
|
|
198
|
+
},
|
|
199
|
+
"agent_entry": PLUGIN.install.path,
|
|
200
|
+
"mcp_project_relpath": PLUGIN.mcp_write.project_relpath,
|
|
201
|
+
"mcp_global_scope": PLUGIN.mcp_write.global_scope,
|
|
202
|
+
"findings": [],
|
|
203
|
+
"evidence": {
|
|
204
|
+
"availability_detail": availability_detail,
|
|
205
|
+
"project_root": str(root) if root else None,
|
|
206
|
+
},
|
|
207
|
+
"metadata": {
|
|
208
|
+
"degraded_mode": "static_plugin_facts_only",
|
|
209
|
+
"acp": "unavailable(上游无 ACP 子命令/flag,见 core/host_acp/claude.py)",
|
|
210
|
+
"fallback": "宿主 CLI 缺失时由外层宿主/用户决策接管;BugX 不代装宿主 CLI",
|
|
211
|
+
},
|
|
212
|
+
}
|
package/core/hosts/cline.py
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
``supervisor_host.ClineAdapter`` / ``worker_orchestrator`` 的 ``== "cline"`` 分支。
|
|
8
8
|
旧实现的注释被逐字搬到这里(它们是实测结论,不是解释)。
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
仍然在插件外、由「遗漏普查」登记的 Cline 事实(``OUTSIDE_PLUGIN``
|
|
11
|
+
按文件+符号逐一核对,新增未登记字面量即违反登记契约,以本注释为准):
|
|
12
12
|
|
|
13
13
|
* ``core/worker_runtime.py``:claim 级 ``.cline_data`` 沙箱、凭据同步、provider/model
|
|
14
14
|
对齐——那是**执行器实现**,不是宿主声明;清单与本模块 ``sandbox_sync`` 同源。
|
|
@@ -206,6 +206,10 @@ PLUGIN = HostPlugin(
|
|
|
206
206
|
autonomous_cli=True,
|
|
207
207
|
# 原 ``autonomous`` 的 ``2 <= workers <= 6`` 硬校验。
|
|
208
208
|
concurrency_bounds=(2, 6),
|
|
209
|
+
# 单 claim 墙钟预算:慢模型全 agent 闭环实测 ~6min(22 迭代);原 tier 阶梯
|
|
210
|
+
# recon 180s(attempt=2 退避 270s)会让 worker 在 checkpoint 提交前到点退出
|
|
211
|
+
# (E1 验收 5/5 expired 的直接根因)。
|
|
212
|
+
worker_timeout_seconds=600.0,
|
|
209
213
|
),
|
|
210
214
|
mcp_write=McpWriteFacet(
|
|
211
215
|
container_key="mcpServers",
|
package/core/hosts/codex.py
CHANGED
|
@@ -62,6 +62,7 @@ from __future__ import annotations
|
|
|
62
62
|
|
|
63
63
|
import json
|
|
64
64
|
import os
|
|
65
|
+
import shutil
|
|
65
66
|
import time
|
|
66
67
|
import tomllib
|
|
67
68
|
from pathlib import Path
|
|
@@ -946,3 +947,60 @@ PLUGIN = HostPlugin(
|
|
|
946
947
|
),
|
|
947
948
|
)
|
|
948
949
|
|
|
950
|
+
|
|
951
|
+
def is_available() -> tuple[bool, str]:
|
|
952
|
+
"""降级契约:机械探活 Codex CLI 是否安装(零子进程 ``shutil.which``)。
|
|
953
|
+
|
|
954
|
+
宿主探活语义:CLI 缺失时无头 ``codex exec``、自治通道与宿主原生
|
|
955
|
+
``collaboration.spawn_agent`` 派发全部不可用,调用方必须走
|
|
956
|
+
``run_static_degraded`` 输出静态事实声明,禁止伪装宿主可用。
|
|
957
|
+
"""
|
|
958
|
+
path = shutil.which("codex")
|
|
959
|
+
if path is None:
|
|
960
|
+
return False, "codex 可执行文件未安装;headless(codex exec)与宿主原生 Agent 派发不可用"
|
|
961
|
+
return True, path
|
|
962
|
+
|
|
963
|
+
|
|
964
|
+
def run_static_degraded(root: Path | None = None) -> dict:
|
|
965
|
+
"""Codex CLI 缺失时的静态降级输出:只声明插件事实,绝不伪装宿主健康。
|
|
966
|
+
|
|
967
|
+
输出与宿主真实可用状态字段级可区分:``status="degraded"`` + ``degraded=True``
|
|
968
|
+
+ ``degraded_reason``,且 ``headless_available`` / ``native_task_available``
|
|
969
|
+
跟随真实探活结果;MCP 健康检查在 CLI 缺失时显式声明 ``unknown``。
|
|
970
|
+
"""
|
|
971
|
+
available, availability_detail = is_available()
|
|
972
|
+
return {
|
|
973
|
+
"plugin": _NAME,
|
|
974
|
+
"schema_version": 1,
|
|
975
|
+
"success": available,
|
|
976
|
+
"status": "degraded",
|
|
977
|
+
"degraded": True,
|
|
978
|
+
"degraded_reason": (
|
|
979
|
+
"static_facts_only" if available else "codex_cli_not_installed"
|
|
980
|
+
),
|
|
981
|
+
"probe_mode": "static_degraded",
|
|
982
|
+
"headless_available": available,
|
|
983
|
+
"native_task_available": bool(available and PLUGIN.engine_run.native_task),
|
|
984
|
+
"mcp_health": "unknown" if not available else "not_probed",
|
|
985
|
+
"identity": {
|
|
986
|
+
"executable": PLUGIN.identity.executable,
|
|
987
|
+
"aliases": list(PLUGIN.identity.aliases),
|
|
988
|
+
"markers": list(PLUGIN.identity.markers),
|
|
989
|
+
},
|
|
990
|
+
"agent_entry": PLUGIN.install.path,
|
|
991
|
+
"mcp_project_relpath": PLUGIN.mcp_write.project_relpath,
|
|
992
|
+
"mcp_global_scope": PLUGIN.mcp_write.global_scope,
|
|
993
|
+
"mcp_config_format": getattr(PLUGIN.mcp_write, "config_format", "json"),
|
|
994
|
+
"findings": [],
|
|
995
|
+
"evidence": {
|
|
996
|
+
"availability_detail": availability_detail,
|
|
997
|
+
"codex_home": str(_codex_home()),
|
|
998
|
+
"project_root": str(root) if root else None,
|
|
999
|
+
},
|
|
1000
|
+
"metadata": {
|
|
1001
|
+
"degraded_mode": "static_plugin_facts_only",
|
|
1002
|
+
"acp": "unavailable(机读声明,见 core/host_acp/codex.py)",
|
|
1003
|
+
"fallback": "宿主 CLI 缺失时由外层宿主/用户决策接管;BugX 不代装宿主 CLI",
|
|
1004
|
+
},
|
|
1005
|
+
}
|
|
1006
|
+
|
package/core/hosts/dsh.py
CHANGED
|
@@ -26,6 +26,9 @@
|
|
|
26
26
|
**0 处** 命中项目级 ``.dsh/mcp.json`` —— 那个文件是**死配置**(与 codex
|
|
27
27
|
的 ``.codex/config.json`` 同类陷阱),故 ``mcp_config_paths`` 只声明
|
|
28
28
|
``.dsh/patch.yml``,写入走 ``bootstrap`` 自定义实现。
|
|
29
|
+
用户级 patch 是 YAML(``config_format="yaml_patch"``):探针/诊断按
|
|
30
|
+
该声明分派 ``yaml.safe_load``,不再把 YAML 当 JSON 解析失败后误判
|
|
31
|
+
「未配置」。
|
|
29
32
|
* worker ← dsh 有**完整原生 subagent**(不是「只能串行」):standard preset 的
|
|
30
33
|
``tool-subagent``/``tool-subagent-fork``/``tool-subagent-control`` 等
|
|
31
34
|
5 条 delegation 工具(``backgroundMode: continuable``),故 ``native_task=True``、
|
|
@@ -35,7 +38,7 @@
|
|
|
35
38
|
痕迹(真机 grep)。该事实由 ``core/host_acp/dsh.py`` 以
|
|
36
39
|
``status="unavailable"`` 机读声明。
|
|
37
40
|
|
|
38
|
-
仍然在插件外的 dsh
|
|
41
|
+
仍然在插件外的 dsh 事实(逐文件核对,以本注释为准):
|
|
39
42
|
|
|
40
43
|
* ``src/bugx_cli/commands/agent.command_dsh``:``bugx dsh`` 兼容启动器设置
|
|
41
44
|
``DSH_CWD`` 后 ``exec dsh --profile <p>`` —— 那是**用户交互壳**,不是宿主接线;
|
|
@@ -500,6 +503,11 @@ PLUGIN = HostPlugin(
|
|
|
500
503
|
global_scope="user-profile",
|
|
501
504
|
mirror_relpaths=(),
|
|
502
505
|
requires_absolutize=False,
|
|
506
|
+
# 用户级 cordis.patch.yml 是 YAML patch:顶层是 ``- insert:`` 列表,无
|
|
507
|
+
# JSON「名字→条目」映射形态。声明 ``config_format="yaml_patch"`` 后,
|
|
508
|
+
# ACP 探针/D4 判定与装配门按本声明分派 ``yaml.safe_load``(此前 YAML 被
|
|
509
|
+
# 当 JSON 解析失败,``mcp_configured`` 结构性恒 False 的假阴性即源于此)。
|
|
510
|
+
config_format="yaml_patch",
|
|
503
511
|
# cordis patch 的 insert 段由本插件 bootstrap 负责;通用 JSON 骨架
|
|
504
512
|
# 会把 YAML 当 JSON 解析并静默跳过。
|
|
505
513
|
custom_writer=True,
|
package/core/hosts/opencode.py
CHANGED
|
@@ -20,6 +20,8 @@ import os
|
|
|
20
20
|
from pathlib import Path
|
|
21
21
|
from typing import Iterator
|
|
22
22
|
|
|
23
|
+
from core.infra.json_utils import unique_json_object
|
|
24
|
+
|
|
23
25
|
from .base import (
|
|
24
26
|
AcpFacet,
|
|
25
27
|
EngineRunFacet,
|
|
@@ -131,12 +133,10 @@ def _strip_jsonc_comments_and_trailing_commas(source: str) -> str:
|
|
|
131
133
|
|
|
132
134
|
|
|
133
135
|
def _unique_object(pairs: list[tuple[str, object]]) -> dict[str, object]:
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
result[key] = value
|
|
139
|
-
return result
|
|
136
|
+
return unique_json_object(
|
|
137
|
+
pairs,
|
|
138
|
+
error_factory=lambda key: ValueError(f"duplicate key: {key}"),
|
|
139
|
+
)
|
|
140
140
|
|
|
141
141
|
|
|
142
142
|
def _read_opencode_config(path: Path) -> dict[str, object]:
|