bugx-cli 0.1.2 → 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/README.md +26 -29
- package/core/README.md +5 -3
- package/core/agent/agent_orchestrator.py +3 -0
- package/core/agent/agent_workspace.py +14 -2
- package/core/assets/bugx-wechat-group.png +0 -0
- package/core/assets/twitter_promo_art.jpg +0 -0
- package/core/assets/twitter_promo_card.svg +166 -0
- package/core/assets/twitter_promo_clean.jpg +0 -0
- package/core/assets/twitter_terminal_real.png +0 -0
- package/core/bugx.md +3 -3
- 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-opencode.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 +267 -111
- package/core/host_acp/antigravity.py +153 -0
- package/core/host_acp/kimi.py +175 -0
- package/core/host_acp/minimax.py +28 -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 +25 -4
- 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 +43 -24
- package/core/hosts/kimi.py +293 -0
- package/core/hosts/minimax.py +249 -0
- package/core/hosts/zcode.py +5 -0
- package/core/i18n.py +94 -5
- package/core/infra/README.md +1 -1
- package/core/infra/build_info.py +30 -5
- 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 +16 -23
- 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 +2 -2
- 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/setup_ui_env.py +4 -7
- 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/cli.py +2 -2
- package/core/supervisor/worker_execution.py +16 -3
- package/core/webui/docs_session_service.py +40 -2
- package/core/webui/mcp_inspector.py +12 -6
- package/core/webui/static/index.html +51 -3
- package/core/webui/static/manifest.webmanifest +1 -1
- package/core/webui/static/project-settings.js +18 -3
- package/core/webui/static/robots.txt +36 -0
- package/core/webui/static/sitemap.xml +15 -0
- package/docs/07_distribution/01_README_NPM.md +26 -29
- package/ecosystem/integrations/cline/skills/bugx/SKILL.md +46 -46
- package/ecosystem/integrations/dsh/agents/bugx.md +2 -1
- package/ecosystem/integrations/dsh/dsh-patch.yml +2 -2
- package/ecosystem/integrations/dsh/mcp/package.json +1 -1
- package/ecosystem/integrations/dsh/skills/bugx/SKILL.md +6 -6
- 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 +2 -2
- package/ecosystem/integrations/pi/extensions/bugx/manifest.json +1 -1
- package/ecosystem/integrations/pi/skills/bugx/SKILL.md +6 -6
- package/ecosystem/integrations/qoder/CONNECTORS.md +11 -23
- package/ecosystem/integrations/qoder/connector-meta.json +9 -9
- package/ecosystem/integrations/workbuddy/connector-meta.json +9 -9
- package/ecosystem/integrations/workbuddy/skills/bugx/SKILL.md +8 -7
- package/ecosystem/plugins/bugx/.claude-plugin/marketplace.json +2 -2
- package/ecosystem/plugins/bugx/.claude-plugin/plugin.json +2 -2
- package/ecosystem/plugins/bugx/.codex-plugin/plugin.json +4 -4
- package/ecosystem/plugins/bugx/.zcode-plugin/plugin.json +2 -2
- 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 +8 -8
- package/ecosystem/plugins/bugx/skills/bugx-claude/SKILL.md +1 -1
- 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 +3 -3
- package/interfaces/bin/bugx.js +2 -0
- package/interfaces/cli/bugx_cli/__init__.py +2 -2
- package/interfaces/cli/bugx_cli/cli.py +153 -8
- package/interfaces/cli/bugx_cli/commands/agent.py +568 -136
- package/interfaces/cli/bugx_cli/commands/cloud.py +42 -1
- package/interfaces/cli/bugx_cli/commands/doctor.py +668 -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 +99 -62
- package/interfaces/cli/bugx_cli/commands/plugin.py +301 -60
- package/interfaces/cli/bugx_cli/commands/plugin_antigravity.py +350 -0
- package/interfaces/cli/bugx_cli/commands/plugin_claude.py +27 -13
- package/interfaces/cli/bugx_cli/commands/plugin_kimi.py +440 -0
- package/interfaces/cli/bugx_cli/commands/plugin_minimax.py +522 -0
- package/interfaces/cli/bugx_cli/commands/plugin_qoder.py +3 -4
- package/interfaces/cli/bugx_cli/commands/plugin_zcode.py +4 -5
- package/interfaces/cli/bugx_cli/commands/system.py +75 -5
- package/interfaces/cli/bugx_cli/common.py +135 -15
- package/interfaces/cli/bugx_cli/host_adapters.py +190 -7
- package/interfaces/cli/bugx_cli/hosts/registry.py +6 -3
- package/interfaces/cli/bugx_cli/hosts/template_engine.py +31 -11
- 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 +242 -52
- package/package.json +38 -13
- package/pyproject.toml +57 -13
- package/scripts/sync-version.mjs +1 -1
- package/skills/README.md +24 -0
- package/skills/platform/bugx/SKILL.md +50 -0
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
"""Install the native Antigravity plugin for defensive code review."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
from core.hosts.antigravity import (
|
|
9
|
+
AGENT, LOGO, MANIFEST, MCP, PLUGIN_DIR, PROJECT_MCP, SKILL, WORKER_AGENT,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
from .. import __version__
|
|
13
|
+
from ..common import CliError
|
|
14
|
+
from ..infra.engine_installer import asset_root, global_engine_root
|
|
15
|
+
from ..infra.security import _assert_no_symlink_components
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
_LEGACY_MCP = json.dumps({"mcpServers": {"docs": {
|
|
19
|
+
"command": "bugx", "args": ["mcp", "docs", "serve", "--root", "."],
|
|
20
|
+
}}}, indent=2) + "\n"
|
|
21
|
+
|
|
22
|
+
# Exact payloads emitted by the first Antigravity adapter revision. They are
|
|
23
|
+
# accepted only as an upgrade input; arbitrary edits to a user's plugin still
|
|
24
|
+
# fail closed instead of being silently overwritten.
|
|
25
|
+
_LEGACY_FILES = {
|
|
26
|
+
AGENT: """---
|
|
27
|
+
name: bugx-review
|
|
28
|
+
description: Review source changes and identify defects in an authorized workspace.
|
|
29
|
+
mainAgent: true
|
|
30
|
+
subagent: false
|
|
31
|
+
inheritMcp: false
|
|
32
|
+
inheritCustomizations: false
|
|
33
|
+
commandExecutionPolicy: 'off'
|
|
34
|
+
skills:
|
|
35
|
+
- skills/bugx-review
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
You are BugX Review. Use the BugX Review skill to inspect the requested workspace scope. Use the plugin's documentation search when the repository's documentation is relevant. Report findings with source locations, impact, and concrete remediation.
|
|
39
|
+
""",
|
|
40
|
+
SKILL: """---
|
|
41
|
+
name: bugx-review
|
|
42
|
+
description: Review authorized source changes for correctness, maintainability, and defensive security.
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
Identify the requested files and the expected behavior. Inspect those files and their immediate callers. Report each defect with an exact source location, its impact, and a remediation. Distinguish source evidence from assumptions and state any verification gaps. This is a read-only review.
|
|
46
|
+
""",
|
|
47
|
+
MANIFEST: json.dumps({
|
|
48
|
+
"name": "bugx-review", "version": __version__,
|
|
49
|
+
"description": "BugX defensive code review and local documentation search.",
|
|
50
|
+
}, indent=2) + "\n",
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
_LEGACY_AGENT_V2 = """---
|
|
54
|
+
name: bugx-review
|
|
55
|
+
description: Review source changes and identify defects in an authorized workspace.
|
|
56
|
+
mainAgent: true
|
|
57
|
+
subagent: false
|
|
58
|
+
inheritMcp: true
|
|
59
|
+
inheritCustomizations: false
|
|
60
|
+
commandExecutionPolicy: 'off'
|
|
61
|
+
skills:
|
|
62
|
+
- skills/bugx-review
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
You are BugX Review. Before doing work, read `bugx engine path --name bugx-runtime-contract.md` and `bugx engine path --name bugx-quick.md`.
|
|
66
|
+
Use the inherited workspace-scoped BugX MCP servers. Use `bugx-docs` for project documentation and `bugx-supervisor` for lifecycle, evidence, checkpoints, findings, and final reporting. Never treat model text, a generated prompt, or a local CLI printout as lifecycle evidence. Report findings with source locations, impact, and concrete remediation.
|
|
67
|
+
|
|
68
|
+
`bugx-docs` is project-scoped: every `resolve_library`, `search_docs`, or `fetch_doc` call MUST include `project_id`. Unless the server instructions explicitly advertise another value, use the current workspace directory name (the scope used by `bugx mcp docs serve`) and never omit the field.
|
|
69
|
+
"""
|
|
70
|
+
|
|
71
|
+
# Exact payload emitted by the immediately preceding managed revision. It is
|
|
72
|
+
# accepted only for this one-way rename so an existing BugX installation can
|
|
73
|
+
# be upgraded from the lowercase identifier without weakening ownership
|
|
74
|
+
# checks for arbitrary user edits.
|
|
75
|
+
_LEGACY_AGENT_BUGX = """---
|
|
76
|
+
name: bugx
|
|
77
|
+
description: Review source changes and identify defects in an authorized workspace.
|
|
78
|
+
mainAgent: true
|
|
79
|
+
subagent: false
|
|
80
|
+
inheritMcp: true
|
|
81
|
+
inheritCustomizations: false
|
|
82
|
+
commandExecutionPolicy: 'off'
|
|
83
|
+
skills:
|
|
84
|
+
- skills/bugx-review
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
You are BugX Review. Before doing work, read `bugx engine path --name bugx-runtime-contract.md` and `bugx engine path --name bugx-quick.md`.
|
|
88
|
+
Use the inherited workspace-scoped BugX MCP servers. Use `bugx-docs` for project documentation and `bugx-supervisor` for lifecycle, evidence, checkpoints, findings, and final reporting. Never treat model text, a generated prompt, or a local CLI printout as lifecycle evidence. Report findings with source locations, impact, and concrete remediation.
|
|
89
|
+
|
|
90
|
+
`bugx-docs` is project-scoped: every `resolve_library`, `search_docs`, or `fetch_doc` call MUST include `project_id`. Unless the server instructions explicitly advertise another value, use the current workspace directory name (the scope used by `bugx mcp docs serve`) and never omit the field.
|
|
91
|
+
"""
|
|
92
|
+
|
|
93
|
+
_LEGACY_MANIFEST_WITH_LOGO = json.dumps({
|
|
94
|
+
"name": "bugx-review", "version": __version__,
|
|
95
|
+
"logo": LOGO,
|
|
96
|
+
"description": "BugX defensive code review and local documentation search.",
|
|
97
|
+
}, indent=2) + "\n"
|
|
98
|
+
|
|
99
|
+
# The old relative MCP config could start the docs server from the plugin
|
|
100
|
+
# directory, leaving only these BugX-owned SQLite artifacts behind. Keep them
|
|
101
|
+
# readable during upgrade (they are no longer loaded); unknown files remain a
|
|
102
|
+
# hard failure.
|
|
103
|
+
_LEGACY_GENERATED = (
|
|
104
|
+
Path(".bugx/knowledge/docs.sqlite3"),
|
|
105
|
+
Path(".bugx/knowledge/docs.sqlite3-shm"),
|
|
106
|
+
Path(".bugx/knowledge/docs.sqlite3-wal"),
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
_FILES = {
|
|
111
|
+
AGENT: """---
|
|
112
|
+
name: BugX
|
|
113
|
+
description: Review source changes and identify defects in an authorized workspace.
|
|
114
|
+
mainAgent: true
|
|
115
|
+
subagent: false
|
|
116
|
+
inheritMcp: true
|
|
117
|
+
inheritCustomizations: false
|
|
118
|
+
commandExecutionPolicy: 'off'
|
|
119
|
+
skills:
|
|
120
|
+
- skills/bugx-review
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
You are BugX Review. Before doing work, read `bugx engine path --name bugx-runtime-contract.md` and `bugx engine path --name bugx-quick.md`.
|
|
124
|
+
Use the inherited workspace-scoped BugX MCP servers. Use `bugx-docs` for project documentation and `bugx-supervisor` for lifecycle, evidence, checkpoints, findings, and final reporting. Never treat model text, a generated prompt, or a local CLI printout as lifecycle evidence. Report findings with source locations, impact, and concrete remediation.
|
|
125
|
+
|
|
126
|
+
`bugx-docs` is project-scoped: every `resolve_library`, `search_docs`, or `fetch_doc` call MUST include `project_id`. Unless the server instructions explicitly advertise another value, use the current workspace directory name (the scope used by `bugx mcp docs serve`) and never omit the field.
|
|
127
|
+
""",
|
|
128
|
+
WORKER_AGENT: """---
|
|
129
|
+
name: bugx-worker
|
|
130
|
+
description: Execute one bounded BugX review claim and return evidence to the Supervisor.
|
|
131
|
+
mainAgent: false
|
|
132
|
+
subagent: true
|
|
133
|
+
inheritMcp: true
|
|
134
|
+
inheritCustomizations: false
|
|
135
|
+
commandExecutionPolicy: 'off'
|
|
136
|
+
skills:
|
|
137
|
+
- skills/bugx-review
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
You are the BugX Worker. Read `bugx engine path --name bugx-worker.md` and `bugx engine path --name bugx-runtime-contract.md` first. Work only on the assigned claim, use `bugx-supervisor-worker` for claim, heartbeat, checkpoint, and finding calls, and never invent a checkpoint or finding. Return bounded evidence and a clear terminal status.
|
|
141
|
+
""",
|
|
142
|
+
SKILL: """---
|
|
143
|
+
name: bugx-review
|
|
144
|
+
description: Review authorized source changes for correctness, maintainability, and defensive security.
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
Identify the requested files and the expected behavior. Inspect those files and their immediate callers. Report each defect with an exact source location, its impact, and a remediation. Distinguish source evidence from assumptions and state any verification gaps. This is a read-only review. When using `bugx-docs`, always include the current workspace directory name as the required `project_id` unless the server advertises a different exact scope.
|
|
148
|
+
""",
|
|
149
|
+
# Project-bound MCP is written to ``<root>/.agents/mcp_config.json`` by
|
|
150
|
+
# the generic host writer. The plugin-level file must not start a server
|
|
151
|
+
# against the plugin/app CWD, so it is intentionally an empty container.
|
|
152
|
+
MCP: json.dumps({"mcpServers": {}}, indent=2) + "\n",
|
|
153
|
+
MANIFEST: json.dumps({
|
|
154
|
+
"name": "bugx-review", "displayName": "BugX", "version": __version__, "logo": LOGO,
|
|
155
|
+
"description": "BugX defensive code review and local documentation search.",
|
|
156
|
+
}, indent=2) + "\n",
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def _logo_source() -> Path:
|
|
161
|
+
"""Return the packaged official BugX avatar used by the plugin manifest."""
|
|
162
|
+
|
|
163
|
+
candidates = (
|
|
164
|
+
asset_root() / "assets" / "bugx-avatar.svg",
|
|
165
|
+
global_engine_root() / "assets" / "bugx-avatar.svg",
|
|
166
|
+
Path(__file__).resolve().parents[4] / "core" / "assets" / "bugx-avatar.svg",
|
|
167
|
+
)
|
|
168
|
+
for candidate in candidates:
|
|
169
|
+
if not candidate.is_symlink() and candidate.is_file():
|
|
170
|
+
return candidate
|
|
171
|
+
raise CliError("找不到 BugX 官方头像资源 bugx-avatar.svg,拒绝安装 Antigravity 插件。")
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def _owned_files() -> dict[str, bytes | str]:
|
|
175
|
+
return {**_FILES, LOGO: _logo_source().read_bytes()}
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def pre_validate() -> None:
|
|
179
|
+
dest = Path.home() / PLUGIN_DIR
|
|
180
|
+
_assert_no_symlink_components(dest)
|
|
181
|
+
owned = _owned_files()
|
|
182
|
+
paths = {dest / relative for relative in owned}
|
|
183
|
+
paths.update(dest / relative for relative in _LEGACY_GENERATED)
|
|
184
|
+
directories = {dest} | {parent for path in paths for parent in path.parents if dest in parent.parents}
|
|
185
|
+
allowed = paths | directories
|
|
186
|
+
for folder in directories:
|
|
187
|
+
_assert_no_symlink_components(folder)
|
|
188
|
+
if folder.exists() and (
|
|
189
|
+
not folder.is_dir() or any(path not in allowed for path in folder.iterdir())
|
|
190
|
+
):
|
|
191
|
+
raise CliError(f"Antigravity 插件目录含有未识别的内容,拒绝覆盖: {folder}")
|
|
192
|
+
for relative, content in owned.items():
|
|
193
|
+
path = dest / relative
|
|
194
|
+
_assert_no_symlink_components(path)
|
|
195
|
+
if not path.exists():
|
|
196
|
+
continue
|
|
197
|
+
if not path.is_file():
|
|
198
|
+
raise CliError(f"Antigravity 插件路径不是普通文件,拒绝覆盖: {path}")
|
|
199
|
+
current = path.read_bytes()
|
|
200
|
+
expected = content if isinstance(content, bytes) else content.encode("utf-8")
|
|
201
|
+
if current != expected:
|
|
202
|
+
# This is the exact MCP file emitted by the previous BugX build.
|
|
203
|
+
# It is accepted only to be replaced during this upgrade; any
|
|
204
|
+
# other foreign content remains a hard failure.
|
|
205
|
+
if relative == LOGO:
|
|
206
|
+
legacy_contents = ()
|
|
207
|
+
elif relative == MCP:
|
|
208
|
+
legacy_contents = (_LEGACY_MCP,)
|
|
209
|
+
else:
|
|
210
|
+
legacy_contents = tuple(
|
|
211
|
+
value for value in (_LEGACY_FILES.get(relative),
|
|
212
|
+
_LEGACY_AGENT_V2 if relative == AGENT else None,
|
|
213
|
+
_LEGACY_AGENT_BUGX if relative == AGENT else None,
|
|
214
|
+
_LEGACY_MANIFEST_WITH_LOGO if relative == MANIFEST else None)
|
|
215
|
+
if value is not None
|
|
216
|
+
)
|
|
217
|
+
if not any(
|
|
218
|
+
current == (value if isinstance(value, bytes) else value.encode("utf-8"))
|
|
219
|
+
for value in legacy_contents
|
|
220
|
+
):
|
|
221
|
+
raise CliError(f"Antigravity 插件路径含有未识别的内容,拒绝覆盖: {path}")
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
def install_review_plugin() -> dict[str, object]:
|
|
225
|
+
from .agent import _atomic_write_global_file_tx
|
|
226
|
+
|
|
227
|
+
pre_validate()
|
|
228
|
+
dest = Path.home() / PLUGIN_DIR
|
|
229
|
+
written = []
|
|
230
|
+
changed_any = False
|
|
231
|
+
for relative, content in _owned_files().items():
|
|
232
|
+
path = dest / relative
|
|
233
|
+
payload = content if isinstance(content, bytes) else content.encode("utf-8")
|
|
234
|
+
created = not path.exists()
|
|
235
|
+
changed = created or path.read_bytes() != payload
|
|
236
|
+
if changed:
|
|
237
|
+
_atomic_write_global_file_tx(path, payload)
|
|
238
|
+
changed_any = True
|
|
239
|
+
written.append({
|
|
240
|
+
"path": str(path),
|
|
241
|
+
"status": "created" if created else "updated" if changed else "unchanged",
|
|
242
|
+
"backup": None, "created": created,
|
|
243
|
+
})
|
|
244
|
+
return {
|
|
245
|
+
"status": "updated" if changed_any else "unchanged",
|
|
246
|
+
"dir": str(dest), "written": written, "backups": [],
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
def _validate_workspace_mcp(root: Path) -> tuple[bool, str]:
|
|
251
|
+
target = root.resolve() / PROJECT_MCP
|
|
252
|
+
if target.is_symlink() or not target.is_file():
|
|
253
|
+
return False, f"缺少项目级 Antigravity MCP 配置: {target}"
|
|
254
|
+
try:
|
|
255
|
+
payload = json.loads(target.read_text(encoding="utf-8"))
|
|
256
|
+
except (OSError, UnicodeDecodeError, json.JSONDecodeError) as exc:
|
|
257
|
+
return False, f"项目级 Antigravity MCP 配置无法解析: {target}: {exc}"
|
|
258
|
+
servers = payload.get("mcpServers") if isinstance(payload, dict) else None
|
|
259
|
+
required = {"bugx-supervisor", "bugx-supervisor-worker", "bugx-docs"}
|
|
260
|
+
if not isinstance(servers, dict) or not required.issubset(servers):
|
|
261
|
+
return False, "项目级 Antigravity MCP 缺少 bugx-supervisor / worker / docs 双通道"
|
|
262
|
+
root_resolved = root.resolve()
|
|
263
|
+
root_text = str(root_resolved)
|
|
264
|
+
expected_db = str(root_resolved / ".bugx" / "knowledge" / "docs.sqlite3")
|
|
265
|
+
for name in required:
|
|
266
|
+
entry = servers.get(name)
|
|
267
|
+
command = entry.get("command") if isinstance(entry, dict) else None
|
|
268
|
+
command_name = Path(str(command)).name.casefold() if isinstance(command, str) else ""
|
|
269
|
+
if not isinstance(entry, dict) or entry.get("type") != "stdio":
|
|
270
|
+
return False, f"项目级 Antigravity MCP 条目不是 BugX stdio 配置: {name}"
|
|
271
|
+
args = entry.get("args") if isinstance(entry, dict) else None
|
|
272
|
+
if not isinstance(args, list) or "--root" not in args:
|
|
273
|
+
return False, f"项目级 Antigravity MCP 条目缺少绝对 --root: {name}"
|
|
274
|
+
if command_name in {"python", "python.exe", "python3", "python3.exe", "pypy", "pypy.exe"}:
|
|
275
|
+
expected_script = "bugx_docs_mcp_server.py" if name == "bugx-docs" else "bugx_mcp_server.py"
|
|
276
|
+
if len(args) < 2 or Path(str(args[0])).name.casefold() != expected_script or args[1] != "serve":
|
|
277
|
+
return False, f"项目级 Antigravity Python MCP 条目启动器不受支持: {name}"
|
|
278
|
+
script = Path(str(args[0])).expanduser()
|
|
279
|
+
trusted_scripts = {
|
|
280
|
+
(global_engine_root() / "skills" / expected_script).resolve(),
|
|
281
|
+
(asset_root() / "skills" / expected_script).resolve(),
|
|
282
|
+
}
|
|
283
|
+
try:
|
|
284
|
+
if script.resolve() not in trusted_scripts:
|
|
285
|
+
return False, f"项目级 Antigravity MCP 脚本不属于 BugX 引擎: {name}"
|
|
286
|
+
except OSError:
|
|
287
|
+
return False, f"项目级 Antigravity MCP 脚本路径无效: {name}"
|
|
288
|
+
elif command_name not in {"bugx", "bugx.exe", "bugx.cmd", "bugx.ps1"}:
|
|
289
|
+
return False, f"项目级 Antigravity MCP 条目不是 BugX stdio 配置: {name}"
|
|
290
|
+
try:
|
|
291
|
+
root_arg = str(args[args.index("--root") + 1])
|
|
292
|
+
except (ValueError, IndexError):
|
|
293
|
+
return False, f"项目级 Antigravity MCP 条目 --root 无值: {name}"
|
|
294
|
+
if root_arg != root_text:
|
|
295
|
+
return False, f"项目级 Antigravity MCP 根目录不匹配: {name} -> {root_arg}"
|
|
296
|
+
if name == "bugx-docs":
|
|
297
|
+
if "--db" not in args:
|
|
298
|
+
return False, "项目级 Antigravity bugx-docs 条目缺少 --db"
|
|
299
|
+
try:
|
|
300
|
+
db_arg = str(args[args.index("--db") + 1])
|
|
301
|
+
except (ValueError, IndexError):
|
|
302
|
+
return False, "项目级 Antigravity bugx-docs 条目 --db 无值"
|
|
303
|
+
if db_arg != expected_db:
|
|
304
|
+
return False, f"项目级 Antigravity docs 数据库不匹配: {db_arg}"
|
|
305
|
+
elif name == "bugx-supervisor":
|
|
306
|
+
if "--role" not in args or args[args.index("--role") + 1:args.index("--role") + 2] != ["host"]:
|
|
307
|
+
return False, "项目级 Antigravity supervisor 条目必须使用 --role host"
|
|
308
|
+
elif name == "bugx-supervisor-worker":
|
|
309
|
+
if "--role" not in args or args[args.index("--role") + 1:args.index("--role") + 2] != ["worker"]:
|
|
310
|
+
return False, "项目级 Antigravity worker 条目必须使用 --role worker"
|
|
311
|
+
return True, f"Antigravity 项目级 MCP 已绑定当前工作区: {target}"
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
def validate_install(root: Path) -> tuple[bool, str]:
|
|
315
|
+
dest = Path.home() / PLUGIN_DIR
|
|
316
|
+
try:
|
|
317
|
+
pre_validate()
|
|
318
|
+
except (OSError, CliError) as exc:
|
|
319
|
+
return False, str(exc)
|
|
320
|
+
if any(not (dest / relative).is_file() for relative in _owned_files()):
|
|
321
|
+
return False, "BugX Agent 安装不完整,请运行 bugx install --agent antigravity。"
|
|
322
|
+
mcp_ok, mcp_detail = _validate_workspace_mcp(root)
|
|
323
|
+
if not mcp_ok:
|
|
324
|
+
return False, mcp_detail + ";请运行 bugx install --agent antigravity"
|
|
325
|
+
return True, f"Antigravity BugX Agent、Worker、Skill 和项目 MCP 已注册:{dest}"
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
def user_agent_surfaces() -> list[dict[str, object]]:
|
|
329
|
+
return [{"path": Path.home() / PLUGIN_DIR, "entries": tuple(_owned_files()), "label": "Google Antigravity"}]
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
def self_remove_user_agents(
|
|
333
|
+
backup_root: Path | None, removed: list[str], preserved: list[str],
|
|
334
|
+
) -> None:
|
|
335
|
+
from .lifecycle import _backup_tree_external
|
|
336
|
+
|
|
337
|
+
dest = Path.home() / PLUGIN_DIR
|
|
338
|
+
if not dest.exists() and not dest.is_symlink():
|
|
339
|
+
return
|
|
340
|
+
try:
|
|
341
|
+
pre_validate()
|
|
342
|
+
paths = [dest / relative for relative in reversed(_owned_files()) if (dest / relative).is_file()]
|
|
343
|
+
if backup_root is not None:
|
|
344
|
+
for path in paths:
|
|
345
|
+
_backup_tree_external(path, backup_root / "antigravity-bugx-review" / path.relative_to(dest))
|
|
346
|
+
for path in paths:
|
|
347
|
+
path.unlink()
|
|
348
|
+
removed.append(str(path))
|
|
349
|
+
except (CliError, OSError) as exc:
|
|
350
|
+
preserved.append(f"{dest}(未清理: {exc})")
|
|
@@ -18,6 +18,7 @@ from ..common import (
|
|
|
18
18
|
_backup_host_resource,
|
|
19
19
|
_i18n_exc,
|
|
20
20
|
_i18n_prompt,
|
|
21
|
+
_remove_tree_force,
|
|
21
22
|
_resolve_locale_name,
|
|
22
23
|
get_build_id,
|
|
23
24
|
)
|
|
@@ -133,9 +134,21 @@ def _claude_desktop_session_dirs() -> list[Path]:
|
|
|
133
134
|
def _claude_skill_description(locale: str | None = None) -> str:
|
|
134
135
|
"""Return localized description for Claude skill."""
|
|
135
136
|
loc = _resolve_locale_name(locale)
|
|
137
|
+
fallback = (
|
|
138
|
+
"BugX 是一个具备自主代码审查与测试能力的智能体,严把代码交付关:它帮助开发人员在写完代码后自动排查隐藏的深层 Bug,"
|
|
139
|
+
"减少反复排错与返工;帮助测试人员自动化运行黑盒测试、功能验证与性能测试,自动覆盖手工盲测难以覆盖的极端场景;"
|
|
140
|
+
"确保代码功能符合要求、具备良好的健壮性和稳定性。让开发和测试在繁琐的工作中解放双手,大幅提高工作效率、全面提升代码质量、显著降低后期维护成本,实现科技服务于人。"
|
|
141
|
+
) if loc.startswith("zh") else (
|
|
142
|
+
"BugX is an autonomous code review and testing agent designed to safeguard software delivery: "
|
|
143
|
+
"it surfaces hidden, deep bugs for developers right after writing code to eliminate painful debugging and rework; "
|
|
144
|
+
"automates black-box, functional, and performance testing across complex edge cases for QA; "
|
|
145
|
+
"and ensures software strictly meets functional requirements with rock-solid stability and resilience. "
|
|
146
|
+
"By taking over tedious verification, BugX frees engineers from manual grunt work, boosts team velocity, "
|
|
147
|
+
"elevates code quality, and significantly lowers long-term maintenance costs—putting technology to work for people."
|
|
148
|
+
)
|
|
136
149
|
return _i18n_prompt(
|
|
137
150
|
"plugin.claude_skill_description",
|
|
138
|
-
|
|
151
|
+
fallback,
|
|
139
152
|
locale=loc,
|
|
140
153
|
)
|
|
141
154
|
|
|
@@ -247,9 +260,9 @@ def _claude_user_agent_content_worker(*, locale: str | None = None) -> str:
|
|
|
247
260
|
|
|
248
261
|
_DEFAULT_CLAUDE_SKILL_CONTENT = """---
|
|
249
262
|
name: bugx
|
|
250
|
-
description:
|
|
263
|
+
description: BugX 是一个具备自主代码审查与测试能力的智能体,严把代码交付关:它帮助开发人员在写完代码后自动排查隐藏的深层 Bug,减少反复排错与返工;帮助测试人员自动化运行黑盒测试、功能验证与性能测试,自动覆盖手工盲测难以覆盖的极端场景;确保代码功能符合要求、具备良好的健壮性和稳定性。让开发和测试在繁琐的工作中解放双手,大幅提高工作效率、全面提升代码质量、显著降低后期维护成本,实现科技服务于人。
|
|
251
264
|
metadata:
|
|
252
|
-
bugx_version: "0.1.
|
|
265
|
+
bugx_version: "0.1.4"
|
|
253
266
|
---
|
|
254
267
|
<!-- bugx-locale: zh-CN -->
|
|
255
268
|
|
|
@@ -257,7 +270,7 @@ metadata:
|
|
|
257
270
|
|
|
258
271
|
BugX Claude Skill 镜像。执行前用 `bugx engine path --name AGENT_GUIDE.md` 和 `bugx engine path --name bugx.md` 读取全局协议;项目 `.bugx/` 只保存状态与配置。
|
|
259
272
|
|
|
260
|
-
协议镜像版本:0.1.
|
|
273
|
+
协议镜像版本:0.1.4
|
|
261
274
|
|
|
262
275
|
## Claude 原生交互适配(强制)
|
|
263
276
|
|
|
@@ -364,7 +377,7 @@ def _claude_plugin_manifest() -> dict[str, object]:
|
|
|
364
377
|
return {
|
|
365
378
|
"name": "bugx",
|
|
366
379
|
"version": __version__,
|
|
367
|
-
"description": "Autonomous code review and
|
|
380
|
+
"description": "Autonomous code review and testing agent. Catches hidden deep bugs for developers, automates black-box, functional, and performance testing for QA, and ensures rock-solid software delivery.",
|
|
368
381
|
"author": {
|
|
369
382
|
"name": "BugX",
|
|
370
383
|
"url": "https://bugx.dev",
|
|
@@ -612,13 +625,14 @@ def _build_claude_desktop_packages(
|
|
|
612
625
|
skill_bytes = skill_buf.getvalue()
|
|
613
626
|
|
|
614
627
|
# 构建 in-memory dxt zip (Claude Desktop Extension)
|
|
628
|
+
plugin_desc = _claude_skill_description(locale=locale)
|
|
615
629
|
dxt_manifest = {
|
|
616
630
|
"manifest_version": "0.4",
|
|
617
631
|
"name": "bugx",
|
|
618
632
|
"display_name": "BugX",
|
|
619
633
|
"version": __version__,
|
|
620
634
|
"bugx_build_id": get_build_id(),
|
|
621
|
-
"description":
|
|
635
|
+
"description": plugin_desc,
|
|
622
636
|
"author": {
|
|
623
637
|
"name": "BugX",
|
|
624
638
|
"url": "https://bugx.dev",
|
|
@@ -1172,7 +1186,7 @@ def _remove_claude_project_skills_and_dist(
|
|
|
1172
1186
|
project_skill = root / ".claude" / "skills" / "bugx"
|
|
1173
1187
|
if project_skill.is_dir() and not project_skill.is_symlink():
|
|
1174
1188
|
try:
|
|
1175
|
-
|
|
1189
|
+
_remove_tree_force(project_skill)
|
|
1176
1190
|
removed.append(f"{project_skill}(项目级 Claude Skill)")
|
|
1177
1191
|
except OSError as exc:
|
|
1178
1192
|
preserved.append(f"{project_skill}(删除失败:{exc})")
|
|
@@ -1194,7 +1208,7 @@ def _remove_claude_user_skills(
|
|
|
1194
1208
|
user_skill = _claude_user_skills_dir() / "bugx"
|
|
1195
1209
|
if user_skill.is_dir() and not user_skill.is_symlink():
|
|
1196
1210
|
try:
|
|
1197
|
-
|
|
1211
|
+
_remove_tree_force(user_skill)
|
|
1198
1212
|
removed.append(f"{user_skill}(Claude 用户级 Skill)")
|
|
1199
1213
|
except OSError as exc:
|
|
1200
1214
|
preserved.append(f"{user_skill}(删除失败:{exc})")
|
|
@@ -1202,7 +1216,7 @@ def _remove_claude_user_skills(
|
|
|
1202
1216
|
host_manual = _claude_user_skills_dir() / "bugx-claude"
|
|
1203
1217
|
if host_manual.is_dir() and not host_manual.is_symlink():
|
|
1204
1218
|
try:
|
|
1205
|
-
|
|
1219
|
+
_remove_tree_force(host_manual)
|
|
1206
1220
|
removed.append(f"{host_manual}(Claude 用户级宿主手册 Skill)")
|
|
1207
1221
|
except OSError as exc:
|
|
1208
1222
|
preserved.append(f"{host_manual}(删除失败:{exc})")
|
|
@@ -1211,7 +1225,7 @@ def _remove_claude_user_skills(
|
|
|
1211
1225
|
target = d_dir / "bugx"
|
|
1212
1226
|
if target.is_dir() and not target.is_symlink():
|
|
1213
1227
|
try:
|
|
1214
|
-
|
|
1228
|
+
_remove_tree_force(target)
|
|
1215
1229
|
removed.append(f"{target}(Claude 桌面端 Skill)")
|
|
1216
1230
|
except OSError as exc:
|
|
1217
1231
|
preserved.append(f"{target}(删除失败:{exc})")
|
|
@@ -1229,7 +1243,7 @@ def _remove_claude_user_skills(
|
|
|
1229
1243
|
ext_dir = desktop_support / "Claude Extensions" / ext_id
|
|
1230
1244
|
if ext_dir.is_dir() and not ext_dir.is_symlink():
|
|
1231
1245
|
try:
|
|
1232
|
-
|
|
1246
|
+
_remove_tree_force(ext_dir)
|
|
1233
1247
|
removed.append(f"{ext_dir}(Claude 桌面端扩展)")
|
|
1234
1248
|
except OSError as exc:
|
|
1235
1249
|
preserved.append(f"{ext_dir}(删除失败:{exc})")
|
|
@@ -1319,7 +1333,7 @@ def _remove_claude_desktop_cowork_plugins(
|
|
|
1319
1333
|
bugx_dir = local_marketplace / "bugx"
|
|
1320
1334
|
if bugx_dir.is_dir() and not bugx_dir.is_symlink():
|
|
1321
1335
|
try:
|
|
1322
|
-
|
|
1336
|
+
_remove_tree_force(bugx_dir)
|
|
1323
1337
|
removed.append(f"{bugx_dir}(Claude 桌面端插件目录)")
|
|
1324
1338
|
except OSError as exc:
|
|
1325
1339
|
preserved.append(f"{bugx_dir}(删除失败:{exc})")
|
|
@@ -1394,7 +1408,7 @@ def _remove_claude_plugin_registry(
|
|
|
1394
1408
|
cache_dir = plugins_dir / "cache" / "bugx"
|
|
1395
1409
|
if cache_dir.is_dir() and not cache_dir.is_symlink():
|
|
1396
1410
|
try:
|
|
1397
|
-
|
|
1411
|
+
_remove_tree_force(cache_dir)
|
|
1398
1412
|
removed.append(f"{cache_dir}(Claude 插件缓存)")
|
|
1399
1413
|
except OSError as exc:
|
|
1400
1414
|
preserved.append(f"{cache_dir}(删除失败:{exc})")
|