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,522 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""MiniMax Code Plugin V1 installer for BugX.
|
|
3
|
+
|
|
4
|
+
This module owns the MiniMax package contract. It deliberately does not reuse
|
|
5
|
+
Kimi's manifest, registry or icon URL: MiniMax discovers a package directory
|
|
6
|
+
under <DATA_DIR>/plugins and validates .minimax-plugin/plugin.json.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import json
|
|
12
|
+
import os
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
from typing import Any
|
|
15
|
+
|
|
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
|
|
29
|
+
|
|
30
|
+
_PLUGIN_NAME = "bugx"
|
|
31
|
+
_SCHEMA_VERSION = 1
|
|
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}"
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _minimax_data_dir() -> Path:
|
|
40
|
+
"""Return MiniMax's data directory; the env override is BugX's test hook."""
|
|
41
|
+
configured = os.environ.get("MINIMAX_DATA_DIR")
|
|
42
|
+
if configured is not None:
|
|
43
|
+
if not configured.strip():
|
|
44
|
+
raise CliError("MINIMAX_DATA_DIR 不能为空。")
|
|
45
|
+
return Path(configured).expanduser().resolve()
|
|
46
|
+
return (Path.home() / ".minimax").resolve()
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _minimax_plugin_root() -> Path:
|
|
50
|
+
return _minimax_data_dir() / "plugins" / _PLUGIN_NAME
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def _minimax_custom_agent_path() -> Path:
|
|
54
|
+
return _minimax_data_dir() / "agents" / _PLUGIN_NAME / "agent.md"
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def _find_bugx_skill_source(root: Path, source: Path) -> Path | None:
|
|
58
|
+
from ..infra.host_sync import find_bugx_skill_source
|
|
59
|
+
|
|
60
|
+
return find_bugx_skill_source(root, source)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def _find_bugx_avatar_source() -> Path | None:
|
|
64
|
+
candidates = (
|
|
65
|
+
asset_root() / "bugx-avatar-512.png",
|
|
66
|
+
asset_root() / "assets" / "bugx-avatar-512.png",
|
|
67
|
+
global_engine_root() / "assets" / "bugx-avatar-512.png",
|
|
68
|
+
Path(__file__).resolve().parents[4] / "core" / "assets" / "bugx-avatar-512.png",
|
|
69
|
+
)
|
|
70
|
+
for candidate in candidates:
|
|
71
|
+
if not candidate.is_symlink() and candidate.is_file():
|
|
72
|
+
return candidate
|
|
73
|
+
return None
|
|
74
|
+
|
|
75
|
+
|
|
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
|
+
)
|
|
121
|
+
|
|
122
|
+
|
|
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)
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def _build_plugin_manifest(locale: str | None = None) -> dict[str, Any]:
|
|
161
|
+
loc = _resolve_locale_name(locale)
|
|
162
|
+
desc = get_agent_description(loc)
|
|
163
|
+
return {
|
|
164
|
+
"schemaVersion": _SCHEMA_VERSION,
|
|
165
|
+
"name": _PLUGIN_NAME,
|
|
166
|
+
"displayName": "BugX",
|
|
167
|
+
"version": __version__,
|
|
168
|
+
"description": desc,
|
|
169
|
+
"author": "BugX",
|
|
170
|
+
"icon": "icon.png",
|
|
171
|
+
"category": "Code",
|
|
172
|
+
"exampleQueries": [
|
|
173
|
+
"对当前项目执行自主代码审查,找出深层 Bug",
|
|
174
|
+
"为当前项目执行自动化测试并提交可复现证据",
|
|
175
|
+
],
|
|
176
|
+
"apps": [],
|
|
177
|
+
"mcpServers": ["servers.mcp.json"],
|
|
178
|
+
"skills": ["skills/bugx/SKILL.md"],
|
|
179
|
+
"agents": [_WORKER_PATH],
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
def _server(command_args: list[str]) -> dict[str, Any]:
|
|
184
|
+
return {
|
|
185
|
+
"type": "stdio",
|
|
186
|
+
"command": "bugx",
|
|
187
|
+
"args": command_args,
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
def _build_mcp_manifest() -> dict[str, Any]:
|
|
192
|
+
return {
|
|
193
|
+
"schemaVersion": _SCHEMA_VERSION,
|
|
194
|
+
"mcpServers": {
|
|
195
|
+
"bugx-supervisor": _server(
|
|
196
|
+
["mcp", "serve", "--root", ".", "--role", "host"]
|
|
197
|
+
),
|
|
198
|
+
"bugx-supervisor-worker": _server(
|
|
199
|
+
["mcp", "serve", "--root", ".", "--role", "worker"]
|
|
200
|
+
),
|
|
201
|
+
"bugx-docs": _server(
|
|
202
|
+
[
|
|
203
|
+
"mcp", "docs", "serve", "--root", ".", "--db",
|
|
204
|
+
".bugx/knowledge/docs.sqlite3"
|
|
205
|
+
]
|
|
206
|
+
),
|
|
207
|
+
},
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
def _write_owned_file(
|
|
212
|
+
path: Path,
|
|
213
|
+
payload: bytes,
|
|
214
|
+
written: list[dict[str, Any]],
|
|
215
|
+
) -> None:
|
|
216
|
+
from .agent import _atomic_write_global_file_tx
|
|
217
|
+
|
|
218
|
+
_assert_no_symlink_components(path)
|
|
219
|
+
if path.exists() and not path.is_file():
|
|
220
|
+
raise CliError(f"MiniMax 插件目标不是普通文件: {path}")
|
|
221
|
+
status = "created"
|
|
222
|
+
if path.is_file():
|
|
223
|
+
if path.read_bytes() == payload:
|
|
224
|
+
status = "unchanged"
|
|
225
|
+
else:
|
|
226
|
+
status = "updated"
|
|
227
|
+
if status != "unchanged":
|
|
228
|
+
_atomic_write_global_file_tx(path, payload)
|
|
229
|
+
written.append({
|
|
230
|
+
"path": str(path),
|
|
231
|
+
"status": status,
|
|
232
|
+
"backup": None,
|
|
233
|
+
"created": status == "created",
|
|
234
|
+
})
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
def _validate_existing_package(dest: Path) -> dict[str, Any]:
|
|
238
|
+
_assert_no_symlink_components(dest)
|
|
239
|
+
if not dest.exists():
|
|
240
|
+
return {}
|
|
241
|
+
if not dest.is_dir():
|
|
242
|
+
raise CliError(f"MiniMax 插件目标不是目录: {dest}")
|
|
243
|
+
manifest = dest / ".minimax-plugin" / "plugin.json"
|
|
244
|
+
_assert_no_symlink_components(manifest)
|
|
245
|
+
if not manifest.exists():
|
|
246
|
+
if any(dest.iterdir()):
|
|
247
|
+
raise CliError(
|
|
248
|
+
f"MiniMax 插件目录已有未知内容,拒绝覆盖: {dest}"
|
|
249
|
+
)
|
|
250
|
+
return {}
|
|
251
|
+
if manifest.is_symlink() or not manifest.is_file():
|
|
252
|
+
raise CliError(f"MiniMax 插件 manifest 无效: {manifest}")
|
|
253
|
+
try:
|
|
254
|
+
existing = json.loads(manifest.read_text(encoding="utf-8"))
|
|
255
|
+
except (OSError, UnicodeError, json.JSONDecodeError) as exc:
|
|
256
|
+
raise CliError(f"MiniMax 插件 manifest 无法解析,已阻断覆盖: {manifest}") from exc
|
|
257
|
+
if not isinstance(existing, dict) or existing.get("name") != _PLUGIN_NAME:
|
|
258
|
+
raise CliError(f"MiniMax 插件目录属于其他插件,拒绝覆盖: {dest}")
|
|
259
|
+
|
|
260
|
+
entries = list(dest.rglob("*"))
|
|
261
|
+
if len(entries) > 2048:
|
|
262
|
+
raise CliError(f"MiniMax 插件目录条目超过 V1 上限: {dest}")
|
|
263
|
+
total_bytes = 0
|
|
264
|
+
for entry in entries:
|
|
265
|
+
_assert_no_symlink_components(entry)
|
|
266
|
+
if entry.is_dir():
|
|
267
|
+
continue
|
|
268
|
+
if not entry.is_file():
|
|
269
|
+
raise CliError(f"MiniMax 插件包包含特殊文件: {entry}")
|
|
270
|
+
stat_result = entry.stat()
|
|
271
|
+
if stat_result.st_nlink > 1:
|
|
272
|
+
raise CliError(f"MiniMax 插件包禁止硬链接文件: {entry}")
|
|
273
|
+
if stat_result.st_size > 16 * 1024 * 1024:
|
|
274
|
+
raise CliError(f"MiniMax 插件单文件超过 V1 上限: {entry}")
|
|
275
|
+
total_bytes += stat_result.st_size
|
|
276
|
+
relative = entry.relative_to(dest).as_posix()
|
|
277
|
+
try:
|
|
278
|
+
relative.encode("ascii")
|
|
279
|
+
except UnicodeEncodeError as exc:
|
|
280
|
+
raise CliError(f"MiniMax 插件路径必须是 ASCII: {entry}") from exc
|
|
281
|
+
if len(relative.encode("ascii")) > 512 or len(relative.split("/")) > 16:
|
|
282
|
+
raise CliError(f"MiniMax 插件路径超过 V1 上限: {entry}")
|
|
283
|
+
if total_bytes > 64 * 1024 * 1024:
|
|
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 头像已移除)")
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
def _ensure_minimax_plugin(
|
|
383
|
+
root: Path,
|
|
384
|
+
source: Path,
|
|
385
|
+
*,
|
|
386
|
+
locale: str | None = None,
|
|
387
|
+
) -> dict[str, Any]:
|
|
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)
|
|
392
|
+
data_dir = _minimax_data_dir()
|
|
393
|
+
if not data_dir.is_dir():
|
|
394
|
+
raise CliError(
|
|
395
|
+
f"未找到 MiniMax Code 数据目录: {data_dir}。"
|
|
396
|
+
"请先启动一次 MiniMax Code,或设置有效的 MINIMAX_DATA_DIR。"
|
|
397
|
+
)
|
|
398
|
+
|
|
399
|
+
skill_src = _find_bugx_skill_source(root, source)
|
|
400
|
+
if skill_src is None:
|
|
401
|
+
raise CliError("未找到 BugX SKILL.md,已阻断 MiniMax 插件安装。")
|
|
402
|
+
avatar_src = _find_bugx_avatar_source()
|
|
403
|
+
if avatar_src is None:
|
|
404
|
+
raise CliError("未找到 BugX PNG 图标,已阻断 MiniMax 插件安装。")
|
|
405
|
+
|
|
406
|
+
dest = _minimax_plugin_root()
|
|
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)
|
|
411
|
+
|
|
412
|
+
manifest_bytes = (
|
|
413
|
+
json.dumps(_build_plugin_manifest(locale=loc), indent=2, ensure_ascii=False) + "\n"
|
|
414
|
+
).encode("utf-8")
|
|
415
|
+
mcp_bytes = (
|
|
416
|
+
json.dumps(_build_mcp_manifest(), indent=2, ensure_ascii=False) + "\n"
|
|
417
|
+
).encode("utf-8")
|
|
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}")
|
|
427
|
+
written: list[dict[str, Any]] = []
|
|
428
|
+
|
|
429
|
+
_write_owned_file(dest / "servers.mcp.json", mcp_bytes, written)
|
|
430
|
+
_write_owned_file(dest / "icon.png", avatar_bytes, written)
|
|
431
|
+
_write_owned_file(
|
|
432
|
+
dest / _WORKER_PATH,
|
|
433
|
+
_build_worker_agent(locale=loc).encode("utf-8"),
|
|
434
|
+
written,
|
|
435
|
+
)
|
|
436
|
+
_write_owned_file(
|
|
437
|
+
dest / "skills" / "bugx" / "SKILL.md",
|
|
438
|
+
skill_src.read_bytes(),
|
|
439
|
+
written,
|
|
440
|
+
)
|
|
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)
|
|
454
|
+
|
|
455
|
+
changed = any(item["status"] != "unchanged" for item in written)
|
|
456
|
+
return {
|
|
457
|
+
"status": "updated" if changed else "unchanged",
|
|
458
|
+
"dir": str(dest),
|
|
459
|
+
"home": str(data_dir),
|
|
460
|
+
"manifest_path": str(dest / ".minimax-plugin" / "plugin.json"),
|
|
461
|
+
"mcp_path": str(dest / "servers.mcp.json"),
|
|
462
|
+
"agent_path": str(agent),
|
|
463
|
+
"avatar_path": str(avatar),
|
|
464
|
+
"worker_agent_path": str(dest / _WORKER_PATH),
|
|
465
|
+
"written": written,
|
|
466
|
+
"backups": [],
|
|
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})"
|
|
@@ -12,6 +12,7 @@ from ..common import (
|
|
|
12
12
|
_backup_host_resource,
|
|
13
13
|
_i18n_exc,
|
|
14
14
|
_i18n_prompt,
|
|
15
|
+
_remove_tree_force,
|
|
15
16
|
_resolve_locale_name,
|
|
16
17
|
)
|
|
17
18
|
from ..host_adapters import (
|
|
@@ -104,13 +105,11 @@ def _qoder_user_agent_content_worker(*, locale: str | None = None) -> str:
|
|
|
104
105
|
|
|
105
106
|
def _clean_legacy_qoder_plugin_and_skills() -> None:
|
|
106
107
|
"""清理历史遗留的 Qoder 散装技能目录与插件注册(Option A 收敛保障)。"""
|
|
107
|
-
import shutil
|
|
108
|
-
|
|
109
108
|
# 1. 清理 ~/.qoder/skills/bugx
|
|
110
109
|
try:
|
|
111
110
|
user_skill = _qoder_user_skills_dir() / "bugx"
|
|
112
111
|
if user_skill.is_dir() and not user_skill.is_symlink():
|
|
113
|
-
|
|
112
|
+
_remove_tree_force(user_skill)
|
|
114
113
|
except OSError:
|
|
115
114
|
pass
|
|
116
115
|
|
|
@@ -118,7 +117,7 @@ def _clean_legacy_qoder_plugin_and_skills() -> None:
|
|
|
118
117
|
try:
|
|
119
118
|
cache_parent = _qoder_user_plugins_dir() / "cache" / "bugx-agent"
|
|
120
119
|
if cache_parent.is_dir() and not cache_parent.is_symlink():
|
|
121
|
-
|
|
120
|
+
_remove_tree_force(cache_parent)
|
|
122
121
|
except OSError:
|
|
123
122
|
pass
|
|
124
123
|
|
|
@@ -54,7 +54,7 @@ def _zcode_plugin_manifest(version: str = __version__) -> dict[str, object]:
|
|
|
54
54
|
return {
|
|
55
55
|
"name": CHATGPT_PLUGIN_NAME,
|
|
56
56
|
"version": version,
|
|
57
|
-
"description": "Autonomous code review and
|
|
57
|
+
"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.",
|
|
58
58
|
"homepage": "https://bugx.dev",
|
|
59
59
|
"author": {
|
|
60
60
|
"name": "BugX",
|
|
@@ -130,10 +130,9 @@ def _zcode_storage_dir_override() -> Path:
|
|
|
130
130
|
raw = storage.get("dir") if isinstance(storage, dict) else None
|
|
131
131
|
if isinstance(raw, str) and raw.strip():
|
|
132
132
|
raw = raw.strip()
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
return Path(raw)
|
|
133
|
+
expanded = Path(raw).expanduser()
|
|
134
|
+
if expanded.is_absolute():
|
|
135
|
+
return expanded
|
|
137
136
|
return home / ".zcode"
|
|
138
137
|
|
|
139
138
|
|