bugx-cli 0.1.0 → 0.1.2
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 +193 -185
- 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/README.md +3 -2
- 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/bugx-social-preview.svg +71 -0
- package/core/assets/bugx-wechat-group.png +0 -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/audit_packs/README.md +2 -0
- package/core/audit_packs/pitfalls/auth_crypto.json +64 -0
- package/core/audit_packs/pitfalls/file_ssrf_cmd.json +64 -0
- package/core/audit_packs/pitfalls/go_backend.json +66 -0
- package/core/audit_packs/pitfalls/java_spring.json +64 -0
- package/core/audit_packs/pitfalls/js_ts_web.json +67 -0
- package/core/audit_packs/pitfalls/python_web.json +82 -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 +81 -11
- package/core/cloud_sync/cloud_onboard.py +42 -1
- package/core/cloud_sync/consent.py +33 -3
- package/core/cloud_sync/flywheel_client.py +186 -15
- 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 +670 -442
- 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 +6 -3
- package/core/launch_phases/SPEC.md +1 -1
- package/core/launch_phases/common.py +21 -2
- package/core/launch_phases/finding_confirm_phase.py +170 -5
- 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 +144 -8
- 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 +66 -36
- package/core/launch_phases/pre_state_builder.py +23 -176
- package/core/launch_phases/report_sharing.py +3 -7
- package/core/launch_phases/round_orchestrator.py +129 -58
- package/core/launch_phases/semantic_recon.py +545 -0
- 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 +13 -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/verify_loop.py +767 -0
- package/core/launch_phases/worker_barriers.py +15 -5
- package/core/launch_phases/worker_orchestrator.py +105 -25
- package/core/launch_phases/worker_prior.py +115 -0
- package/core/ledger/README.md +2 -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 +555 -10
- package/core/ledger/fp_ledger.py +255 -0
- 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 +2 -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 +57 -15
- package/core/planning/prompt_policy_engine.py +386 -0
- 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/README.md +4 -2
- package/core/prompts/command_routing_en.md +2 -2
- package/core/prompts/command_routing_zh.md +2 -2
- package/core/prompts/policies/prompt_policies.json +101 -0
- package/core/prompts/stages/stage_repair.md +1 -1
- package/core/prompts/stages/stage_verify.defensive.md +42 -0
- package/core/prompts/stages/stage_verify.md +44 -0
- 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/report_share.py +0 -8
- 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 +2 -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/pitfall_packs.py +277 -0
- 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/global_telemetry.py +20 -0
- 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 +193 -185
- 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 +172 -69
- package/interfaces/cli/bugx_cli/commands/advisory.py +1 -1
- package/interfaces/cli/bugx_cli/commands/agent.py +461 -134
- package/interfaces/cli/bugx_cli/commands/audit.py +10 -9
- package/interfaces/cli/bugx_cli/commands/autonomous.py +1 -1
- package/interfaces/cli/bugx_cli/commands/cloud.py +31 -22
- 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 +5 -4
- package/interfaces/cli/bugx_cli/commands/lifecycle.py +3 -3
- package/interfaces/cli/bugx_cli/commands/plugin.py +58 -23
- 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/project.py +6 -13
- package/interfaces/cli/bugx_cli/commands/report.py +2 -6
- package/interfaces/cli/bugx_cli/commands/system.py +524 -169
- package/interfaces/cli/bugx_cli/common.py +21 -15
- 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 +35 -16
- 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 +30 -15
- package/pyproject.toml +60 -9
- package/scripts/ensure-python.mjs +7 -7
- package/scripts/sync-version.mjs +10 -21
- package/scripts/test-npm-wrapper.mjs +1 -1
- package/core/assets/bugx-hero-cn.png +0 -0
- package/core/assets/bugx-hero-en.png +0 -0
- 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
|
@@ -150,11 +150,18 @@ class _PayloadLimitError(ValueError):
|
|
|
150
150
|
"""单个 fuzz 样本超过执行边界。"""
|
|
151
151
|
|
|
152
152
|
|
|
153
|
-
def split_argv(
|
|
153
|
+
def split_argv(
|
|
154
|
+
template: str,
|
|
155
|
+
*,
|
|
156
|
+
error_type: type[Exception] = ValueError,
|
|
157
|
+
parse_error_prefix: str = "命令无法解析",
|
|
158
|
+
empty_message: str = "命令不能为空",
|
|
159
|
+
operator_message: str = "命令包含 shell 运算符;如确需使用,请显式传入 --allow-shell",
|
|
160
|
+
) -> list[str]:
|
|
154
161
|
"""解析 argv 模板,并拒绝未授权的 shell 语法。
|
|
155
162
|
|
|
156
|
-
这是全仓命令拆分的唯一实现(QUA-03
|
|
157
|
-
``
|
|
163
|
+
这是全仓命令拆分的唯一实现(QUA-03)。调用方如需领域异常,只能通过
|
|
164
|
+
``error_type`` 和消息参数适配,不得复制 lexer 与运算符校验。
|
|
158
165
|
"""
|
|
159
166
|
lexer = shlex.shlex(template, posix=True, punctuation_chars=_SHELL_PUNCTUATION)
|
|
160
167
|
lexer.whitespace_split = True
|
|
@@ -162,11 +169,11 @@ def split_argv(template: str) -> list[str]:
|
|
|
162
169
|
try:
|
|
163
170
|
argv = list(lexer)
|
|
164
171
|
except ValueError as exc:
|
|
165
|
-
raise
|
|
172
|
+
raise error_type(f"{parse_error_prefix}: {exc}") from exc
|
|
166
173
|
if not argv:
|
|
167
|
-
raise
|
|
174
|
+
raise error_type(empty_message)
|
|
168
175
|
if any(token in _SHELL_OPERATORS for token in argv):
|
|
169
|
-
raise
|
|
176
|
+
raise error_type(operator_message)
|
|
170
177
|
return argv
|
|
171
178
|
|
|
172
179
|
|
|
@@ -1184,5 +1191,101 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
1184
1191
|
return 0
|
|
1185
1192
|
|
|
1186
1193
|
|
|
1194
|
+
def is_available() -> tuple[bool, str]:
|
|
1195
|
+
"""降级契约:机械探活模糊执行前提(解释器 + CPU + 可写临时目录,零子进程)。"""
|
|
1196
|
+
if not sys.executable:
|
|
1197
|
+
return False, "缺少 Python 解释器;模糊目标执行不可用"
|
|
1198
|
+
cpu = os.cpu_count()
|
|
1199
|
+
if not cpu:
|
|
1200
|
+
return False, "无法确定 CPU 数量;并发变异调度不可用"
|
|
1201
|
+
tmp = tempfile.gettempdir()
|
|
1202
|
+
if not os.path.isdir(tmp) or not os.access(tmp, os.W_OK):
|
|
1203
|
+
return False, f"模糊样本临时目录不可写: {tmp}"
|
|
1204
|
+
return True, f"执行前提就绪(cpu={cpu}, tmp={tmp})"
|
|
1205
|
+
|
|
1206
|
+
|
|
1207
|
+
def run_static_degraded(
|
|
1208
|
+
input_path: str | Path | None = None,
|
|
1209
|
+
*,
|
|
1210
|
+
count: int = 8,
|
|
1211
|
+
seed: int | None = None,
|
|
1212
|
+
gap_tokens: list[bytes] | None = None,
|
|
1213
|
+
) -> dict[str, Any]:
|
|
1214
|
+
"""降级契约:只生成变异样本(不执行目标),显式声明为变异发生器自检。
|
|
1215
|
+
|
|
1216
|
+
输出与成功路径(``main`` 的并发轰靶 summary.json 工件)字段级可区分:
|
|
1217
|
+
``status="degraded"`` + ``degraded=True`` + ``degraded_reason`` +
|
|
1218
|
+
``target_executed=False``;只产出变异策略直方图,绝不产出任何
|
|
1219
|
+
「异常样本/crash」结论,禁止把变异发生器自检伪装成模糊测试完成。
|
|
1220
|
+
"""
|
|
1221
|
+
available, availability_detail = is_available()
|
|
1222
|
+
if input_path is None:
|
|
1223
|
+
return {
|
|
1224
|
+
"schema_version": 1,
|
|
1225
|
+
"success": False,
|
|
1226
|
+
"status": "degraded",
|
|
1227
|
+
"degraded": True,
|
|
1228
|
+
"degraded_reason": "seed_input_missing",
|
|
1229
|
+
"probe_mode": "static_degraded",
|
|
1230
|
+
"target_executed": False,
|
|
1231
|
+
"mutations_generated": 0,
|
|
1232
|
+
"strategy_histogram": {},
|
|
1233
|
+
"findings": [],
|
|
1234
|
+
"evidence": {"availability_detail": availability_detail},
|
|
1235
|
+
"metadata": {"degraded_mode": "mutation_generator_selfcheck"},
|
|
1236
|
+
}
|
|
1237
|
+
src = Path(input_path)
|
|
1238
|
+
if not src.is_file():
|
|
1239
|
+
return {
|
|
1240
|
+
"schema_version": 1,
|
|
1241
|
+
"success": False,
|
|
1242
|
+
"status": "degraded",
|
|
1243
|
+
"degraded": True,
|
|
1244
|
+
"degraded_reason": "seed_input_not_found",
|
|
1245
|
+
"probe_mode": "static_degraded",
|
|
1246
|
+
"target_executed": False,
|
|
1247
|
+
"mutations_generated": 0,
|
|
1248
|
+
"strategy_histogram": {},
|
|
1249
|
+
"findings": [],
|
|
1250
|
+
"evidence": {
|
|
1251
|
+
"availability_detail": availability_detail,
|
|
1252
|
+
"seed_input": str(src),
|
|
1253
|
+
},
|
|
1254
|
+
"metadata": {"degraded_mode": "mutation_generator_selfcheck"},
|
|
1255
|
+
}
|
|
1256
|
+
data = src.read_bytes()
|
|
1257
|
+
rng = random.Random(seed if seed is not None else 0)
|
|
1258
|
+
sample_count = max(1, min(int(count), 64))
|
|
1259
|
+
strategy_histogram: dict[str, int] = {}
|
|
1260
|
+
distinct_variants: set[str] = set()
|
|
1261
|
+
for _ in range(sample_count):
|
|
1262
|
+
strategy, variant = mutate(data, rng, gap_tokens)
|
|
1263
|
+
strategy_histogram[strategy] = strategy_histogram.get(strategy, 0) + 1
|
|
1264
|
+
distinct_variants.add(hashlib.sha256(variant).hexdigest())
|
|
1265
|
+
return {
|
|
1266
|
+
"schema_version": 1,
|
|
1267
|
+
"success": True,
|
|
1268
|
+
"status": "degraded",
|
|
1269
|
+
"degraded": True,
|
|
1270
|
+
"degraded_reason": (
|
|
1271
|
+
"static_mode_forced" if available else "target_execution_unavailable"
|
|
1272
|
+
),
|
|
1273
|
+
"probe_mode": "static_degraded",
|
|
1274
|
+
"target_executed": False,
|
|
1275
|
+
"seed_input": str(src),
|
|
1276
|
+
"seed_sha256": hashlib.sha256(data).hexdigest(),
|
|
1277
|
+
"mutations_generated": sample_count,
|
|
1278
|
+
"distinct_variants": len(distinct_variants),
|
|
1279
|
+
"strategy_histogram": strategy_histogram,
|
|
1280
|
+
"findings": [],
|
|
1281
|
+
"evidence": {"availability_detail": availability_detail},
|
|
1282
|
+
"metadata": {
|
|
1283
|
+
"degraded_mode": "mutation_generator_selfcheck",
|
|
1284
|
+
"anomalies_reported": 0,
|
|
1285
|
+
"fallback": "目标执行不可用时只验证变异发生器;禁止产出任何 crash/异常样本结论",
|
|
1286
|
+
},
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
|
|
1187
1290
|
if __name__ == "__main__":
|
|
1188
1291
|
sys.exit(main())
|
|
@@ -328,5 +328,77 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
328
328
|
return 0
|
|
329
329
|
|
|
330
330
|
|
|
331
|
+
def is_available() -> tuple[bool, str]:
|
|
332
|
+
"""降级契约:机械探活推演器前提(纯标准库,零 I/O、零子进程)。"""
|
|
333
|
+
if sys.version_info < (3, 9):
|
|
334
|
+
return False, (
|
|
335
|
+
f"Python 版本过低({sys.version_info[0]}.{sys.version_info[1]});"
|
|
336
|
+
"状态机推演器不可用"
|
|
337
|
+
)
|
|
338
|
+
return True, f"状态机推演器就绪(Python {sys.version_info[0]}.{sys.version_info[1]},纯标准库)"
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
def run_static_degraded(
|
|
342
|
+
transitions_data: list[dict[str, Any]] | None,
|
|
343
|
+
*,
|
|
344
|
+
max_length: int = 4,
|
|
345
|
+
max_sequences: int = 20,
|
|
346
|
+
) -> dict[str, Any]:
|
|
347
|
+
"""降级契约:只做反常序序列生成,不执行 StatefulOracle 目标测试。
|
|
348
|
+
|
|
349
|
+
输出与成功路径(``oracle.test_target`` 的真实目标执行 + 不变量校验结果)
|
|
350
|
+
字段级可区分:``status="degraded"`` + ``degraded=True`` + ``degraded_reason``,
|
|
351
|
+
并显式声明 ``oracle_executed=False``——生成序列只是候选线索,不是漏洞确认。
|
|
352
|
+
"""
|
|
353
|
+
available, availability_detail = is_available()
|
|
354
|
+
transitions_valid = isinstance(transitions_data, list) and any(
|
|
355
|
+
isinstance(item, dict) and item.get("action") for item in transitions_data
|
|
356
|
+
)
|
|
357
|
+
if not transitions_valid:
|
|
358
|
+
return {
|
|
359
|
+
"schema_version": 1,
|
|
360
|
+
"success": False,
|
|
361
|
+
"status": "degraded",
|
|
362
|
+
"degraded": True,
|
|
363
|
+
"degraded_reason": "transitions_empty_or_invalid",
|
|
364
|
+
"probe_mode": "static_degraded",
|
|
365
|
+
"oracle_executed": False,
|
|
366
|
+
"generation": None,
|
|
367
|
+
"findings": [],
|
|
368
|
+
"evidence": {
|
|
369
|
+
"availability_detail": availability_detail,
|
|
370
|
+
"transitions_provided": bool(transitions_data),
|
|
371
|
+
},
|
|
372
|
+
"metadata": {"degraded_mode": "sequence_generation_only"},
|
|
373
|
+
}
|
|
374
|
+
generation = fuzz_transitions(
|
|
375
|
+
transitions_data,
|
|
376
|
+
max_length=max_length,
|
|
377
|
+
max_sequences=max_sequences,
|
|
378
|
+
)
|
|
379
|
+
return {
|
|
380
|
+
"schema_version": 1,
|
|
381
|
+
"success": True,
|
|
382
|
+
"status": "degraded",
|
|
383
|
+
"degraded": True,
|
|
384
|
+
"degraded_reason": (
|
|
385
|
+
"static_mode_forced" if available else "oracle_execution_skipped"
|
|
386
|
+
),
|
|
387
|
+
"probe_mode": "static_degraded",
|
|
388
|
+
"oracle_executed": False,
|
|
389
|
+
"generation": generation,
|
|
390
|
+
"findings": [],
|
|
391
|
+
"evidence": {
|
|
392
|
+
"availability_detail": availability_detail,
|
|
393
|
+
"sequences_generated": generation["total_anomalies_generated"],
|
|
394
|
+
"transitions_count": generation["transitions_count"],
|
|
395
|
+
},
|
|
396
|
+
"metadata": {
|
|
397
|
+
"degraded_mode": "sequence_generation_only",
|
|
398
|
+
"fallback": "生成序列需配合真实目标执行与不变量校验才能确认业务逻辑漏洞",
|
|
399
|
+
},
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
|
|
331
403
|
if __name__ == "__main__":
|
|
332
404
|
sys.exit(main(sys.argv[1:]))
|
|
@@ -24,6 +24,17 @@ UUID_RE = re.compile(
|
|
|
24
24
|
)
|
|
25
25
|
SHA_RE = re.compile(r"(?i)^(?:[0-9a-f]{40}|[0-9a-f]{64})$")
|
|
26
26
|
ROUTE_TEMPLATE_RE = re.compile(r"(?:/:[A-Za-z_][\w-]*|/\{[A-Za-z_][\w-]*\})")
|
|
27
|
+
# 占位符标记语法(F-RSI-20261115-209):只有被显式括号/标记包裹的值才可能是
|
|
28
|
+
# 模板占位符。这是 header 白名单的唯一作用对象——真实 header 值位置上出现的
|
|
29
|
+
# 裸词(如 ``Bearer token``)不是占位符,必须脱敏。
|
|
30
|
+
PLACEHOLDER_MARKER_PATTERN = (
|
|
31
|
+
r"\{\{[^{}\r\n]*\}\}" # {{REDACTED_TOKEN_A}} / {{ token }}
|
|
32
|
+
r"|\$\{[^{}\r\n]*\}" # ${TOKEN}
|
|
33
|
+
r"|<[^<>\r\n]*>" # <token> / <YOUR_TOKEN_HERE>
|
|
34
|
+
r"|\[[^\[\]\r\n]*\]" # [REDACTED]
|
|
35
|
+
r"|__[A-Za-z0-9_]+__" # __TOKEN__
|
|
36
|
+
)
|
|
37
|
+
PLACEHOLDER_MARKER_RE = re.compile(rf"(?i)^(?:{PLACEHOLDER_MARKER_PATTERN})$")
|
|
27
38
|
|
|
28
39
|
API_KEY_RE = re.compile(
|
|
29
40
|
r"(?<![A-Za-z0-9])(?:"
|
|
@@ -69,21 +80,15 @@ ASSIGNMENT_BARE_RE = re.compile(
|
|
|
69
80
|
AUTH_HEADER_RE = re.compile(
|
|
70
81
|
r"(?P<prefix>\b(?:authorization|proxy-authorization)\s*:\s*"
|
|
71
82
|
r"(?:bearer|basic)\s+)"
|
|
72
|
-
r"(?P<value
|
|
83
|
+
r"(?P<value>" + PLACEHOLDER_MARKER_PATTERN + r"|[^\r\n,\}\]\"']+)",
|
|
73
84
|
re.IGNORECASE,
|
|
74
85
|
)
|
|
75
86
|
AUTH_VALUE_HEADER_RE = re.compile(
|
|
76
87
|
r"(?P<prefix>\b(?:x-api-key|x-auth-token|x-access-token|cookie|"
|
|
77
88
|
r"set-cookie)\s*:\s*)"
|
|
78
|
-
r"(?P<value
|
|
89
|
+
r"(?P<value>" + PLACEHOLDER_MARKER_PATTERN + r"|[^\r\n,\}\]\"']+)",
|
|
79
90
|
re.IGNORECASE,
|
|
80
91
|
)
|
|
81
|
-
BEARER_IGNORE_WORDS = frozenset({
|
|
82
|
-
"token", "tokens", "auth", "authentication", "credential", "credentials",
|
|
83
|
-
"scheme", "format", "header", "headers", "type", "mode", "of", "the",
|
|
84
|
-
"a", "an", "to", "for", "in", "is", "was", "and", "or",
|
|
85
|
-
"adm", "admin", "adm9", "user", "guest", "test", "bearer",
|
|
86
|
-
})
|
|
87
92
|
BEARER_RE = re.compile(
|
|
88
93
|
r"(?P<prefix>\bBearer\s+)"
|
|
89
94
|
r"(?P<value>\{\{REDACTED_[A-Z0-9_]+\}\}|[A-Za-z0-9_.\-~+/=:]+)",
|
|
@@ -197,6 +202,11 @@ def is_placeholder(value: str) -> bool:
|
|
|
197
202
|
return bool(PLACEHOLDER_RE.fullmatch(value.strip()))
|
|
198
203
|
|
|
199
204
|
|
|
205
|
+
def _is_placeholder_marker(value: str) -> bool:
|
|
206
|
+
"""True only for explicitly bracketed template markers, never for bare words."""
|
|
207
|
+
return bool(PLACEHOLDER_MARKER_RE.fullmatch(value.strip()))
|
|
208
|
+
|
|
209
|
+
|
|
200
210
|
def _is_hash_or_uuid(value: str) -> bool:
|
|
201
211
|
candidate = value.strip()
|
|
202
212
|
if UUID_RE.fullmatch(candidate) or SHA_RE.fullmatch(candidate):
|
|
@@ -555,7 +565,9 @@ class SecretRedactor:
|
|
|
555
565
|
|
|
556
566
|
def replace_header(match: re.Match[str]) -> str:
|
|
557
567
|
value = match.group("value").strip()
|
|
558
|
-
|
|
568
|
+
# 白名单只抑制显式占位标记;值位置上出现的裸词是真实 header 值,
|
|
569
|
+
# 一律脱敏(F-RSI-20261115-209:`Bearer token` 曾是放行形态)。
|
|
570
|
+
if _is_placeholder_marker(value):
|
|
559
571
|
return match.group(0)
|
|
560
572
|
header = match.group("prefix").lower()
|
|
561
573
|
fallback = "TOKEN" if ("bearer" in header or "auth-token" in header) else "HTTP_AUTH"
|
|
@@ -688,7 +700,7 @@ class SecretRedactor:
|
|
|
688
700
|
for pattern in (AUTH_HEADER_RE, AUTH_VALUE_HEADER_RE, BEARER_RE):
|
|
689
701
|
for match in pattern.finditer(text):
|
|
690
702
|
val = match.group("value").strip()
|
|
691
|
-
if
|
|
703
|
+
if _is_placeholder_marker(val):
|
|
692
704
|
continue
|
|
693
705
|
collect(val)
|
|
694
706
|
for pattern in (ASSIGNMENT_QUOTED_RE, ASSIGNMENT_BARE_RE):
|
package/core/host_acp/SPEC.md
CHANGED
|
@@ -21,5 +21,5 @@ from core.host_acp import AcpSession
|
|
|
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/host_acp --write`.
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
"""core/host_acp/__init__.py - 宿主 ACP 插件注册表(发现即注册)。
|
|
3
3
|
|
|
4
4
|
**新增宿主的完整动作**:在 ``core/host_acp/`` 下加一个模块(导出 ``PLUGIN``),
|
|
5
|
-
再从下面的 ``TODO_HOSTS``
|
|
6
|
-
|
|
5
|
+
再从下面的 ``TODO_HOSTS`` 删掉该宿主名。探针代码一行都不用改——
|
|
6
|
+
「探针源码不得出现宿主字面量」的性质以本注释为契约。
|
|
7
7
|
|
|
8
8
|
失败姿态:注册期不静默跳过任何模块。缺 ``PLUGIN``、重复名字、``ready`` 却没有实现
|
|
9
9
|
``acp_argv``,一律在 import 期 ``RuntimeError``——用声明支持的空实现去跑真实宿主,
|
|
@@ -34,8 +34,8 @@ __all__ = [
|
|
|
34
34
|
REGISTRY_VERSION = 1
|
|
35
35
|
|
|
36
36
|
# 显式登记为「本仓尚未适配 ACP」的受支持宿主。它们是合法一等状态(探针据此直接
|
|
37
|
-
# BLOCKED + adapter_status=todo
|
|
38
|
-
#
|
|
37
|
+
# BLOCKED + adapter_status=todo),不是特权默认值。账目一致性契约(以本注释
|
|
38
|
+
# 为准):ready ∪ todo ∪ unavailable 必须等于
|
|
39
39
|
# ``host_registry.SUPPORTED_HOSTS``,且三者两两不相交。
|
|
40
40
|
# 反例(务必别再把它们混进来):``codex`` 是 ``unavailable``(上游无 ACP 面,
|
|
41
41
|
# 见 ``core/host_acp/codex.py``),不是本仓拖欠的 TODO。
|
package/core/host_acp/claude.py
CHANGED
|
@@ -18,9 +18,12 @@
|
|
|
18
18
|
|
|
19
19
|
from __future__ import annotations
|
|
20
20
|
|
|
21
|
+
import shutil
|
|
22
|
+
from pathlib import Path
|
|
23
|
+
|
|
21
24
|
from .base import AcpPlugin
|
|
22
25
|
|
|
23
|
-
__all__ = ["ClaudeAcpPlugin", "PLUGIN"]
|
|
26
|
+
__all__ = ["ClaudeAcpPlugin", "PLUGIN", "is_available", "run_static_degraded"]
|
|
24
27
|
|
|
25
28
|
#: 宿主名由模块名派生(``core/host_acp/<host>.py``),实现体不写字面量。
|
|
26
29
|
_HOST_NAME = __name__.rsplit(".", 1)[-1]
|
|
@@ -39,3 +42,58 @@ class ClaudeAcpPlugin(AcpPlugin):
|
|
|
39
42
|
|
|
40
43
|
|
|
41
44
|
PLUGIN = ClaudeAcpPlugin
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def is_available() -> tuple[bool, str]:
|
|
48
|
+
"""降级契约:机械探活宿主 CLI 是否安装(零子进程 ``shutil.which``)。
|
|
49
|
+
|
|
50
|
+
ACP 适配器探活语义:宿主 CLI 缺失时本适配器无法拉起任何真实 ACP 会话,
|
|
51
|
+
调用方必须走 :func:`run_static_degraded` 输出静态适配器事实声明;真实 ACP
|
|
52
|
+
可达性(仅 ``acp_status == "ready"`` 的宿主适用)归宿主探活链路验证,
|
|
53
|
+
本函数不发任何子进程。
|
|
54
|
+
"""
|
|
55
|
+
path = shutil.which(PLUGIN.executable)
|
|
56
|
+
if path is None:
|
|
57
|
+
return False, (
|
|
58
|
+
f"{PLUGIN.executable} 可执行文件未安装;ACP 适配器无法拉起真实会话"
|
|
59
|
+
)
|
|
60
|
+
return True, path
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def run_static_degraded(root: Path | None = None) -> dict:
|
|
64
|
+
"""宿主 CLI 缺失/降级时的静态输出:只声明适配器事实,绝不伪装 ACP 会话。
|
|
65
|
+
|
|
66
|
+
与真实 ACP 探活输出字段级可区分:``status="degraded"`` + ``degraded=True``
|
|
67
|
+
+ ``degraded_reason``;``acp_status`` 保持上游机读声明(``unavailable`` =
|
|
68
|
+
宿主产品没有 ACP 协议面,非本仓欠适配),MCP 健康显式 ``unknown``
|
|
69
|
+
(真实可达性归宿主探活链路,本函数不探 MCP、不发子进程)。
|
|
70
|
+
"""
|
|
71
|
+
available, availability_detail = is_available()
|
|
72
|
+
plugin = PLUGIN()
|
|
73
|
+
return {
|
|
74
|
+
"adapter": f"core/host_acp/{plugin.name}.py",
|
|
75
|
+
"plugin": plugin.name,
|
|
76
|
+
"schema_version": 1,
|
|
77
|
+
"success": available,
|
|
78
|
+
"status": "degraded",
|
|
79
|
+
"degraded": True,
|
|
80
|
+
"degraded_reason": (
|
|
81
|
+
"static_facts_only" if available else f"{plugin.name}_cli_not_installed"
|
|
82
|
+
),
|
|
83
|
+
"probe_mode": "static_degraded",
|
|
84
|
+
"acp_status": plugin.status,
|
|
85
|
+
"acp_supported": plugin.supports_acp(),
|
|
86
|
+
"acp_reason": plugin.reason or None,
|
|
87
|
+
"executable": plugin.executable,
|
|
88
|
+
"mcp_health": "unknown",
|
|
89
|
+
"findings": [],
|
|
90
|
+
"evidence": {
|
|
91
|
+
"availability_detail": availability_detail,
|
|
92
|
+
"project_root": str(root) if root else None,
|
|
93
|
+
},
|
|
94
|
+
"metadata": {
|
|
95
|
+
"degraded_mode": "static_adapter_facts_only",
|
|
96
|
+
"mcp_probing": "deferred_to_host_probe_chain",
|
|
97
|
+
"fallback": "宿主 CLI 缺失时由外层宿主/用户决策接管;BugX 不代装宿主 CLI",
|
|
98
|
+
},
|
|
99
|
+
}
|
package/core/host_acp/cline.py
CHANGED
|
@@ -37,7 +37,13 @@ import core.hosts as host_plugins
|
|
|
37
37
|
|
|
38
38
|
from .base import AcpPlugin, McpServersBuilder
|
|
39
39
|
|
|
40
|
-
__all__ = [
|
|
40
|
+
__all__ = [
|
|
41
|
+
"ClineAcpPlugin",
|
|
42
|
+
"CLINE_SANDBOX_SYNC_FILES",
|
|
43
|
+
"PLUGIN",
|
|
44
|
+
"is_available",
|
|
45
|
+
"run_static_degraded",
|
|
46
|
+
]
|
|
41
47
|
|
|
42
48
|
#: 宿主名由模块名派生(``core/host_acp/<host>.py``),实现体不写字面量。
|
|
43
49
|
_HOST_NAME = __name__.rsplit(".", 1)[-1]
|
|
@@ -233,3 +239,60 @@ class ClineAcpPlugin(AcpPlugin):
|
|
|
233
239
|
|
|
234
240
|
|
|
235
241
|
PLUGIN = ClineAcpPlugin
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
def is_available() -> tuple[bool, str]:
|
|
245
|
+
"""降级契约:机械探活宿主 CLI 是否安装(零子进程 ``shutil.which``)。
|
|
246
|
+
|
|
247
|
+
ACP 适配器探活语义:宿主 CLI 缺失时本适配器无法拉起任何真实 ACP 会话,
|
|
248
|
+
调用方必须走 :func:`run_static_degraded` 输出静态适配器事实声明;真实 ACP
|
|
249
|
+
可达性(仅 ``acp_status == "ready"`` 的宿主适用)归宿主探活链路验证,
|
|
250
|
+
本函数不发任何子进程(flag 版本探测 ``probe_host_flags`` 属探活链路的
|
|
251
|
+
慢路径,降级模式不执行)。
|
|
252
|
+
"""
|
|
253
|
+
path = shutil.which(PLUGIN.executable)
|
|
254
|
+
if path is None:
|
|
255
|
+
return False, (
|
|
256
|
+
f"{PLUGIN.executable} 可执行文件未安装;ACP 适配器无法拉起真实会话"
|
|
257
|
+
)
|
|
258
|
+
return True, path
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
def run_static_degraded(root: Path | None = None) -> dict:
|
|
262
|
+
"""宿主 CLI 缺失/降级时的静态输出:只声明适配器事实,绝不伪装 ACP 会话。
|
|
263
|
+
|
|
264
|
+
与真实 ACP 探活输出字段级可区分:``status="degraded"`` + ``degraded=True``
|
|
265
|
+
+ ``degraded_reason``;``acp_status`` 保持机读声明,MCP 健康显式 ``unknown``
|
|
266
|
+
(真实可达性归宿主探活链路,本函数不探 MCP、不发子进程、不跑
|
|
267
|
+
``--help`` flag 探测)。
|
|
268
|
+
"""
|
|
269
|
+
available, availability_detail = is_available()
|
|
270
|
+
plugin = PLUGIN()
|
|
271
|
+
return {
|
|
272
|
+
"adapter": f"core/host_acp/{plugin.name}.py",
|
|
273
|
+
"plugin": plugin.name,
|
|
274
|
+
"schema_version": 1,
|
|
275
|
+
"success": available,
|
|
276
|
+
"status": "degraded",
|
|
277
|
+
"degraded": True,
|
|
278
|
+
"degraded_reason": (
|
|
279
|
+
"static_facts_only" if available else f"{plugin.name}_cli_not_installed"
|
|
280
|
+
),
|
|
281
|
+
"probe_mode": "static_degraded",
|
|
282
|
+
"acp_status": plugin.status,
|
|
283
|
+
"acp_supported": plugin.supports_acp(),
|
|
284
|
+
"acp_reason": plugin.reason or None,
|
|
285
|
+
"executable": plugin.executable,
|
|
286
|
+
"mcp_health": "unknown",
|
|
287
|
+
"findings": [],
|
|
288
|
+
"evidence": {
|
|
289
|
+
"availability_detail": availability_detail,
|
|
290
|
+
"project_root": str(root) if root else None,
|
|
291
|
+
},
|
|
292
|
+
"metadata": {
|
|
293
|
+
"degraded_mode": "static_adapter_facts_only",
|
|
294
|
+
"mcp_probing": "deferred_to_host_probe_chain",
|
|
295
|
+
"flag_probe": "runtime_only(probe_host_flags 需子进程,降级模式不执行)",
|
|
296
|
+
"fallback": "宿主 CLI 缺失时由外层宿主/用户决策接管;BugX 不代装宿主 CLI",
|
|
297
|
+
},
|
|
298
|
+
}
|
package/core/host_acp/codex.py
CHANGED
|
@@ -28,7 +28,7 @@ from typing import Any
|
|
|
28
28
|
|
|
29
29
|
from .base import AcpPlugin, McpServersBuilder
|
|
30
30
|
|
|
31
|
-
__all__ = ["CodexAcpPlugin", "PLUGIN"]
|
|
31
|
+
__all__ = ["CodexAcpPlugin", "PLUGIN", "is_available", "run_static_degraded"]
|
|
32
32
|
|
|
33
33
|
#: 宿主名由模块名派生(``core/host_acp/<host>.py``),实现体不写字面量。
|
|
34
34
|
_HOST_NAME = __name__.rsplit(".", 1)[-1]
|
|
@@ -243,3 +243,58 @@ class CodexAcpPlugin(AcpPlugin):
|
|
|
243
243
|
|
|
244
244
|
#: 注册表按类注册(``_register`` 自己实例化),与 ``opencode``/``cline`` 同形。
|
|
245
245
|
PLUGIN = CodexAcpPlugin
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
def is_available() -> tuple[bool, str]:
|
|
249
|
+
"""降级契约:机械探活宿主 CLI 是否安装(零子进程 ``shutil.which``)。
|
|
250
|
+
|
|
251
|
+
ACP 适配器探活语义:宿主 CLI 缺失时本适配器无法拉起任何真实 ACP 会话,
|
|
252
|
+
调用方必须走 :func:`run_static_degraded` 输出静态适配器事实声明;真实 ACP
|
|
253
|
+
可达性(仅 ``acp_status == "ready"`` 的宿主适用)归宿主探活链路验证,
|
|
254
|
+
本函数不发任何子进程。
|
|
255
|
+
"""
|
|
256
|
+
path = shutil.which(PLUGIN.executable)
|
|
257
|
+
if path is None:
|
|
258
|
+
return False, (
|
|
259
|
+
f"{PLUGIN.executable} 可执行文件未安装;ACP 适配器无法拉起真实会话"
|
|
260
|
+
)
|
|
261
|
+
return True, path
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
def run_static_degraded(root: Path | None = None) -> dict:
|
|
265
|
+
"""宿主 CLI 缺失/降级时的静态输出:只声明适配器事实,绝不伪装 ACP 会话。
|
|
266
|
+
|
|
267
|
+
与真实 ACP 探活输出字段级可区分:``status="degraded"`` + ``degraded=True``
|
|
268
|
+
+ ``degraded_reason``;``acp_status`` 保持上游机读声明(``unavailable`` =
|
|
269
|
+
宿主产品没有 ACP 协议面,非本仓欠适配),MCP 健康显式 ``unknown``
|
|
270
|
+
(真实可达性归宿主探活链路,本函数不探 MCP、不发子进程)。
|
|
271
|
+
"""
|
|
272
|
+
available, availability_detail = is_available()
|
|
273
|
+
plugin = PLUGIN()
|
|
274
|
+
return {
|
|
275
|
+
"adapter": f"core/host_acp/{plugin.name}.py",
|
|
276
|
+
"plugin": plugin.name,
|
|
277
|
+
"schema_version": 1,
|
|
278
|
+
"success": available,
|
|
279
|
+
"status": "degraded",
|
|
280
|
+
"degraded": True,
|
|
281
|
+
"degraded_reason": (
|
|
282
|
+
"static_facts_only" if available else f"{plugin.name}_cli_not_installed"
|
|
283
|
+
),
|
|
284
|
+
"probe_mode": "static_degraded",
|
|
285
|
+
"acp_status": plugin.status,
|
|
286
|
+
"acp_supported": plugin.supports_acp(),
|
|
287
|
+
"acp_reason": plugin.reason or None,
|
|
288
|
+
"executable": plugin.executable,
|
|
289
|
+
"mcp_health": "unknown",
|
|
290
|
+
"findings": [],
|
|
291
|
+
"evidence": {
|
|
292
|
+
"availability_detail": availability_detail,
|
|
293
|
+
"project_root": str(root) if root else None,
|
|
294
|
+
},
|
|
295
|
+
"metadata": {
|
|
296
|
+
"degraded_mode": "static_adapter_facts_only",
|
|
297
|
+
"mcp_probing": "deferred_to_host_probe_chain",
|
|
298
|
+
"fallback": "宿主 CLI 缺失时由外层宿主/用户决策接管;BugX 不代装宿主 CLI",
|
|
299
|
+
},
|
|
300
|
+
}
|
package/core/host_acp/dsh.py
CHANGED
|
@@ -23,9 +23,12 @@
|
|
|
23
23
|
|
|
24
24
|
from __future__ import annotations
|
|
25
25
|
|
|
26
|
+
import shutil
|
|
27
|
+
from pathlib import Path
|
|
28
|
+
|
|
26
29
|
from .base import AcpPlugin
|
|
27
30
|
|
|
28
|
-
__all__ = ["DshAcpPlugin", "PLUGIN"]
|
|
31
|
+
__all__ = ["DshAcpPlugin", "PLUGIN", "is_available", "run_static_degraded"]
|
|
29
32
|
|
|
30
33
|
#: 宿主名由模块名派生(``core/host_acp/<host>.py``),实现体不写字面量。
|
|
31
34
|
_HOST_NAME = __name__.rsplit(".", 1)[-1]
|
|
@@ -46,3 +49,58 @@ class DshAcpPlugin(AcpPlugin):
|
|
|
46
49
|
|
|
47
50
|
|
|
48
51
|
PLUGIN = DshAcpPlugin
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def is_available() -> tuple[bool, str]:
|
|
55
|
+
"""降级契约:机械探活宿主 CLI 是否安装(零子进程 ``shutil.which``)。
|
|
56
|
+
|
|
57
|
+
ACP 适配器探活语义:宿主 CLI 缺失时本适配器无法拉起任何真实 ACP 会话,
|
|
58
|
+
调用方必须走 :func:`run_static_degraded` 输出静态适配器事实声明;真实 ACP
|
|
59
|
+
可达性(仅 ``acp_status == "ready"`` 的宿主适用)归宿主探活链路验证,
|
|
60
|
+
本函数不发任何子进程。
|
|
61
|
+
"""
|
|
62
|
+
path = shutil.which(PLUGIN.executable)
|
|
63
|
+
if path is None:
|
|
64
|
+
return False, (
|
|
65
|
+
f"{PLUGIN.executable} 可执行文件未安装;ACP 适配器无法拉起真实会话"
|
|
66
|
+
)
|
|
67
|
+
return True, path
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def run_static_degraded(root: Path | None = None) -> dict:
|
|
71
|
+
"""宿主 CLI 缺失/降级时的静态输出:只声明适配器事实,绝不伪装 ACP 会话。
|
|
72
|
+
|
|
73
|
+
与真实 ACP 探活输出字段级可区分:``status="degraded"`` + ``degraded=True``
|
|
74
|
+
+ ``degraded_reason``;``acp_status`` 保持上游机读声明(``unavailable`` =
|
|
75
|
+
宿主产品没有 ACP 协议面,非本仓欠适配),MCP 健康显式 ``unknown``
|
|
76
|
+
(真实可达性归宿主探活链路,本函数不探 MCP、不发子进程)。
|
|
77
|
+
"""
|
|
78
|
+
available, availability_detail = is_available()
|
|
79
|
+
plugin = PLUGIN()
|
|
80
|
+
return {
|
|
81
|
+
"adapter": f"core/host_acp/{plugin.name}.py",
|
|
82
|
+
"plugin": plugin.name,
|
|
83
|
+
"schema_version": 1,
|
|
84
|
+
"success": available,
|
|
85
|
+
"status": "degraded",
|
|
86
|
+
"degraded": True,
|
|
87
|
+
"degraded_reason": (
|
|
88
|
+
"static_facts_only" if available else f"{plugin.name}_cli_not_installed"
|
|
89
|
+
),
|
|
90
|
+
"probe_mode": "static_degraded",
|
|
91
|
+
"acp_status": plugin.status,
|
|
92
|
+
"acp_supported": plugin.supports_acp(),
|
|
93
|
+
"acp_reason": plugin.reason or None,
|
|
94
|
+
"executable": plugin.executable,
|
|
95
|
+
"mcp_health": "unknown",
|
|
96
|
+
"findings": [],
|
|
97
|
+
"evidence": {
|
|
98
|
+
"availability_detail": availability_detail,
|
|
99
|
+
"project_root": str(root) if root else None,
|
|
100
|
+
},
|
|
101
|
+
"metadata": {
|
|
102
|
+
"degraded_mode": "static_adapter_facts_only",
|
|
103
|
+
"mcp_probing": "deferred_to_host_probe_chain",
|
|
104
|
+
"fallback": "宿主 CLI 缺失时由外层宿主/用户决策接管;BugX 不代装宿主 CLI",
|
|
105
|
+
},
|
|
106
|
+
}
|