bugx-cli 0.1.3 → 0.1.4
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/core/README.md +5 -3
- package/core/assets/bugx-wechat-group.png +0 -0
- package/core/bugx.md +2 -2
- package/core/bugx_paths.py +10 -2
- package/core/bundled_docs/OVERVIEW.md +310 -0
- package/core/bundled_docs/README.md +10 -0
- package/core/bundled_docs/README_EN.md +278 -0
- package/core/bundled_docs/ai/01_AI_REFERENCE.md +833 -0
- package/core/bundled_docs/ai/02_AI_USAGE.md +161 -0
- package/core/bundled_docs/ai/03_AI_COMMANDS.md +322 -0
- package/core/bundled_docs/guides/01_USER_GUIDE.md +887 -0
- package/core/bundled_docs/guides/02_COMMANDS.md +935 -0
- package/core/bundled_docs/guides/03_TROUBLESHOOTING.md +763 -0
- package/core/bundled_docs/guides/04_CLOUD_AUTH_AND_SYNC_COOKBOOK.md +48 -0
- package/core/bundled_docs/guides/05_HOST_MATRIX_AND_DISPATCH.md +23 -0
- package/core/bundled_docs/guides/06_PROBES_AND_POC_COOKBOOK.md +49 -0
- package/core/bundled_docs/guides/07_LIFECYCLE_AND_RECOVERY_STATES.md +46 -0
- package/core/bundled_docs/guides/08_LESSONS_AND_PRIVACY_BOUNDARY.md +35 -0
- package/core/bundled_docs/hosts/bugx-claude_SKILL.md +326 -0
- package/core/bundled_docs/hosts/bugx-dsh_SKILL.md +229 -0
- package/core/bundled_docs/hosts/bugx-opencode_SKILL.md +129 -0
- package/core/bundled_docs/hosts/bugx-zcode_SKILL.md +459 -0
- package/core/bundled_docs/hosts/bugx_SKILL.md +118 -0
- package/core/bundled_docs/hosts/cline_bugx_SKILL.md +69 -0
- package/core/bundled_docs/hosts/platform_bugx_SKILL.md +50 -0
- package/core/bundled_docs/manifest.json +140 -0
- package/core/bundled_docs/reference/01_ENVIRONMENT_VARIABLES.md +421 -0
- package/core/bundled_docs/reference/04_REPOSITORY_TOPOLOGY.md +180 -0
- package/core/cli-help.txt +7 -3
- package/core/cloud_sync/cloud_client.py +81 -2
- package/core/cloud_sync/endpoint_router.py +22 -9
- package/core/cloud_sync/issue_uploader.py +297 -0
- package/core/cloud_sync/sensitive_filter.py +77 -7
- package/core/contracts/AGENT_GUIDE.md +3 -9
- package/core/contracts/README.md +1 -1
- package/core/contracts/bugx-runtime-contract.md +10 -20
- package/core/contracts/bugx-worker.md +1 -1
- package/core/engine-integrity.json +209 -93
- package/core/host_acp/antigravity.py +153 -0
- package/core/host_runtime/adapters.py +5 -1
- package/core/host_runtime/antigravity.py +162 -0
- package/core/host_runtime/host_bootstrap.py +18 -7
- package/core/host_runtime/host_evaluators.py +4 -4
- package/core/host_runtime/host_registry.py +2 -1
- package/core/host_runtime/mcp_process_tracker.py +30 -3
- package/core/host_runtime/mcp_registry_gate.py +34 -11
- package/core/hosts/antigravity.py +115 -0
- package/core/hosts/codex.py +3 -0
- package/core/hosts/dsh.py +42 -23
- package/core/hosts/minimax.py +5 -4
- package/core/i18n.py +94 -5
- package/core/infra/README.md +1 -1
- package/core/infra/build_info.py +2 -2
- package/core/launch_phases/README.md +2 -2
- package/core/launch_phases/startup_version_gate.py +2 -2
- package/core/launch_phases/supervisor_bridge.py +2 -0
- package/core/launch_phases/supervisor_degraded.py +7 -5
- package/core/ledger/README.md +1 -1
- package/core/locales/en-US.json +3 -3
- package/core/locales/zh-CN.json +3 -3
- package/core/mcp_runtime_support/environment.py +6 -1
- package/core/metadata.txt +1 -1
- package/core/planning/README.md +1 -1
- package/core/planning/prompt_harness.py +2 -2
- package/core/probes/codebase_memory_probe.py +43 -24
- package/core/probes/probe_registry.py +10 -7
- package/core/prompts/command_routing_en.md +6 -5
- package/core/prompts/command_routing_zh.md +6 -5
- package/core/repair/rsi_rounds.py +3 -0
- package/core/repair/self_heal.py +160 -6
- package/core/retrieval/README.md +1 -1
- package/core/runtime/README.md +1 -1
- package/core/runtime/scenario_eval.py +5 -1
- package/core/runtime/tool_install_targets.py +12 -2
- package/core/skills/README.md +4 -2
- package/core/skills/bugx_docs_cloud_sync.py +658 -0
- package/core/skills/bugx_docs_mcp_server.py +966 -140
- package/core/supervisor/README.md +1 -1
- package/core/supervisor/worker_execution.py +16 -3
- package/core/webui/docs_session_service.py +40 -2
- package/core/webui/mcp_inspector.py +6 -6
- package/ecosystem/integrations/cline/skills/bugx/SKILL.md +46 -46
- package/ecosystem/integrations/dsh/agents/bugx.md +2 -1
- package/ecosystem/integrations/dsh/mcp/package.json +1 -1
- package/ecosystem/integrations/dsh/skills/bugx/SKILL.md +5 -5
- package/ecosystem/integrations/dsh/ui/package.json +1 -1
- package/ecosystem/integrations/opencode/bugx-mcp-manifest.json +2 -2
- package/ecosystem/integrations/pi/extensions/bugx/manifest.json +1 -1
- package/ecosystem/integrations/pi/skills/bugx/SKILL.md +5 -5
- package/ecosystem/integrations/qoder/CONNECTORS.md +11 -23
- 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 +8 -7
- 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/agents/bugx-worker.md +14 -18
- package/ecosystem/plugins/bugx/agents/bugx.md +45 -49
- package/ecosystem/plugins/bugx/skills/bugx/SKILL.md +7 -7
- package/ecosystem/plugins/bugx/skills/bugx-zcode/SKILL.md +2 -2
- package/interfaces/cli/bugx_cli/__init__.py +1 -1
- package/interfaces/cli/bugx_cli/cli.py +138 -8
- package/interfaces/cli/bugx_cli/commands/agent.py +376 -69
- package/interfaces/cli/bugx_cli/commands/cloud.py +42 -1
- package/interfaces/cli/bugx_cli/commands/doctor.py +650 -223
- package/interfaces/cli/bugx_cli/commands/guide.py +143 -0
- package/interfaces/cli/bugx_cli/commands/issue.py +262 -0
- package/interfaces/cli/bugx_cli/commands/lifecycle.py +55 -25
- package/interfaces/cli/bugx_cli/commands/plugin.py +295 -54
- package/interfaces/cli/bugx_cli/commands/plugin_antigravity.py +350 -0
- package/interfaces/cli/bugx_cli/commands/plugin_claude.py +2 -2
- package/interfaces/cli/bugx_cli/commands/plugin_kimi.py +154 -62
- package/interfaces/cli/bugx_cli/commands/plugin_minimax.py +308 -108
- package/interfaces/cli/bugx_cli/commands/system.py +11 -1
- package/interfaces/cli/bugx_cli/common.py +39 -8
- package/interfaces/cli/bugx_cli/host_adapters.py +40 -3
- package/interfaces/cli/bugx_cli/hosts/registry.py +3 -2
- package/interfaces/cli/bugx_cli/hosts/template_engine.py +21 -2
- package/interfaces/cli/bugx_cli/infra/__init__.py +4 -0
- package/interfaces/cli/bugx_cli/infra/ai_advisor.py +14 -12
- package/interfaces/cli/bugx_cli/infra/engine_installer.py +76 -10
- package/interfaces/cli/bugx_cli/infra/host_sync.py +66 -1
- package/interfaces/cli/bugx_cli/infra/mcp_advisor.py +240 -50
- package/package.json +3 -2
- package/pyproject.toml +22 -2
- package/scripts/sync-version.mjs +1 -1
- package/skills/README.md +1 -2
- package/skills/platform/bugx/SKILL.md +50 -0
- package/skills/platform/bugx-user/SKILL.md +0 -92
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"""Antigravity ACP adapter.
|
|
2
|
+
|
|
3
|
+
``agy acp`` is a real ACP v1 server. Authentication remains an external
|
|
4
|
+
precondition owned by Antigravity; the adapter must expose the correct command
|
|
5
|
+
and let the probe report ``Authentication required`` instead of hiding it as a
|
|
6
|
+
missing/unsupported ACP implementation.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import json
|
|
12
|
+
import os
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
import sys
|
|
15
|
+
import tempfile
|
|
16
|
+
from typing import Any
|
|
17
|
+
|
|
18
|
+
from .base import AcpPlugin
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class AntigravityAcpPlugin(AcpPlugin):
|
|
22
|
+
name = "antigravity"
|
|
23
|
+
executable = "agy"
|
|
24
|
+
status = "ready"
|
|
25
|
+
supports_project_permissions = False
|
|
26
|
+
|
|
27
|
+
def acp_argv(
|
|
28
|
+
self,
|
|
29
|
+
*,
|
|
30
|
+
model: str | None = None,
|
|
31
|
+
data_dir: Path | str | None = None,
|
|
32
|
+
) -> list[str]:
|
|
33
|
+
# Antigravity exposes no model/data-dir ACP flags. The selected Agent
|
|
34
|
+
# is explicit so ACP cannot silently fall back to the default Agent.
|
|
35
|
+
# The official ACP flag is required for an unattended client to execute
|
|
36
|
+
# MCP calls; otherwise Antigravity emits a permission request that a
|
|
37
|
+
# headless ACP client cannot approve and the tool call is denied.
|
|
38
|
+
del model, data_dir
|
|
39
|
+
return [
|
|
40
|
+
"agy", "acp", "--agent", "BugX",
|
|
41
|
+
"--dangerously-skip-permissions", "--disable-telemetry",
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
def launch_policy(self) -> dict[str, object]:
|
|
45
|
+
return {
|
|
46
|
+
"auto_approve": True,
|
|
47
|
+
"auto_approve_flag": "--dangerously-skip-permissions",
|
|
48
|
+
"model_flag": None,
|
|
49
|
+
"reason": (
|
|
50
|
+
"Antigravity ACP 使用缓存登录凭据;无人值守 MCP 探活必须使用官方 "
|
|
51
|
+
"--dangerously-skip-permissions,否则 ACP 客户端无法批准工具请求;"
|
|
52
|
+
"无凭据时由宿主返回 Authentication required"
|
|
53
|
+
),
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
def ensure_probe_servers(
|
|
57
|
+
self,
|
|
58
|
+
project_root: Path,
|
|
59
|
+
config_paths: tuple[Path, ...],
|
|
60
|
+
servers: dict[str, dict[str, Any]],
|
|
61
|
+
) -> list[str]:
|
|
62
|
+
"""重绑隔离项目的 MCP,并保持 ACP 冷启动的直通引擎启动器。
|
|
63
|
+
|
|
64
|
+
Antigravity 会在 ACP 会话建立前预加载 stdio MCP。探针项目是从真实项目
|
|
65
|
+
复制出来的,不能沿用真实项目的绝对 ``--root``;而通用探针定义使用完整
|
|
66
|
+
``bugx`` CLI,在 Windows 冷启动窗口内又可能超时。因此这里由宿主适配器
|
|
67
|
+
重建三条 BugX 条目:解释器直接执行已安装引擎的 ``skills/*_mcp_server.py``。
|
|
68
|
+
只允许改写探针项目内部的 ``.agents/mcp_config.json``。
|
|
69
|
+
"""
|
|
70
|
+
project_root = Path(project_root).resolve()
|
|
71
|
+
engine_override = os.environ.get("BUGX_GLOBAL_ENGINE_ROOT", "").strip()
|
|
72
|
+
engine_root = (
|
|
73
|
+
Path(engine_override).expanduser().resolve()
|
|
74
|
+
if engine_override
|
|
75
|
+
else (Path.home() / ".bugx" / "core").resolve()
|
|
76
|
+
)
|
|
77
|
+
python = str(Path(sys.executable).resolve())
|
|
78
|
+
expected: dict[str, dict[str, Any]] = {}
|
|
79
|
+
roles = {
|
|
80
|
+
"bugx-supervisor": "host",
|
|
81
|
+
"bugx-supervisor-worker": "worker",
|
|
82
|
+
}
|
|
83
|
+
for name, role in roles.items():
|
|
84
|
+
script = engine_root / "skills" / "bugx_mcp_server.py"
|
|
85
|
+
if not script.is_file():
|
|
86
|
+
raise ValueError(f"Antigravity 探活缺少 BugX 引擎脚本: {script}")
|
|
87
|
+
expected[name] = {
|
|
88
|
+
"type": "stdio",
|
|
89
|
+
"command": python,
|
|
90
|
+
"args": [
|
|
91
|
+
str(script), "serve", "--root", str(project_root),
|
|
92
|
+
"--role", role,
|
|
93
|
+
],
|
|
94
|
+
}
|
|
95
|
+
docs_script = engine_root / "skills" / "bugx_docs_mcp_server.py"
|
|
96
|
+
if not docs_script.is_file():
|
|
97
|
+
raise ValueError(f"Antigravity 探活缺少 BugX 文档引擎脚本: {docs_script}")
|
|
98
|
+
expected["bugx-docs"] = {
|
|
99
|
+
"type": "stdio",
|
|
100
|
+
"command": python,
|
|
101
|
+
"args": [
|
|
102
|
+
str(docs_script), "serve", "--root", str(project_root),
|
|
103
|
+
"--db", str(project_root / ".bugx" / "knowledge" / "docs.sqlite3"),
|
|
104
|
+
],
|
|
105
|
+
}
|
|
106
|
+
# ``servers`` 是探针的通用输入;名称集合仍由探针控制,具体命令由本适配器
|
|
107
|
+
# 收敛为直通引擎定义,避免隐式接受第三方条目。
|
|
108
|
+
names = [name for name in expected if name in servers]
|
|
109
|
+
updated: list[str] = []
|
|
110
|
+
for path in config_paths:
|
|
111
|
+
try:
|
|
112
|
+
resolved = path.resolve()
|
|
113
|
+
except OSError:
|
|
114
|
+
continue
|
|
115
|
+
if project_root not in resolved.parents or resolved.is_symlink() or not resolved.is_file():
|
|
116
|
+
continue
|
|
117
|
+
try:
|
|
118
|
+
payload = json.loads(resolved.read_text(encoding="utf-8"))
|
|
119
|
+
except (OSError, UnicodeError, ValueError):
|
|
120
|
+
continue
|
|
121
|
+
if not isinstance(payload, dict):
|
|
122
|
+
continue
|
|
123
|
+
block = payload.get("mcpServers")
|
|
124
|
+
if not isinstance(block, dict):
|
|
125
|
+
block = {}
|
|
126
|
+
payload["mcpServers"] = block
|
|
127
|
+
changed = False
|
|
128
|
+
for name in names:
|
|
129
|
+
if block.get(name) != expected[name]:
|
|
130
|
+
block[name] = expected[name]
|
|
131
|
+
changed = True
|
|
132
|
+
if name not in updated:
|
|
133
|
+
updated.append(name)
|
|
134
|
+
if not changed:
|
|
135
|
+
continue
|
|
136
|
+
mode = resolved.stat().st_mode & 0o777
|
|
137
|
+
fd, tmp_name = tempfile.mkstemp(
|
|
138
|
+
prefix=f".{resolved.name}.", suffix=".tmp", dir=resolved.parent,
|
|
139
|
+
)
|
|
140
|
+
tmp = Path(tmp_name)
|
|
141
|
+
try:
|
|
142
|
+
with os.fdopen(fd, "w", encoding="utf-8") as stream:
|
|
143
|
+
stream.write(json.dumps(payload, ensure_ascii=False, indent=2) + "\n")
|
|
144
|
+
stream.flush()
|
|
145
|
+
os.fsync(stream.fileno())
|
|
146
|
+
os.chmod(tmp, mode)
|
|
147
|
+
os.replace(tmp, resolved)
|
|
148
|
+
finally:
|
|
149
|
+
tmp.unlink(missing_ok=True)
|
|
150
|
+
return updated
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
PLUGIN = AntigravityAcpPlugin
|
|
@@ -49,6 +49,8 @@ class HostAdapter:
|
|
|
49
49
|
name = "unknown"
|
|
50
50
|
executable = ""
|
|
51
51
|
host_surface = "tui"
|
|
52
|
+
mcp_config_container: str | None = None
|
|
53
|
+
merge_mcp_config_fields = True
|
|
52
54
|
|
|
53
55
|
def is_callable(self, root: Path) -> bool:
|
|
54
56
|
"""Return whether this host has a callable local entry point.
|
|
@@ -246,6 +248,8 @@ class QoderAdapter(HostAdapter):
|
|
|
246
248
|
|
|
247
249
|
name = "qoder"
|
|
248
250
|
executable = "qoder"
|
|
251
|
+
mcp_config_container = "mcpServers"
|
|
252
|
+
merge_mcp_config_fields = False
|
|
249
253
|
|
|
250
254
|
def headless_run(self, root: Path, agent: str, session: str, prompt: str) -> list[str]:
|
|
251
255
|
return ["qoder", "run", "--prompt", prompt]
|
|
@@ -254,7 +258,7 @@ class QoderAdapter(HostAdapter):
|
|
|
254
258
|
return root / ".qoder"
|
|
255
259
|
|
|
256
260
|
def mcp_config_paths(self, root: Path) -> tuple[Path, ...]:
|
|
257
|
-
return (root / ".qoder" / "mcp.json"
|
|
261
|
+
return (root / ".qoder" / "settings.json", root / ".mcp.json")
|
|
258
262
|
|
|
259
263
|
def required_mcp(self, root: Path) -> list[str]:
|
|
260
264
|
return list(MCP_CATALOG)
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Antigravity Worker process executor.
|
|
3
|
+
|
|
4
|
+
The Agent, not this module, owns the BugX lifecycle decisions. This module
|
|
5
|
+
only starts one bounded ``agy`` Worker process after a claim exists, binds it to
|
|
6
|
+
the requested workspace, and refuses to report success without a Supervisor
|
|
7
|
+
checkpoint.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
import os
|
|
13
|
+
import shutil
|
|
14
|
+
import subprocess
|
|
15
|
+
from pathlib import Path
|
|
16
|
+
from typing import Any
|
|
17
|
+
|
|
18
|
+
import core.hosts as host_plugins
|
|
19
|
+
|
|
20
|
+
from .common import (
|
|
21
|
+
WorkerRuntimeError,
|
|
22
|
+
claim_checkpoint_id,
|
|
23
|
+
terminate_process_group,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
__all__ = ["execute_worker"]
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
_HOST_NAME = __name__.rsplit(".", 1)[-1]
|
|
30
|
+
_PLUGIN = host_plugins.get(_HOST_NAME)
|
|
31
|
+
if _PLUGIN is None: # pragma: no cover - plugin removal is an import-time defect
|
|
32
|
+
raise RuntimeError(f"{__name__} 需要 core/hosts/{_HOST_NAME}.py 声明;插件缺失")
|
|
33
|
+
|
|
34
|
+
_NAME = _PLUGIN.name
|
|
35
|
+
_PROVIDER_KEY = _PLUGIN.worker_runtime.provider_key or _NAME
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def execute_worker(
|
|
39
|
+
workspace_root: Path,
|
|
40
|
+
claim: Any,
|
|
41
|
+
task_spec: str,
|
|
42
|
+
*,
|
|
43
|
+
supervisor: Any,
|
|
44
|
+
stage_name: str,
|
|
45
|
+
executable: str | None = None,
|
|
46
|
+
model: str | None = None,
|
|
47
|
+
provider: str | None = None,
|
|
48
|
+
) -> dict[str, Any]:
|
|
49
|
+
"""Run one pre-claimed Antigravity Worker and require a checkpoint."""
|
|
50
|
+
|
|
51
|
+
del provider
|
|
52
|
+
from core.supervisor.worker_runtime import resolve_worker_timeout
|
|
53
|
+
|
|
54
|
+
failure = f"{_NAME}_worker_failed"
|
|
55
|
+
root = workspace_root.resolve()
|
|
56
|
+
worker_id = getattr(claim, "worker_id", str(claim))
|
|
57
|
+
execution_id = getattr(claim, "execution_id", f"exec-{worker_id}")
|
|
58
|
+
artifact_root_rel = getattr(claim, "artifact_root", "")
|
|
59
|
+
if artifact_root_rel:
|
|
60
|
+
artifact_dir = (root / artifact_root_rel).resolve()
|
|
61
|
+
if artifact_dir != root and root not in artifact_dir.parents:
|
|
62
|
+
raise WorkerRuntimeError(f"{failure}: claim artifact_root 越界")
|
|
63
|
+
artifact_dir.mkdir(parents=True, exist_ok=True)
|
|
64
|
+
|
|
65
|
+
profile_budget = getattr(_PLUGIN.worker_runtime, "worker_timeout_seconds", None)
|
|
66
|
+
base_override = (
|
|
67
|
+
float(profile_budget)
|
|
68
|
+
if isinstance(profile_budget, (int, float))
|
|
69
|
+
and not isinstance(profile_budget, bool)
|
|
70
|
+
and profile_budget > 0
|
|
71
|
+
else None
|
|
72
|
+
)
|
|
73
|
+
timeout_seconds = resolve_worker_timeout(
|
|
74
|
+
model_tier={
|
|
75
|
+
"exploit": "tier_2_exploit",
|
|
76
|
+
"verify": "tier_3_verify",
|
|
77
|
+
}.get(str(stage_name).split("-")[-1], "tier_1_recon"),
|
|
78
|
+
attempt=int(getattr(claim, "attempt", 1) or 1),
|
|
79
|
+
base_override=base_override,
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
host_executable = executable or shutil.which("agy") or "agy"
|
|
83
|
+
command = [
|
|
84
|
+
host_executable,
|
|
85
|
+
"--agent", "bugx-worker",
|
|
86
|
+
"--mode", "auto",
|
|
87
|
+
"--dangerously-skip-permissions",
|
|
88
|
+
"--add-dir", str(root),
|
|
89
|
+
"--output-format", "json",
|
|
90
|
+
"-p", task_spec,
|
|
91
|
+
]
|
|
92
|
+
if model:
|
|
93
|
+
command[3:3] = ["--model", str(model)]
|
|
94
|
+
|
|
95
|
+
environment = os.environ.copy()
|
|
96
|
+
popen_kwargs: dict[str, Any] = {
|
|
97
|
+
"cwd": str(root),
|
|
98
|
+
"env": environment,
|
|
99
|
+
"stdout": subprocess.PIPE,
|
|
100
|
+
"stderr": subprocess.PIPE,
|
|
101
|
+
"text": True,
|
|
102
|
+
}
|
|
103
|
+
if os.name == "posix":
|
|
104
|
+
popen_kwargs["preexec_fn"] = os.setsid
|
|
105
|
+
elif os.name == "nt": # pragma: no cover - exercised on Windows hosts
|
|
106
|
+
popen_kwargs["creationflags"] = getattr(subprocess, "CREATE_NEW_PROCESS_GROUP", 0)
|
|
107
|
+
|
|
108
|
+
process = subprocess.Popen(command, **popen_kwargs)
|
|
109
|
+
try:
|
|
110
|
+
supervisor.start_worker(
|
|
111
|
+
worker_id,
|
|
112
|
+
provider=_PROVIDER_KEY,
|
|
113
|
+
execution_id=execution_id,
|
|
114
|
+
process_pid=process.pid,
|
|
115
|
+
)
|
|
116
|
+
except Exception:
|
|
117
|
+
terminate_process_group(process)
|
|
118
|
+
try:
|
|
119
|
+
process.communicate(timeout=5)
|
|
120
|
+
except (subprocess.TimeoutExpired, OSError):
|
|
121
|
+
terminate_process_group(process, force=True)
|
|
122
|
+
raise
|
|
123
|
+
|
|
124
|
+
try:
|
|
125
|
+
stdout, stderr = process.communicate(timeout=timeout_seconds)
|
|
126
|
+
except subprocess.TimeoutExpired as exc:
|
|
127
|
+
terminate_process_group(process)
|
|
128
|
+
try:
|
|
129
|
+
stdout, stderr = process.communicate(timeout=5)
|
|
130
|
+
except (subprocess.TimeoutExpired, OSError):
|
|
131
|
+
terminate_process_group(process, force=True)
|
|
132
|
+
stdout, stderr = "", ""
|
|
133
|
+
checkpoint_id = claim_checkpoint_id(supervisor, worker_id, execution_id)
|
|
134
|
+
if checkpoint_id is None:
|
|
135
|
+
raise WorkerRuntimeError(
|
|
136
|
+
f"{failure}: timeout after {timeout_seconds:.1f}s"
|
|
137
|
+
) from exc
|
|
138
|
+
return {
|
|
139
|
+
"worker_id": worker_id,
|
|
140
|
+
"checkpoint_id": checkpoint_id,
|
|
141
|
+
"status": "checkpointed",
|
|
142
|
+
"exit_code": process.returncode,
|
|
143
|
+
"stdout": (stdout or "")[-2000:],
|
|
144
|
+
"stderr": (stderr or "")[-2000:],
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
checkpoint_id = claim_checkpoint_id(supervisor, worker_id, execution_id)
|
|
148
|
+
if checkpoint_id is None:
|
|
149
|
+
detail = (stderr or stdout or "").strip()[-500:]
|
|
150
|
+
raise WorkerRuntimeError(
|
|
151
|
+
f"{failure}: process exited without a valid Checkpoint"
|
|
152
|
+
+ (f": {detail}" if detail else "")
|
|
153
|
+
)
|
|
154
|
+
return {
|
|
155
|
+
"worker_id": worker_id,
|
|
156
|
+
"checkpoint_id": checkpoint_id,
|
|
157
|
+
"status": "checkpointed",
|
|
158
|
+
"exit_code": process.returncode,
|
|
159
|
+
"stdout": (stdout or "")[-2000:],
|
|
160
|
+
"stderr": (stderr or "")[-2000:],
|
|
161
|
+
}
|
|
162
|
+
|
|
@@ -189,8 +189,23 @@ def _extract_json_object(output: str) -> dict | None:
|
|
|
189
189
|
return None
|
|
190
190
|
|
|
191
191
|
|
|
192
|
-
def _builtin_mcp_servers(
|
|
193
|
-
""
|
|
192
|
+
def _builtin_mcp_servers(
|
|
193
|
+
*, docs_transport: str = "stdio", remote_url: str | None = None,
|
|
194
|
+
) -> dict[str, dict[str, object]]:
|
|
195
|
+
"""Return the three fixed BugX MCP registrations."""
|
|
196
|
+
if docs_transport == "remote":
|
|
197
|
+
from core.skills.bugx_docs_cloud_sync import contract_version_of, resolve_remote_base_url
|
|
198
|
+
base = resolve_remote_base_url(remote_url)
|
|
199
|
+
ver = contract_version_of()
|
|
200
|
+
docs_entry: dict[str, object] = {
|
|
201
|
+
"url": f"{base}/api/v1/mcp/docs?contract_version={ver}",
|
|
202
|
+
}
|
|
203
|
+
else:
|
|
204
|
+
docs_entry = {
|
|
205
|
+
"command": "bugx",
|
|
206
|
+
"args": ["mcp", "docs", "serve", "--root", ".",
|
|
207
|
+
"--db", ".bugx/knowledge/docs.sqlite3"],
|
|
208
|
+
}
|
|
194
209
|
return {
|
|
195
210
|
"bugx-supervisor": {
|
|
196
211
|
"command": "bugx",
|
|
@@ -200,11 +215,7 @@ def _builtin_mcp_servers() -> dict[str, dict[str, object]]:
|
|
|
200
215
|
"command": "bugx",
|
|
201
216
|
"args": ["mcp", "serve", "--root", ".", "--role", "worker"],
|
|
202
217
|
},
|
|
203
|
-
"bugx-docs":
|
|
204
|
-
"command": "bugx",
|
|
205
|
-
"args": ["mcp", "docs", "serve", "--root", ".",
|
|
206
|
-
"--db", ".bugx/knowledge/docs.sqlite3"],
|
|
207
|
-
},
|
|
218
|
+
"bugx-docs": docs_entry,
|
|
208
219
|
}
|
|
209
220
|
|
|
210
221
|
|
|
@@ -62,13 +62,13 @@ DEFAULT_MODELS_BY_PROVIDER = {
|
|
|
62
62
|
"openai-codex": "gpt-4o",
|
|
63
63
|
"openai-native": "gpt-4o",
|
|
64
64
|
"openai": "gpt-4o",
|
|
65
|
-
"anthropic": "claude-
|
|
66
|
-
"google": "gemini-
|
|
67
|
-
"gemini": "gemini-
|
|
65
|
+
"anthropic": "claude-sonnet-5-5",
|
|
66
|
+
"google": "gemini-4-carbon",
|
|
67
|
+
"gemini": "gemini-4-carbon",
|
|
68
68
|
"deepseek": "deepseek-chat",
|
|
69
69
|
"bigmodel": "GLM-5.3",
|
|
70
70
|
"zai": "glm-4.7",
|
|
71
|
-
"cline": "claude-
|
|
71
|
+
"cline": "claude-sonnet-5-5",
|
|
72
72
|
"9router": "9dev",
|
|
73
73
|
"ocsg": "deepseek-v4.1-flash-1017",
|
|
74
74
|
}
|
|
@@ -40,6 +40,7 @@ SUPPORTED_HOSTS: tuple[str, ...] = (
|
|
|
40
40
|
"dsh",
|
|
41
41
|
"kimi",
|
|
42
42
|
"minimax",
|
|
43
|
+
"antigravity",
|
|
43
44
|
"chatgpt",
|
|
44
45
|
"workbuddy",
|
|
45
46
|
"qoder",
|
|
@@ -66,7 +67,7 @@ HOST_MARKERS: dict[str, tuple[str, ...]] = {
|
|
|
66
67
|
".workbuddy",
|
|
67
68
|
".codebuddy",
|
|
68
69
|
),
|
|
69
|
-
"qoder": (".qoder",
|
|
70
|
+
"qoder": (".qoder",),
|
|
70
71
|
# 真实 Trae / Trae CN 打开过的项目只会有 .trae/ 或 .trae-cn/ 目录;.trea 是 BugX 安装面。
|
|
71
72
|
"trea": (".trea", ".trea/agent.yml", ".trea/mcp.json", ".trae", ".trae-cn"),
|
|
72
73
|
"funide": (".github/agents/bugx.agent.md",),
|
|
@@ -29,7 +29,9 @@ def _config_candidates(root: Path, adapter: HostAdapter) -> tuple[Path, ...]:
|
|
|
29
29
|
return adapter.mcp_config_paths(root)
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
def _read_mcp_document(
|
|
32
|
+
def _read_mcp_document(
|
|
33
|
+
path: Path, *, require_nested_mcp: bool = False, container_key: str | None = None,
|
|
34
|
+
) -> dict:
|
|
33
35
|
try:
|
|
34
36
|
if not path.is_file():
|
|
35
37
|
return {}
|
|
@@ -40,6 +42,9 @@ def _read_mcp_document(path: Path, *, require_nested_mcp: bool = False) -> dict:
|
|
|
40
42
|
data = json.loads(path.read_text(encoding="utf-8"))
|
|
41
43
|
if not isinstance(data, dict):
|
|
42
44
|
return {}
|
|
45
|
+
if container_key is not None:
|
|
46
|
+
servers = data.get(container_key)
|
|
47
|
+
return servers if isinstance(servers, dict) else {}
|
|
43
48
|
if require_nested_mcp and {"plugin", "permission", "tools", "agent"}.intersection(data):
|
|
44
49
|
return {}
|
|
45
50
|
for key in ("mcp", "mcpServers", "mcp_servers"):
|
|
@@ -77,10 +82,13 @@ def _read_mcp_config(root: Path, adapter: HostAdapter) -> dict:
|
|
|
77
82
|
for path in _config_candidates(root, adapter):
|
|
78
83
|
for name, value in _read_mcp_document(
|
|
79
84
|
path, require_nested_mcp=adapter.name == "opencode",
|
|
85
|
+
container_key=adapter.mcp_config_container,
|
|
80
86
|
).items():
|
|
81
87
|
if isinstance(value, dict):
|
|
82
|
-
|
|
83
|
-
|
|
88
|
+
if adapter.merge_mcp_config_fields:
|
|
89
|
+
merged.setdefault(name, {}).update(value)
|
|
90
|
+
else:
|
|
91
|
+
merged[name] = value
|
|
84
92
|
else:
|
|
85
93
|
merged[name] = {"value": value}
|
|
86
94
|
return merged
|
|
@@ -507,3 +515,22 @@ def active_mcp_process_probe(
|
|
|
507
515
|
}
|
|
508
516
|
|
|
509
517
|
|
|
518
|
+
def probe_remote_docs_mcp(
|
|
519
|
+
mcp_config: Mapping[str, Mapping[str, object]],
|
|
520
|
+
) -> dict[str, object]:
|
|
521
|
+
"""检查宿主配置中 bugx-docs 是否为远程 HTTP URL 模式,防止误报缺本地 stdio 进程 (NEG-09)。"""
|
|
522
|
+
cfg = mcp_config.get("bugx-docs")
|
|
523
|
+
if not isinstance(cfg, Mapping) or cfg.get("enabled", True) is False:
|
|
524
|
+
return {"configured": False, "transport": "missing"}
|
|
525
|
+
raw_url = str(cfg.get("url") or "").strip()
|
|
526
|
+
if not raw_url:
|
|
527
|
+
cmd = _configured_server_command(cfg)
|
|
528
|
+
return {"configured": bool(cmd), "transport": "stdio", "command": cmd}
|
|
529
|
+
from core.cloud_sync.endpoint_router import validate_base_url
|
|
530
|
+
try:
|
|
531
|
+
normalized = validate_base_url(raw_url.split("?", 1)[0])
|
|
532
|
+
return {"configured": True, "transport": "remote-http", "url": normalized, "healthy": True}
|
|
533
|
+
except ValueError as exc:
|
|
534
|
+
return {"configured": True, "transport": "remote-http", "url": raw_url, "healthy": False, "error": str(exc)}
|
|
535
|
+
|
|
536
|
+
|
|
@@ -276,14 +276,17 @@ def mcp_tier(name: str) -> str | None:
|
|
|
276
276
|
def host_entry_status(root: Path) -> dict[str, object]:
|
|
277
277
|
"""宿主侧入口(skill/MCP 入口文件)就绪性检查(DOC-236 C7)。
|
|
278
278
|
|
|
279
|
-
数据源:``.bugx/hosts.json``(由 ``bugx install``
|
|
280
|
-
``
|
|
279
|
+
数据源:``.bugx/hosts.json``(由 ``bugx install`` 写入,含语义版本、
|
|
280
|
+
``bugx_build_id`` 与逐文件 ``sha256``)。语义版本和入口文件完整性是硬门禁;
|
|
281
|
+
Build ID 只是构建身份,日常递增不能单独判定宿主入口不兼容。
|
|
281
282
|
|
|
282
283
|
只读、不装配;任何异常一律返回 ``ready=False``(fail-closed,绝不谎报就绪)。
|
|
283
284
|
"""
|
|
284
285
|
import hashlib as _hashlib
|
|
285
286
|
|
|
286
|
-
result: dict[str, object] = {
|
|
287
|
+
result: dict[str, object] = {
|
|
288
|
+
"ready": False, "reason": "", "hosts": [], "stale_files": [], "warnings": [],
|
|
289
|
+
}
|
|
287
290
|
try:
|
|
288
291
|
record_path = Path(root) / ".bugx" / "hosts.json"
|
|
289
292
|
if record_path.is_symlink() or not record_path.is_file():
|
|
@@ -301,19 +304,38 @@ def host_entry_status(root: Path) -> dict[str, object]:
|
|
|
301
304
|
result["reason"] = "宿主入口登记为空(尚未安装任何宿主入口)"
|
|
302
305
|
return result
|
|
303
306
|
|
|
307
|
+
from core.infra.build_info import BASE_VERSION
|
|
308
|
+
|
|
309
|
+
recorded_version = payload.get("bugx_version")
|
|
310
|
+
if not isinstance(recorded_version, str) or not recorded_version:
|
|
311
|
+
result["reason"] = "宿主入口登记缺少语义版本,无法验证入口契约"
|
|
312
|
+
return result
|
|
313
|
+
if recorded_version != BASE_VERSION:
|
|
314
|
+
result["reason"] = (
|
|
315
|
+
f"宿主入口为 {recorded_version},当前引擎为 {BASE_VERSION}"
|
|
316
|
+
"(语义版本不一致,宿主入口需重新装配并重启)"
|
|
317
|
+
)
|
|
318
|
+
return result
|
|
319
|
+
|
|
304
320
|
try:
|
|
305
321
|
from core.infra.build_info import get_build_id as _get_build_id
|
|
306
322
|
current_build = _get_build_id()
|
|
307
|
-
except Exception: # noqa: BLE001 -
|
|
323
|
+
except Exception: # noqa: BLE001 - Build 仅作诊断;身份不可读时不据此阻断
|
|
308
324
|
current_build = None
|
|
309
325
|
recorded_build = payload.get("bugx_build_id")
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
326
|
+
build_matches = (
|
|
327
|
+
isinstance(recorded_build, int) and not isinstance(recorded_build, bool)
|
|
328
|
+
and isinstance(current_build, int) and not isinstance(current_build, bool)
|
|
329
|
+
and recorded_build == current_build
|
|
330
|
+
)
|
|
331
|
+
result["recorded_build_id"] = recorded_build
|
|
332
|
+
result["current_build_id"] = current_build
|
|
333
|
+
result["build_matches"] = build_matches
|
|
334
|
+
if not build_matches:
|
|
335
|
+
result["warnings"].append(
|
|
336
|
+
f"宿主入口装配于 build {recorded_build},当前引擎为 build {current_build}"
|
|
337
|
+
"(构建身份漂移;入口文件与语义契约一致时不阻断)"
|
|
315
338
|
)
|
|
316
|
-
return result
|
|
317
339
|
|
|
318
340
|
stale: list[str] = []
|
|
319
341
|
hosts: list[str] = []
|
|
@@ -345,7 +367,8 @@ def host_entry_status(root: Path) -> dict[str, object]:
|
|
|
345
367
|
result["reason"] = "宿主入口文件缺失或被改动:" + ", ".join(stale[:3])
|
|
346
368
|
return result
|
|
347
369
|
result["ready"] = True
|
|
348
|
-
|
|
370
|
+
build_label = str(recorded_build) if build_matches else f"{recorded_build}→{current_build}"
|
|
371
|
+
result["reason"] = f"宿主入口就绪({', '.join(hosts)};build {build_label})"
|
|
349
372
|
return result
|
|
350
373
|
|
|
351
374
|
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"""Google Antigravity desktop and ``agy`` review/worker integration.
|
|
2
|
+
|
|
3
|
+
Antigravity has two separate configuration surfaces: the user-level plugin
|
|
4
|
+
contains the Agent and Skill, while the workspace-level ``.agents`` file is
|
|
5
|
+
the only safe place for BugX's project-bound MCP servers. Keeping those
|
|
6
|
+
surfaces separate is important because plugin stdio children do not reliably
|
|
7
|
+
inherit the active workspace as their current directory.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
from .base import (
|
|
13
|
+
AcpFacet, EngineRunFacet, HostPlugin, IdentityFacet,
|
|
14
|
+
InstallFacet, McpWriteFacet, RunContext, STATUS_READY, WorkerRuntimeFacet,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
PLUGIN_DIR = ".gemini/config/plugins/bugx-review"
|
|
19
|
+
MANIFEST = "plugin.json"
|
|
20
|
+
AGENT = "agents/bugx-review.md"
|
|
21
|
+
WORKER_AGENT = "agents/bugx-worker.md"
|
|
22
|
+
SKILL = "skills/bugx-review/SKILL.md"
|
|
23
|
+
MCP = "mcp_config.json"
|
|
24
|
+
LOGO = "assets/bugx-avatar.svg"
|
|
25
|
+
PROJECT_MCP = ".agents/mcp_config.json"
|
|
26
|
+
AGENT_ID = "BugX"
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _headless_argv(context: RunContext) -> list[str]:
|
|
30
|
+
"""Build the documented ``agy -p`` headless command.
|
|
31
|
+
|
|
32
|
+
The installed BugX Agent is the stable entry point for this host; callers
|
|
33
|
+
may pass a generic engine agent name, so it is deliberately not forwarded
|
|
34
|
+
to ``agy --agent``.
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
command = [
|
|
38
|
+
"agy", "--agent", AGENT_ID, "--mode", "auto",
|
|
39
|
+
"--add-dir", str(context.root), "--output-format", "json",
|
|
40
|
+
"-p", context.prompt,
|
|
41
|
+
]
|
|
42
|
+
if context.session:
|
|
43
|
+
command[3:3] = ["--conversation", context.session]
|
|
44
|
+
return command
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _autonomous_argv(context: RunContext) -> list[str]:
|
|
48
|
+
"""Build the unattended command with Antigravity's official permission flag."""
|
|
49
|
+
|
|
50
|
+
command = [
|
|
51
|
+
"agy", "--agent", AGENT_ID, "--mode", "auto",
|
|
52
|
+
"--dangerously-skip-permissions", "--add-dir", str(context.root),
|
|
53
|
+
"--output-format", "json", "-p", context.prompt,
|
|
54
|
+
]
|
|
55
|
+
if context.session:
|
|
56
|
+
command[3:3] = ["--conversation", context.session]
|
|
57
|
+
return command
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def _mcp_config_paths(root: Path) -> tuple[Path, ...]:
|
|
61
|
+
"""Return the workspace MCP file consumed by Antigravity."""
|
|
62
|
+
|
|
63
|
+
return (root / PROJECT_MCP,)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def _agent_config_path(_root: Path) -> Path:
|
|
67
|
+
return Path.home() / PLUGIN_DIR / AGENT
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
PLUGIN = HostPlugin(
|
|
71
|
+
identity=IdentityFacet(
|
|
72
|
+
name="antigravity", label="Google Antigravity", order=18, executable="agy",
|
|
73
|
+
# Antigravity 的项目级事实入口是工作区 MCP 文件;插件本体位于用户级
|
|
74
|
+
# ``~/.gemini/config/plugins``,不能拿不存在的项目插件镜像路径做识别 marker。
|
|
75
|
+
markers=(PROJECT_MCP,), aliases=("agy",),
|
|
76
|
+
native_question=False,
|
|
77
|
+
),
|
|
78
|
+
status=STATUS_READY,
|
|
79
|
+
install=InstallFacet(
|
|
80
|
+
kind="plugin", path=f"{PLUGIN_DIR}/{MANIFEST}", entry_mode="user-registration",
|
|
81
|
+
marker=PROJECT_MCP,
|
|
82
|
+
capabilities=frozenset({
|
|
83
|
+
"user-agent-registration", "user-level-plugin", "native-mcp-config",
|
|
84
|
+
}),
|
|
85
|
+
worker_subagent=True,
|
|
86
|
+
worker_entry_path=WORKER_AGENT,
|
|
87
|
+
interaction={"tool": "Antigravity Agent selector"},
|
|
88
|
+
),
|
|
89
|
+
engine_run=EngineRunFacet(
|
|
90
|
+
supports_headless=True,
|
|
91
|
+
headless_argv=_headless_argv,
|
|
92
|
+
autonomous_argv=_autonomous_argv,
|
|
93
|
+
mcp_config_paths=_mcp_config_paths,
|
|
94
|
+
agent_config_path=_agent_config_path,
|
|
95
|
+
host_surface="desktop",
|
|
96
|
+
),
|
|
97
|
+
worker_runtime=WorkerRuntimeFacet(
|
|
98
|
+
mode="serial",
|
|
99
|
+
max_concurrency=1,
|
|
100
|
+
requires_process_mode=True,
|
|
101
|
+
runner_module="host_runtime.antigravity",
|
|
102
|
+
provider_key="antigravity",
|
|
103
|
+
pid_required=True,
|
|
104
|
+
autonomous_cli=True,
|
|
105
|
+
),
|
|
106
|
+
mcp_write=McpWriteFacet(
|
|
107
|
+
container_key="mcpServers", writer_key="antigravity",
|
|
108
|
+
project_relpath=PROJECT_MCP, custom_writer=False, requires_absolutize=True,
|
|
109
|
+
# ``bugx`` imports the complete CLI before handing off to the engine.
|
|
110
|
+
# Antigravity ACP preloads stdio MCP with a short deadline, so the
|
|
111
|
+
# writer must use the direct global-engine script launcher instead.
|
|
112
|
+
entry_extra={"_bugx_direct_engine_script": True},
|
|
113
|
+
),
|
|
114
|
+
acp=AcpFacet(plugin="antigravity"),
|
|
115
|
+
)
|