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
|
@@ -13,12 +13,27 @@ import os
|
|
|
13
13
|
from pathlib import Path
|
|
14
14
|
from typing import Any
|
|
15
15
|
|
|
16
|
-
from ..
|
|
16
|
+
from .. import __version__
|
|
17
|
+
from ..common import (
|
|
18
|
+
CliError,
|
|
19
|
+
_resolve_locale_name,
|
|
20
|
+
asset_root,
|
|
21
|
+
global_engine_root,
|
|
22
|
+
)
|
|
23
|
+
from ..hosts.template_engine import (
|
|
24
|
+
add_locale_marker,
|
|
25
|
+
get_agent_description,
|
|
26
|
+
get_worker_description,
|
|
27
|
+
)
|
|
28
|
+
from ..infra.security import _assert_no_symlink_components
|
|
17
29
|
|
|
18
30
|
_PLUGIN_NAME = "bugx"
|
|
19
31
|
_SCHEMA_VERSION = 1
|
|
20
|
-
|
|
21
|
-
|
|
32
|
+
_WORKER_PATH = "agents/bugx-worker.md"
|
|
33
|
+
_LEGACY_MAIN_PATH = "agents/bugx.md"
|
|
34
|
+
_AGENT_OWNER = "<!-- Managed by BugX for MiniMax Code -->"
|
|
35
|
+
_AGENT_AVATAR_NAME = "bugx-avatar-512.png"
|
|
36
|
+
_AGENT_AVATAR_FIELD = f" avatar: {_AGENT_AVATAR_NAME}"
|
|
22
37
|
|
|
23
38
|
|
|
24
39
|
def _minimax_data_dir() -> Path:
|
|
@@ -35,22 +50,14 @@ def _minimax_plugin_root() -> Path:
|
|
|
35
50
|
return _minimax_data_dir() / "plugins" / _PLUGIN_NAME
|
|
36
51
|
|
|
37
52
|
|
|
53
|
+
def _minimax_custom_agent_path() -> Path:
|
|
54
|
+
return _minimax_data_dir() / "agents" / _PLUGIN_NAME / "agent.md"
|
|
55
|
+
|
|
56
|
+
|
|
38
57
|
def _find_bugx_skill_source(root: Path, source: Path) -> Path | None:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
source / "ecosystem" / "plugins" / "bugx" / "skills" / "bugx" / "SKILL.md",
|
|
43
|
-
source.parent / "skills" / "bugx" / "SKILL.md",
|
|
44
|
-
source.parent / "plugins" / "bugx" / "skills" / "bugx" / "SKILL.md",
|
|
45
|
-
source.parent / "ecosystem" / "plugins" / "bugx" / "skills" / "bugx" / "SKILL.md",
|
|
46
|
-
root / "plugins" / "bugx" / "skills" / "bugx" / "SKILL.md",
|
|
47
|
-
root / "ecosystem" / "plugins" / "bugx" / "skills" / "bugx" / "SKILL.md",
|
|
48
|
-
global_engine_root() / "skills" / "bugx" / "SKILL.md",
|
|
49
|
-
)
|
|
50
|
-
for candidate in candidates:
|
|
51
|
-
if not candidate.is_symlink() and candidate.is_file():
|
|
52
|
-
return candidate
|
|
53
|
-
return None
|
|
58
|
+
from ..infra.host_sync import find_bugx_skill_source
|
|
59
|
+
|
|
60
|
+
return find_bugx_skill_source(root, source)
|
|
54
61
|
|
|
55
62
|
|
|
56
63
|
def _find_bugx_avatar_source() -> Path | None:
|
|
@@ -66,75 +73,100 @@ def _find_bugx_avatar_source() -> Path | None:
|
|
|
66
73
|
return None
|
|
67
74
|
|
|
68
75
|
|
|
69
|
-
def _build_main_agent() -> str:
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
""
|
|
76
|
+
def _build_main_agent(locale: str | None = None) -> str:
|
|
77
|
+
loc = _resolve_locale_name(locale)
|
|
78
|
+
desc = get_agent_description(loc)
|
|
79
|
+
is_zh = loc.startswith("zh")
|
|
80
|
+
body = (
|
|
81
|
+
"你是 BugX,负责在用户授权的工作区和范围内协助代码审查与测试。\n\n"
|
|
82
|
+
"开始任务前,先运行下面两条命令,再读取它们返回的文件。\n\n"
|
|
83
|
+
"- `bugx engine path --name bugx-runtime-contract.md`\n"
|
|
84
|
+
"- `bugx engine path --name bugx-quick.md`\n\n"
|
|
85
|
+
"按文档约定使用 BugX Supervisor MCP 记录进度、检查点和验证证据。"
|
|
86
|
+
"如果命令、文档或所需工具不可用,请说明具体缺项。"
|
|
87
|
+
"报告已验证的结果和尚待验证的范围。\n"
|
|
88
|
+
) if is_zh else (
|
|
89
|
+
"You are BugX. Help review and test code within the workspace and scope authorized by the user.\n\n"
|
|
90
|
+
"Before starting a task, run the two commands below and read the files at the returned paths.\n\n"
|
|
91
|
+
"- `bugx engine path --name bugx-runtime-contract.md`\n"
|
|
92
|
+
"- `bugx engine path --name bugx-quick.md`\n\n"
|
|
93
|
+
"Follow the documented BugX Supervisor MCP workflow to record progress, checkpoints, and evidence. "
|
|
94
|
+
"Identify any unavailable command, document, or required tool. "
|
|
95
|
+
"Report verified results and any scope that still needs verification.\n"
|
|
96
|
+
)
|
|
97
|
+
return (
|
|
98
|
+
"---\n"
|
|
99
|
+
f"# {_AGENT_OWNER}\n"
|
|
100
|
+
"name: bugx\n"
|
|
101
|
+
f"description: {json.dumps(desc, ensure_ascii=False)}\n"
|
|
102
|
+
"tools:\n"
|
|
103
|
+
" - read\n"
|
|
104
|
+
" - write\n"
|
|
105
|
+
" - edit\n"
|
|
106
|
+
" - bash\n"
|
|
107
|
+
" - grep\n"
|
|
108
|
+
" - glob\n"
|
|
109
|
+
" - web_fetch\n"
|
|
110
|
+
"mcpServers:\n"
|
|
111
|
+
" - bugx-supervisor\n"
|
|
112
|
+
" - bugx-docs\n"
|
|
113
|
+
"skills:\n"
|
|
114
|
+
" - bugx\n"
|
|
115
|
+
"x-mavis:\n"
|
|
116
|
+
" displayName: BugX\n"
|
|
117
|
+
f"{_AGENT_AVATAR_FIELD}\n"
|
|
118
|
+
"---\n\n"
|
|
119
|
+
+ body
|
|
120
|
+
)
|
|
100
121
|
|
|
101
122
|
|
|
102
|
-
def _build_worker_agent() -> str:
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
""
|
|
123
|
+
def _build_worker_agent(locale: str | None = None) -> str:
|
|
124
|
+
loc = _resolve_locale_name(locale)
|
|
125
|
+
desc = get_worker_description(loc)
|
|
126
|
+
is_zh = loc.startswith("zh")
|
|
127
|
+
body = (
|
|
128
|
+
"# BugX Worker\n\n"
|
|
129
|
+
"严格遵守分配的任务包(claim)与租约。通过 bugx-supervisor-worker\n"
|
|
130
|
+
"发送心跳与检查点,为确认的缺陷附加可复现证据,不得委托给其他 Agent。\n"
|
|
131
|
+
) if is_zh else (
|
|
132
|
+
"# BugX Worker\n\n"
|
|
133
|
+
"Obey the assigned claim and lease. Send heartbeats and checkpoints through\n"
|
|
134
|
+
"bugx-supervisor-worker, attach reproducible evidence to confirmed findings,\n"
|
|
135
|
+
"and do not delegate to another Agent.\n"
|
|
136
|
+
)
|
|
137
|
+
rendered = (
|
|
138
|
+
"---\n"
|
|
139
|
+
"name: bugx-worker\n"
|
|
140
|
+
f"description: {json.dumps(desc, ensure_ascii=False)}\n"
|
|
141
|
+
"tools:\n"
|
|
142
|
+
" - read\n"
|
|
143
|
+
" - write\n"
|
|
144
|
+
" - edit\n"
|
|
145
|
+
" - bash\n"
|
|
146
|
+
" - grep\n"
|
|
147
|
+
" - glob\n"
|
|
148
|
+
"mcpServers:\n"
|
|
149
|
+
" - bugx-supervisor-worker\n"
|
|
150
|
+
"skills:\n"
|
|
151
|
+
" - bugx\n"
|
|
152
|
+
"x-mavis:\n"
|
|
153
|
+
" displayName: BugX Worker\n"
|
|
154
|
+
"---\n\n"
|
|
155
|
+
+ body
|
|
156
|
+
)
|
|
157
|
+
return add_locale_marker(rendered, loc)
|
|
127
158
|
|
|
128
159
|
|
|
129
|
-
def _build_plugin_manifest(
|
|
160
|
+
def _build_plugin_manifest(locale: str | None = None) -> dict[str, Any]:
|
|
161
|
+
loc = _resolve_locale_name(locale)
|
|
162
|
+
desc = get_agent_description(loc)
|
|
130
163
|
return {
|
|
131
|
-
"$schema": _PLUGIN_SCHEMA,
|
|
132
164
|
"schemaVersion": _SCHEMA_VERSION,
|
|
133
165
|
"name": _PLUGIN_NAME,
|
|
134
166
|
"displayName": "BugX",
|
|
135
|
-
"version":
|
|
136
|
-
"description":
|
|
137
|
-
"author":
|
|
167
|
+
"version": __version__,
|
|
168
|
+
"description": desc,
|
|
169
|
+
"author": "BugX",
|
|
138
170
|
"icon": "icon.png",
|
|
139
171
|
"category": "Code",
|
|
140
172
|
"exampleQueries": [
|
|
@@ -144,7 +176,7 @@ def _build_plugin_manifest(version: str = "0.1.3") -> dict[str, Any]:
|
|
|
144
176
|
"apps": [],
|
|
145
177
|
"mcpServers": ["servers.mcp.json"],
|
|
146
178
|
"skills": ["skills/bugx/SKILL.md"],
|
|
147
|
-
"agents": [
|
|
179
|
+
"agents": [_WORKER_PATH],
|
|
148
180
|
}
|
|
149
181
|
|
|
150
182
|
|
|
@@ -158,7 +190,7 @@ def _server(command_args: list[str]) -> dict[str, Any]:
|
|
|
158
190
|
|
|
159
191
|
def _build_mcp_manifest() -> dict[str, Any]:
|
|
160
192
|
return {
|
|
161
|
-
"
|
|
193
|
+
"schemaVersion": _SCHEMA_VERSION,
|
|
162
194
|
"mcpServers": {
|
|
163
195
|
"bugx-supervisor": _server(
|
|
164
196
|
["mcp", "serve", "--root", ".", "--role", "host"]
|
|
@@ -181,8 +213,9 @@ def _write_owned_file(
|
|
|
181
213
|
payload: bytes,
|
|
182
214
|
written: list[dict[str, Any]],
|
|
183
215
|
) -> None:
|
|
184
|
-
|
|
185
|
-
|
|
216
|
+
from .agent import _atomic_write_global_file_tx
|
|
217
|
+
|
|
218
|
+
_assert_no_symlink_components(path)
|
|
186
219
|
if path.exists() and not path.is_file():
|
|
187
220
|
raise CliError(f"MiniMax 插件目标不是普通文件: {path}")
|
|
188
221
|
status = "created"
|
|
@@ -192,8 +225,7 @@ def _write_owned_file(
|
|
|
192
225
|
else:
|
|
193
226
|
status = "updated"
|
|
194
227
|
if status != "unchanged":
|
|
195
|
-
path
|
|
196
|
-
path.write_bytes(payload)
|
|
228
|
+
_atomic_write_global_file_tx(path, payload)
|
|
197
229
|
written.append({
|
|
198
230
|
"path": str(path),
|
|
199
231
|
"status": status,
|
|
@@ -202,20 +234,20 @@ def _write_owned_file(
|
|
|
202
234
|
})
|
|
203
235
|
|
|
204
236
|
|
|
205
|
-
def _validate_existing_package(dest: Path) ->
|
|
206
|
-
|
|
207
|
-
raise CliError(f"MiniMax 插件目录禁止符号链接: {dest}")
|
|
237
|
+
def _validate_existing_package(dest: Path) -> dict[str, Any]:
|
|
238
|
+
_assert_no_symlink_components(dest)
|
|
208
239
|
if not dest.exists():
|
|
209
|
-
return
|
|
240
|
+
return {}
|
|
210
241
|
if not dest.is_dir():
|
|
211
242
|
raise CliError(f"MiniMax 插件目标不是目录: {dest}")
|
|
212
243
|
manifest = dest / ".minimax-plugin" / "plugin.json"
|
|
244
|
+
_assert_no_symlink_components(manifest)
|
|
213
245
|
if not manifest.exists():
|
|
214
246
|
if any(dest.iterdir()):
|
|
215
247
|
raise CliError(
|
|
216
248
|
f"MiniMax 插件目录已有未知内容,拒绝覆盖: {dest}"
|
|
217
249
|
)
|
|
218
|
-
return
|
|
250
|
+
return {}
|
|
219
251
|
if manifest.is_symlink() or not manifest.is_file():
|
|
220
252
|
raise CliError(f"MiniMax 插件 manifest 无效: {manifest}")
|
|
221
253
|
try:
|
|
@@ -230,8 +262,7 @@ def _validate_existing_package(dest: Path) -> None:
|
|
|
230
262
|
raise CliError(f"MiniMax 插件目录条目超过 V1 上限: {dest}")
|
|
231
263
|
total_bytes = 0
|
|
232
264
|
for entry in entries:
|
|
233
|
-
|
|
234
|
-
raise CliError(f"MiniMax 插件包禁止符号链接: {entry}")
|
|
265
|
+
_assert_no_symlink_components(entry)
|
|
235
266
|
if entry.is_dir():
|
|
236
267
|
continue
|
|
237
268
|
if not entry.is_file():
|
|
@@ -251,6 +282,101 @@ def _validate_existing_package(dest: Path) -> None:
|
|
|
251
282
|
raise CliError(f"MiniMax 插件路径超过 V1 上限: {entry}")
|
|
252
283
|
if total_bytes > 64 * 1024 * 1024:
|
|
253
284
|
raise CliError(f"MiniMax 插件包总大小超过 V1 上限: {dest}")
|
|
285
|
+
return existing
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
def _validate_custom_agent(path: Path) -> list[str]:
|
|
289
|
+
_assert_no_symlink_components(path)
|
|
290
|
+
if path.parent.exists() and not path.parent.is_dir():
|
|
291
|
+
raise CliError(f"MiniMax Agent 目录无效: {path.parent}")
|
|
292
|
+
if not path.exists():
|
|
293
|
+
if path.parent.is_dir() and any(path.parent.iterdir()):
|
|
294
|
+
raise CliError(f"MiniMax Agent 目录已有用户内容,拒绝覆盖: {path.parent}")
|
|
295
|
+
return []
|
|
296
|
+
if not path.is_file() or path.stat().st_nlink != 1:
|
|
297
|
+
raise CliError(f"MiniMax Agent 入口不是安全的普通文件: {path}")
|
|
298
|
+
try:
|
|
299
|
+
content = path.read_text(encoding="utf-8")
|
|
300
|
+
except (OSError, UnicodeError) as exc:
|
|
301
|
+
raise CliError(f"无法读取 MiniMax Agent 入口: {path}") from exc
|
|
302
|
+
lines = content.splitlines()
|
|
303
|
+
if not any(line.removeprefix("# ") == _AGENT_OWNER for line in lines):
|
|
304
|
+
raise CliError(f"MiniMax 已有同名用户 Agent,拒绝覆盖: {path}")
|
|
305
|
+
return lines
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
def _validate_avatar_file(path: Path) -> bool:
|
|
309
|
+
"""Return whether the avatar exists and reject unsafe file types."""
|
|
310
|
+
_assert_no_symlink_components(path)
|
|
311
|
+
if not path.exists():
|
|
312
|
+
return False
|
|
313
|
+
if not path.is_file() or path.stat().st_nlink != 1:
|
|
314
|
+
raise CliError(f"MiniMax Agent 头像不是安全的普通文件: {path}")
|
|
315
|
+
return True
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
def validate_install(_root: Path) -> tuple[bool, str]:
|
|
319
|
+
dest = _minimax_plugin_root()
|
|
320
|
+
agent = _minimax_custom_agent_path()
|
|
321
|
+
avatar = agent.with_name(_AGENT_AVATAR_NAME)
|
|
322
|
+
try:
|
|
323
|
+
manifest = _validate_existing_package(dest)
|
|
324
|
+
agent_lines = _validate_custom_agent(agent)
|
|
325
|
+
avatar_ok = (
|
|
326
|
+
_AGENT_AVATAR_FIELD in agent_lines
|
|
327
|
+
and _validate_avatar_file(avatar)
|
|
328
|
+
and avatar.read_bytes() == (dest / "icon.png").read_bytes()
|
|
329
|
+
)
|
|
330
|
+
expected = _build_plugin_manifest()
|
|
331
|
+
mcp = json.loads((dest / "servers.mcp.json").read_text(encoding="utf-8"))
|
|
332
|
+
except (CliError, OSError, UnicodeError, json.JSONDecodeError) as exc:
|
|
333
|
+
return False, f"MiniMax Code 注册无效: {exc}"
|
|
334
|
+
fields = ("schemaVersion", "author", "category", "agents", "mcpServers", "skills", "icon")
|
|
335
|
+
if (
|
|
336
|
+
not avatar_ok
|
|
337
|
+
or any(manifest.get(field) != expected[field] for field in fields)
|
|
338
|
+
or mcp != _build_mcp_manifest()
|
|
339
|
+
or any(not (dest / path).is_file() for path in (
|
|
340
|
+
_WORKER_PATH, "skills/bugx/SKILL.md", "icon.png",
|
|
341
|
+
))
|
|
342
|
+
):
|
|
343
|
+
return False, "MiniMax Code 的 Agent 或 Plugin V1 注册不完整,请运行 bugx install --agent minimax"
|
|
344
|
+
return True, f"MiniMax Code 自定义 Agent 和插件已注册: {agent}"
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
def user_agent_surfaces() -> list[dict[str, object]]:
|
|
348
|
+
agent = _minimax_custom_agent_path()
|
|
349
|
+
return [{"path": agent.parent, "entries": (agent.name,), "label": "MiniMax Code"}]
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
def self_remove_user_agents(
|
|
353
|
+
backup_root: Path | None, removed: list[str], preserved: list[str],
|
|
354
|
+
) -> None:
|
|
355
|
+
from .lifecycle import _backup_tree_external
|
|
356
|
+
|
|
357
|
+
agent = _minimax_custom_agent_path()
|
|
358
|
+
if not agent.exists() and not agent.is_symlink():
|
|
359
|
+
return
|
|
360
|
+
avatar = agent.with_name(_AGENT_AVATAR_NAME)
|
|
361
|
+
try:
|
|
362
|
+
agent_lines = _validate_custom_agent(agent)
|
|
363
|
+
remove_avatar = _AGENT_AVATAR_FIELD in agent_lines and _validate_avatar_file(avatar)
|
|
364
|
+
if backup_root is not None:
|
|
365
|
+
_backup_tree_external(agent, backup_root / "minimax-bugx-agent.md")
|
|
366
|
+
if remove_avatar:
|
|
367
|
+
_backup_tree_external(avatar, backup_root / _AGENT_AVATAR_NAME)
|
|
368
|
+
agent.unlink()
|
|
369
|
+
except (CliError, OSError) as exc:
|
|
370
|
+
preserved.append(f"{agent}(未清理: {exc})")
|
|
371
|
+
else:
|
|
372
|
+
removed.append(f"{agent}(BugX 自定义 Agent 已移除)")
|
|
373
|
+
if remove_avatar:
|
|
374
|
+
try:
|
|
375
|
+
avatar.unlink()
|
|
376
|
+
except OSError as exc:
|
|
377
|
+
preserved.append(f"{avatar}(未清理: {exc})")
|
|
378
|
+
else:
|
|
379
|
+
removed.append(f"{avatar}(BugX Agent 头像已移除)")
|
|
254
380
|
|
|
255
381
|
|
|
256
382
|
def _ensure_minimax_plugin(
|
|
@@ -259,8 +385,10 @@ def _ensure_minimax_plugin(
|
|
|
259
385
|
*,
|
|
260
386
|
locale: str | None = None,
|
|
261
387
|
) -> dict[str, Any]:
|
|
262
|
-
"""Install the
|
|
263
|
-
|
|
388
|
+
"""Install the Custom Agent and Plugin V1 package with one receipt."""
|
|
389
|
+
from .agent import _tx_stage_global
|
|
390
|
+
|
|
391
|
+
loc = _resolve_locale_name(locale)
|
|
264
392
|
data_dir = _minimax_data_dir()
|
|
265
393
|
if not data_dir.is_dir():
|
|
266
394
|
raise CliError(
|
|
@@ -276,29 +404,33 @@ def _ensure_minimax_plugin(
|
|
|
276
404
|
raise CliError("未找到 BugX PNG 图标,已阻断 MiniMax 插件安装。")
|
|
277
405
|
|
|
278
406
|
dest = _minimax_plugin_root()
|
|
279
|
-
|
|
280
|
-
|
|
407
|
+
agent = _minimax_custom_agent_path()
|
|
408
|
+
avatar = agent.with_name(_AGENT_AVATAR_NAME)
|
|
409
|
+
previous_manifest = _validate_existing_package(dest)
|
|
410
|
+
agent_lines = _validate_custom_agent(agent)
|
|
281
411
|
|
|
282
412
|
manifest_bytes = (
|
|
283
|
-
json.dumps(_build_plugin_manifest(), indent=2, ensure_ascii=False) + "\n"
|
|
413
|
+
json.dumps(_build_plugin_manifest(locale=loc), indent=2, ensure_ascii=False) + "\n"
|
|
284
414
|
).encode("utf-8")
|
|
285
415
|
mcp_bytes = (
|
|
286
416
|
json.dumps(_build_mcp_manifest(), indent=2, ensure_ascii=False) + "\n"
|
|
287
417
|
).encode("utf-8")
|
|
288
418
|
avatar_bytes = avatar_src.read_bytes()
|
|
419
|
+
if not avatar_bytes.startswith(b"\x89PNG\r\n\x1a\n"):
|
|
420
|
+
raise CliError(f"BugX 头像不是有效 PNG: {avatar_src}")
|
|
421
|
+
if (
|
|
422
|
+
_validate_avatar_file(avatar)
|
|
423
|
+
and _AGENT_AVATAR_FIELD not in agent_lines
|
|
424
|
+
and avatar.read_bytes() != avatar_bytes
|
|
425
|
+
):
|
|
426
|
+
raise CliError(f"MiniMax Agent 头像路径已有用户文件,拒绝覆盖: {avatar}")
|
|
289
427
|
written: list[dict[str, Any]] = []
|
|
290
428
|
|
|
291
|
-
_write_owned_file(dest / ".minimax-plugin" / "plugin.json", manifest_bytes, written)
|
|
292
429
|
_write_owned_file(dest / "servers.mcp.json", mcp_bytes, written)
|
|
293
430
|
_write_owned_file(dest / "icon.png", avatar_bytes, written)
|
|
294
431
|
_write_owned_file(
|
|
295
|
-
dest /
|
|
296
|
-
|
|
297
|
-
written,
|
|
298
|
-
)
|
|
299
|
-
_write_owned_file(
|
|
300
|
-
dest / "agents" / "bugx-worker.md",
|
|
301
|
-
_build_worker_agent().encode("utf-8"),
|
|
432
|
+
dest / _WORKER_PATH,
|
|
433
|
+
_build_worker_agent(locale=loc).encode("utf-8"),
|
|
302
434
|
written,
|
|
303
435
|
)
|
|
304
436
|
_write_owned_file(
|
|
@@ -306,7 +438,19 @@ def _ensure_minimax_plugin(
|
|
|
306
438
|
skill_src.read_bytes(),
|
|
307
439
|
written,
|
|
308
440
|
)
|
|
309
|
-
|
|
441
|
+
_write_owned_file(dest / ".minimax-plugin" / "plugin.json", manifest_bytes, written)
|
|
442
|
+
legacy_path = dest / _LEGACY_MAIN_PATH
|
|
443
|
+
previous_agents = previous_manifest.get("agents")
|
|
444
|
+
if isinstance(previous_agents, list) and _LEGACY_MAIN_PATH in previous_agents and legacy_path.is_file():
|
|
445
|
+
_tx_stage_global(legacy_path)
|
|
446
|
+
legacy_path.unlink()
|
|
447
|
+
written.append({"path": str(legacy_path), "status": "removed", "backup": None, "created": False})
|
|
448
|
+
_validate_custom_agent(agent)
|
|
449
|
+
_write_owned_file(avatar, avatar_bytes, written)
|
|
450
|
+
_write_owned_file(agent, _build_main_agent(locale=loc).encode("utf-8"), written)
|
|
451
|
+
valid, detail = validate_install(root)
|
|
452
|
+
if not valid:
|
|
453
|
+
raise CliError(detail)
|
|
310
454
|
|
|
311
455
|
changed = any(item["status"] != "unchanged" for item in written)
|
|
312
456
|
return {
|
|
@@ -315,8 +459,64 @@ def _ensure_minimax_plugin(
|
|
|
315
459
|
"home": str(data_dir),
|
|
316
460
|
"manifest_path": str(dest / ".minimax-plugin" / "plugin.json"),
|
|
317
461
|
"mcp_path": str(dest / "servers.mcp.json"),
|
|
318
|
-
"agent_path": str(
|
|
319
|
-
"
|
|
462
|
+
"agent_path": str(agent),
|
|
463
|
+
"avatar_path": str(avatar),
|
|
464
|
+
"worker_agent_path": str(dest / _WORKER_PATH),
|
|
320
465
|
"written": written,
|
|
321
466
|
"backups": [],
|
|
322
467
|
}
|
|
468
|
+
|
|
469
|
+
|
|
470
|
+
def validate_install(root: Path) -> tuple[bool, str]:
|
|
471
|
+
"""Verify MiniMax Code Plugin V1 assets and MCP servers at user-level plugin root."""
|
|
472
|
+
del root
|
|
473
|
+
try:
|
|
474
|
+
dest = _minimax_plugin_root()
|
|
475
|
+
except CliError as exc:
|
|
476
|
+
return False, str(exc)
|
|
477
|
+
manifest = dest / ".minimax-plugin" / "plugin.json"
|
|
478
|
+
mcp_path = dest / "servers.mcp.json"
|
|
479
|
+
agent_main = dest / "agents" / "bugx.md"
|
|
480
|
+
agent_worker = dest / "agents" / "bugx-worker.md"
|
|
481
|
+
skill_file = dest / "skills" / "bugx" / "SKILL.md"
|
|
482
|
+
required_files = (
|
|
483
|
+
("plugin manifest", manifest),
|
|
484
|
+
("MCP 配置", mcp_path),
|
|
485
|
+
("主智能体", agent_main),
|
|
486
|
+
("Worker 智能体", agent_worker),
|
|
487
|
+
("Skill", skill_file),
|
|
488
|
+
)
|
|
489
|
+
missing = [
|
|
490
|
+
label for label, path in required_files
|
|
491
|
+
if path.is_symlink() or not path.is_file()
|
|
492
|
+
]
|
|
493
|
+
if missing:
|
|
494
|
+
return (
|
|
495
|
+
False,
|
|
496
|
+
f"MiniMax Code 插件不完整({dest} 缺少 {'、'.join(missing)});"
|
|
497
|
+
"请运行 `bugx install --agent minimax`",
|
|
498
|
+
)
|
|
499
|
+
try:
|
|
500
|
+
manifest_data = json.loads(manifest.read_text(encoding="utf-8"))
|
|
501
|
+
except (OSError, UnicodeError, json.JSONDecodeError) as exc:
|
|
502
|
+
return False, f"MiniMax Code plugin.json 无法解析({manifest}):{exc}"
|
|
503
|
+
if not isinstance(manifest_data, dict) or manifest_data.get("name") != _PLUGIN_NAME:
|
|
504
|
+
return False, f"MiniMax Code plugin.json 无效({manifest});请运行 `bugx install --agent minimax`"
|
|
505
|
+
try:
|
|
506
|
+
mcp_data = json.loads(mcp_path.read_text(encoding="utf-8"))
|
|
507
|
+
except (OSError, UnicodeError, json.JSONDecodeError) as exc:
|
|
508
|
+
return False, f"MiniMax Code servers.mcp.json 无法解析({mcp_path}):{exc}"
|
|
509
|
+
servers = mcp_data.get("mcpServers") if isinstance(mcp_data, dict) else None
|
|
510
|
+
if not isinstance(servers, dict):
|
|
511
|
+
return False, f"MiniMax Code servers.mcp.json 缺少 mcpServers 对象({mcp_path})"
|
|
512
|
+
required_channels = ("bugx-supervisor", "bugx-supervisor-worker", "bugx-docs")
|
|
513
|
+
missing_channels = [
|
|
514
|
+
ch for ch in required_channels if not isinstance(servers.get(ch), dict)
|
|
515
|
+
]
|
|
516
|
+
if missing_channels:
|
|
517
|
+
return (
|
|
518
|
+
False,
|
|
519
|
+
f"MiniMax Code servers.mcp.json 缺少 {', '.join(missing_channels)}({mcp_path});"
|
|
520
|
+
"请运行 `bugx install --agent minimax`",
|
|
521
|
+
)
|
|
522
|
+
return True, f"MiniMax Code Plugin V1 与三通道 MCP 已就绪({dest})"
|
|
@@ -2487,7 +2487,7 @@ def command_mcp(args: argparse.Namespace) -> int:
|
|
|
2487
2487
|
|
|
2488
2488
|
|
|
2489
2489
|
def command_mcp_docs(args: argparse.Namespace) -> int:
|
|
2490
|
-
"""
|
|
2490
|
+
"""索引、同步或启动双域文档 MCP,隔离业务项目与官方知识库。"""
|
|
2491
2491
|
root = resolve_project_root(args.root).resolve()
|
|
2492
2492
|
forwarded = [args.mcp_docs_command, "--root", str(root), "--db", str(args.db)]
|
|
2493
2493
|
if args.project_id:
|
|
@@ -2496,6 +2496,16 @@ def command_mcp_docs(args: argparse.Namespace) -> int:
|
|
|
2496
2496
|
forwarded.extend(["--version", args.version])
|
|
2497
2497
|
if getattr(args, "no_auto_index", False):
|
|
2498
2498
|
forwarded.append("--no-auto-index")
|
|
2499
|
+
mode = getattr(args, "mode", None)
|
|
2500
|
+
if mode:
|
|
2501
|
+
forwarded.extend(["--mode", str(mode)])
|
|
2502
|
+
remote_url = getattr(args, "remote_url", None)
|
|
2503
|
+
if remote_url:
|
|
2504
|
+
forwarded.extend(["--remote-url", str(remote_url)])
|
|
2505
|
+
if getattr(args, "force", False):
|
|
2506
|
+
forwarded.append("--force")
|
|
2507
|
+
if getattr(args, "offline", False):
|
|
2508
|
+
forwarded.append("--offline")
|
|
2499
2509
|
return _run_script(
|
|
2500
2510
|
root, "bugx_docs_mcp_server.py", forwarded,
|
|
2501
2511
|
timeout=None if args.mcp_docs_command == "serve" else 300,
|
|
@@ -62,6 +62,8 @@ from .infra import (
|
|
|
62
62
|
_ensure_global_cli_symlinks,
|
|
63
63
|
_find_current_cli_executable,
|
|
64
64
|
_find_repo_root,
|
|
65
|
+
_global_bugx_dir,
|
|
66
|
+
_is_global_home_scope,
|
|
65
67
|
_engine_manifest_payload,
|
|
66
68
|
_file_record,
|
|
67
69
|
_fsync_engine_tree,
|
|
@@ -256,18 +258,41 @@ def _ensure_core_importable() -> None:
|
|
|
256
258
|
candidate = Path(engine_override).expanduser()
|
|
257
259
|
if not engine_override or not candidate.is_dir():
|
|
258
260
|
raise CliError(f"BUGX_GLOBAL_ENGINE_ROOT 指向不存在的引擎目录: {engine_override}")
|
|
259
|
-
asset = asset_root()
|
|
260
261
|
global_engine = global_engine_root()
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
262
|
+
asset: Path | None = None
|
|
263
|
+
try:
|
|
264
|
+
asset = asset_root()
|
|
265
|
+
except CliError:
|
|
266
|
+
asset = None
|
|
267
|
+
|
|
268
|
+
if asset is None:
|
|
269
|
+
try:
|
|
270
|
+
repo_root = _source_checkout_root()
|
|
271
|
+
repo_core = repo_root / "core"
|
|
272
|
+
if repo_core.is_dir() and (repo_core / "launch_bugx.py").is_file():
|
|
273
|
+
asset = repo_core
|
|
274
|
+
except Exception:
|
|
275
|
+
pass
|
|
276
|
+
|
|
267
277
|
candidates = []
|
|
268
278
|
for cand in (asset, global_engine):
|
|
269
|
-
if cand.is_dir() and (cand / "launch_bugx.py").is_file():
|
|
279
|
+
if cand is not None and cand.is_dir() and (cand / "launch_bugx.py").is_file():
|
|
270
280
|
candidates.append(cand)
|
|
281
|
+
|
|
282
|
+
if not candidates:
|
|
283
|
+
raise MissingAgentAssetError(_i18n_exc(
|
|
284
|
+
"common.agent_asset_missing",
|
|
285
|
+
"找不到 BugX Agent 资源;请重新安装 bugx-cli,或设置 BUGX_ASSET_ROOT "
|
|
286
|
+
"指向完整资源目录。仅在源码仓库开发时,显式设置 BUGX_DEV_ASSET_ROOT=1。",
|
|
287
|
+
), repairable=True)
|
|
288
|
+
|
|
289
|
+
if global_engine.is_dir() and not (global_engine / "launch_bugx.py").is_file():
|
|
290
|
+
if asset is not None:
|
|
291
|
+
print(
|
|
292
|
+
f"[bugx] 全局引擎目录 {global_engine} 缺失 launch_bugx.py,"
|
|
293
|
+
f"回落至 asset_root: {asset}",
|
|
294
|
+
file=sys.stderr,
|
|
295
|
+
)
|
|
271
296
|
# 后插入者位于 sys.path[0],故按 (asset, global_engine) 顺序插入 ⇒
|
|
272
297
|
# 最终 global_engine 优先。契约见 `docs/03_ai/01_AI_REFERENCE.md`「副本升级门禁」:
|
|
273
298
|
# Python 导入必须优先 `global_engine_root()`(共享引擎是运行时真源),
|
|
@@ -277,6 +302,12 @@ def _ensure_core_importable() -> None:
|
|
|
277
302
|
while s in sys.path:
|
|
278
303
|
sys.path.remove(s)
|
|
279
304
|
sys.path.insert(0, s)
|
|
305
|
+
try:
|
|
306
|
+
from core.repair.self_heal import mount_bugx_pydeps
|
|
307
|
+
|
|
308
|
+
mount_bugx_pydeps()
|
|
309
|
+
except Exception:
|
|
310
|
+
pass
|
|
280
311
|
|
|
281
312
|
|
|
282
313
|
# 宿主启动子进程时会通过环境变量指明工作区。MCP / 引擎入口若拿不到显式
|