bugx-cli 0.1.2 → 0.1.3

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.
Files changed (84) hide show
  1. package/README.md +26 -29
  2. package/core/agent/agent_orchestrator.py +3 -0
  3. package/core/agent/agent_workspace.py +14 -2
  4. package/core/assets/twitter_promo_art.jpg +0 -0
  5. package/core/assets/twitter_promo_card.svg +166 -0
  6. package/core/assets/twitter_promo_clean.jpg +0 -0
  7. package/core/assets/twitter_terminal_real.png +0 -0
  8. package/core/bugx.md +2 -2
  9. package/core/bugx_paths.py +2 -2
  10. package/core/cli-help.txt +1 -1
  11. package/core/contracts/bugx-opencode.md +1 -1
  12. package/core/contracts/bugx-runtime-contract.md +1 -1
  13. package/core/contracts/bugx-worker.md +1 -1
  14. package/core/engine-integrity.json +82 -42
  15. package/core/host_acp/kimi.py +175 -0
  16. package/core/host_acp/minimax.py +28 -0
  17. package/core/host_runtime/host_registry.py +23 -3
  18. package/core/hosts/dsh.py +1 -1
  19. package/core/hosts/kimi.py +293 -0
  20. package/core/hosts/minimax.py +248 -0
  21. package/core/hosts/zcode.py +5 -0
  22. package/core/infra/build_info.py +30 -5
  23. package/core/launch_phases/startup_version_gate.py +2 -2
  24. package/core/launch_phases/supervisor_bridge.py +14 -23
  25. package/core/metadata.txt +2 -2
  26. package/core/runtime/scenario_eval.py +1 -1
  27. package/core/runtime/setup_ui_env.py +4 -7
  28. package/core/supervisor/cli.py +2 -2
  29. package/core/webui/mcp_inspector.py +6 -0
  30. package/core/webui/static/index.html +51 -3
  31. package/core/webui/static/manifest.webmanifest +1 -1
  32. package/core/webui/static/project-settings.js +18 -3
  33. package/core/webui/static/robots.txt +36 -0
  34. package/core/webui/static/sitemap.xml +15 -0
  35. package/docs/07_distribution/01_README_NPM.md +26 -29
  36. package/ecosystem/integrations/cline/skills/bugx/SKILL.md +1 -1
  37. package/ecosystem/integrations/dsh/agents/bugx.md +1 -1
  38. package/ecosystem/integrations/dsh/dsh-patch.yml +2 -2
  39. package/ecosystem/integrations/dsh/mcp/package.json +1 -1
  40. package/ecosystem/integrations/dsh/skills/bugx/SKILL.md +1 -1
  41. package/ecosystem/integrations/dsh/skills/bugx-dsh/SKILL.md +1 -1
  42. package/ecosystem/integrations/dsh/ui/package.json +1 -1
  43. package/ecosystem/integrations/opencode/bugx-mcp-manifest.json +1 -1
  44. package/ecosystem/integrations/pi/extensions/bugx/manifest.json +1 -1
  45. package/ecosystem/integrations/pi/skills/bugx/SKILL.md +1 -1
  46. package/ecosystem/integrations/qoder/connector-meta.json +9 -9
  47. package/ecosystem/integrations/workbuddy/connector-meta.json +9 -9
  48. package/ecosystem/integrations/workbuddy/skills/bugx/SKILL.md +2 -2
  49. package/ecosystem/plugins/bugx/.claude-plugin/marketplace.json +2 -2
  50. package/ecosystem/plugins/bugx/.claude-plugin/plugin.json +2 -2
  51. package/ecosystem/plugins/bugx/.codex-plugin/plugin.json +4 -4
  52. package/ecosystem/plugins/bugx/.zcode-plugin/plugin.json +2 -2
  53. package/ecosystem/plugins/bugx/agents/bugx-worker.md +1 -1
  54. package/ecosystem/plugins/bugx/agents/bugx.md +1 -1
  55. package/ecosystem/plugins/bugx/skills/bugx/SKILL.md +3 -3
  56. package/ecosystem/plugins/bugx/skills/bugx-claude/SKILL.md +1 -1
  57. package/ecosystem/plugins/bugx/skills/bugx-dsh/SKILL.md +1 -1
  58. package/ecosystem/plugins/bugx/skills/bugx-opencode/SKILL.md +1 -1
  59. package/ecosystem/plugins/bugx/skills/bugx-zcode/SKILL.md +1 -1
  60. package/interfaces/bin/bugx.js +2 -0
  61. package/interfaces/cli/bugx_cli/__init__.py +2 -2
  62. package/interfaces/cli/bugx_cli/cli.py +15 -0
  63. package/interfaces/cli/bugx_cli/commands/agent.py +192 -67
  64. package/interfaces/cli/bugx_cli/commands/doctor.py +18 -0
  65. package/interfaces/cli/bugx_cli/commands/lifecycle.py +54 -47
  66. package/interfaces/cli/bugx_cli/commands/plugin.py +6 -6
  67. package/interfaces/cli/bugx_cli/commands/plugin_claude.py +27 -13
  68. package/interfaces/cli/bugx_cli/commands/plugin_kimi.py +348 -0
  69. package/interfaces/cli/bugx_cli/commands/plugin_minimax.py +322 -0
  70. package/interfaces/cli/bugx_cli/commands/plugin_qoder.py +3 -4
  71. package/interfaces/cli/bugx_cli/commands/plugin_zcode.py +4 -5
  72. package/interfaces/cli/bugx_cli/commands/system.py +64 -4
  73. package/interfaces/cli/bugx_cli/common.py +96 -7
  74. package/interfaces/cli/bugx_cli/host_adapters.py +150 -4
  75. package/interfaces/cli/bugx_cli/hosts/registry.py +4 -2
  76. package/interfaces/cli/bugx_cli/hosts/template_engine.py +10 -9
  77. package/interfaces/cli/bugx_cli/infra/engine_installer.py +4 -4
  78. package/interfaces/cli/bugx_cli/infra/host_sync.py +1 -1
  79. package/interfaces/cli/bugx_cli/infra/mcp_advisor.py +2 -2
  80. package/package.json +37 -13
  81. package/pyproject.toml +36 -12
  82. package/scripts/sync-version.mjs +1 -1
  83. package/skills/README.md +25 -0
  84. package/skills/platform/bugx-user/SKILL.md +92 -0
@@ -0,0 +1,348 @@
1
+ #!/usr/bin/env python3
2
+ """interfaces/cli/bugx_cli/commands/plugin_kimi.py - Kimi Code CLI 与桌面端插件适配。"""
3
+
4
+ from __future__ import annotations
5
+
6
+ import datetime
7
+ import json
8
+ import os
9
+ import shutil
10
+ from pathlib import Path
11
+ from typing import Any
12
+
13
+ from ..common import CliError, asset_root, global_engine_root
14
+
15
+
16
+ KIMI_PLUGIN_ICON_URL = "https://bugx.dev/brand-mark.svg"
17
+ KIMI_PLUGIN_BRAND_COLOR = "#0284c7"
18
+
19
+
20
+ def _kimi_code_home() -> Path:
21
+ """返回 Kimi Code 当前跨平台数据根目录。
22
+
23
+ Kimi Code 1.4.x 的桌面端与 CLI 都通过 ``KIMI_CODE_HOME``(未设置时
24
+ ``~/.kimi-code``)解析插件目录;旧版 ``daimon-share`` 不是当前插件
25
+ 注册协议,不能作为回退路径。
26
+ """
27
+ configured = os.environ.get("KIMI_CODE_HOME")
28
+ if configured is not None:
29
+ if not configured.strip():
30
+ raise CliError("KIMI_CODE_HOME 不能为空。")
31
+ return Path(configured).expanduser().resolve()
32
+ return (Path.home() / ".kimi-code").resolve()
33
+
34
+
35
+ def _find_bugx_skill_source(root: Path, source: Path) -> Path | None:
36
+ """定位可复用的 BugX SKILL.md 源文件。"""
37
+ candidates = (
38
+ source / "skills" / "bugx" / "SKILL.md",
39
+ source / "plugins" / "bugx" / "skills" / "bugx" / "SKILL.md",
40
+ source / "ecosystem" / "plugins" / "bugx" / "skills" / "bugx" / "SKILL.md",
41
+ root / "plugins" / "bugx" / "skills" / "bugx" / "SKILL.md",
42
+ root / "ecosystem" / "plugins" / "bugx" / "skills" / "bugx" / "SKILL.md",
43
+ global_engine_root() / "skills" / "bugx" / "SKILL.md",
44
+ )
45
+ for candidate in candidates:
46
+ if not candidate.is_symlink() and candidate.is_file():
47
+ return candidate
48
+ return None
49
+
50
+
51
+ def _find_bugx_avatar_source() -> Path | None:
52
+ """定位官方 BugX 图标源文件。"""
53
+ candidates = (
54
+ asset_root() / "bugx-avatar-512.png",
55
+ asset_root() / "assets" / "bugx-avatar-512.png",
56
+ global_engine_root() / "assets" / "bugx-avatar-512.png",
57
+ Path(__file__).resolve().parents[4] / "core" / "assets" / "bugx-avatar-512.png",
58
+ )
59
+ for candidate in candidates:
60
+ if not candidate.is_symlink() and candidate.is_file():
61
+ return candidate
62
+ return None
63
+
64
+
65
+ def _build_agent_bugx() -> str:
66
+ return """---
67
+ name: bugx
68
+ description: Autonomous code review and testing agent designed to safeguard software delivery. Surfaces hidden bugs for developers, automates black-box, functional, and performance testing for QA, and ensures rock-solid software delivery.
69
+ tools: Bash, Read, Grep, Glob, Edit, Write, AskUserQuestion
70
+ color: cyan
71
+ ---
72
+
73
+ # BugX
74
+
75
+ This is BugX's Kimi Code entry.
76
+
77
+ Read the global engine protocol first:
78
+ load the global protocol via `bugx engine path --name bugx-runtime-contract.md` and
79
+ `bugx engine path --name bugx-quick.md`, and follow the lifetime, Supervisor,
80
+ evidence, and reporting protocols in them.
81
+
82
+ This entry only hands the task to the current Kimi Code session; BugX CLI installs
83
+ resources and does not run audits directly.
84
+
85
+ ## Interaction Adaptation
86
+ - Present interaction decisions with structured prompts.
87
+ - Ensure `bugx-supervisor` and `bugx-supervisor-worker` MCP tools are accessible.
88
+ """
89
+
90
+
91
+ def _build_agent_worker() -> str:
92
+ return """---
93
+ name: bugx-worker
94
+ description: BugX Worker execution agent for targeted code audits and vulnerability reproduction.
95
+ tools: Bash, Read, Grep, Glob, Edit, Write
96
+ color: green
97
+ ---
98
+
99
+ # BugX Worker
100
+
101
+ This is the BugX Worker execution sub-agent.
102
+
103
+ ## Execution Rules
104
+ - Obey task assignment and lease constraints.
105
+ - Report heartbeats and checkpoints to `bugx-supervisor-worker`.
106
+ - Provide standalone proof-of-concept (PoC) scripts for confirmed defects.
107
+ """
108
+
109
+
110
+ def _build_desktop_plugin_manifest(version: str = "0.1.3") -> dict[str, Any]:
111
+ """生成具备完整桌面端 UI / 徽标与 MCP 通道配置的 kimi.plugin.json。"""
112
+ return {
113
+ "name": "bugx",
114
+ "version": version,
115
+ "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.",
116
+ "homepage": "https://bugx.dev",
117
+ "author": {
118
+ "name": "BugX",
119
+ "url": "https://bugx.dev",
120
+ },
121
+ "license": "MIT",
122
+ "keywords": [
123
+ "security",
124
+ "code-audit",
125
+ "code-review",
126
+ "vulnerability",
127
+ "mcp",
128
+ "bugx",
129
+ ],
130
+ "agents": "./agents",
131
+ "skills": "./skills",
132
+ "interface": {
133
+ "defaultLocale": "zh-CN",
134
+ "displayName": "BugX",
135
+ "shortDescription": "自主代码审查与自主测试智能体",
136
+ "longDescription": "BugX 是一个具备自主代码审查与测试能力的智能体,严把代码交付关:它帮助开发人员在写完代码后自动排查隐藏的深层 Bug,减少反复排错与返工;帮助测试人员自动化运行黑盒测试、功能验证与性能测试,自动覆盖手工盲测难以覆盖的极端场景;确保代码功能符合要求、具备良好的健壮性和稳定性。让开发和测试在繁琐的工作中解放双手,大幅提高工作效率、全面提升代码质量、显著降低后期维护成本,实现科技服务于人。",
137
+ "developerName": "BugX",
138
+ "websiteURL": "https://bugx.dev",
139
+ "category": "PRODUCTIVITY",
140
+ "hostKind": "local",
141
+ "tryPrompts": [
142
+ "对当前项目执行自主代码审查,找出深层 Bug",
143
+ "为当前项目执行自动化测试,验证功能与稳定性",
144
+ ],
145
+ "brandColor": {
146
+ "light": KIMI_PLUGIN_BRAND_COLOR,
147
+ "dark": KIMI_PLUGIN_BRAND_COLOR,
148
+ },
149
+ "iconUrl": KIMI_PLUGIN_ICON_URL,
150
+ },
151
+ "mcpServers": {
152
+ "bugx-supervisor": {
153
+ "command": "bugx",
154
+ "args": [
155
+ "mcp",
156
+ "serve",
157
+ "--root",
158
+ ".",
159
+ "--role",
160
+ "host",
161
+ ],
162
+ },
163
+ "bugx-supervisor-worker": {
164
+ "command": "bugx",
165
+ "args": [
166
+ "mcp",
167
+ "serve",
168
+ "--root",
169
+ ".",
170
+ "--role",
171
+ "worker",
172
+ ],
173
+ },
174
+ "bugx-docs": {
175
+ "command": "bugx",
176
+ "args": [
177
+ "mcp",
178
+ "docs",
179
+ "serve",
180
+ "--root",
181
+ ".",
182
+ "--db",
183
+ ".bugx/knowledge/docs.sqlite3",
184
+ ],
185
+ },
186
+ },
187
+ }
188
+
189
+
190
+ def _ensure_kimi_plugin(
191
+ root: Path,
192
+ source: Path,
193
+ *,
194
+ locale: str | None = None,
195
+ ) -> dict[str, Any]:
196
+ """安装并激活 Kimi Code 当前插件协议中的 BugX 插件。
197
+
198
+ Kimi Code 1.4.x 的真实注册面是 ``<KIMI_CODE_HOME>/plugins``:插件
199
+ 文件放在 ``managed/bugx``,启用状态登记在 ``installed.json``。这里
200
+ 只写入这一套当前契约;若宿主数据根不存在则立即失败,避免安装命令
201
+ 返回成功但插件实际没有注册。
202
+ """
203
+ del locale
204
+ kimi_home = _kimi_code_home()
205
+ if not kimi_home.is_dir():
206
+ raise CliError(
207
+ "未找到 Kimi Code 数据目录: "
208
+ f"{kimi_home}。请先启动一次 Kimi Code,或设置有效的 KIMI_CODE_HOME。"
209
+ )
210
+
211
+ plugins_root = kimi_home / "plugins"
212
+ installed_file = plugins_root / "installed.json"
213
+ if installed_file.is_file():
214
+ try:
215
+ installed_data = json.loads(installed_file.read_text(encoding="utf-8"))
216
+ except (OSError, UnicodeError, json.JSONDecodeError) as exc:
217
+ raise CliError(
218
+ f"Kimi Code 插件注册表无法解析,已阻断写入: {installed_file}"
219
+ ) from exc
220
+ else:
221
+ installed_data = {"version": 1, "plugins": []}
222
+
223
+ if not isinstance(installed_data, dict):
224
+ raise CliError(f"Kimi Code 插件注册表顶层必须是对象: {installed_file}")
225
+ plugins_value = installed_data.get("plugins")
226
+ if plugins_value is None:
227
+ plugins_list: list[dict[str, Any]] = []
228
+ installed_data["plugins"] = plugins_list
229
+ elif isinstance(plugins_value, list):
230
+ plugins_list = plugins_value
231
+ else:
232
+ raise CliError(f"Kimi Code 插件注册表 plugins 必须是数组: {installed_file}")
233
+
234
+ dest = plugins_root / "managed" / "bugx"
235
+ dest.mkdir(parents=True, exist_ok=True)
236
+
237
+ written: list[dict[str, Any]] = []
238
+
239
+ # 2. 写入 kimi.plugin.json 与 .kimi-plugin/plugin.json
240
+ manifest_obj = _build_desktop_plugin_manifest()
241
+ manifest_bytes = (
242
+ json.dumps(manifest_obj, indent=2, ensure_ascii=False) + "\n"
243
+ ).encode("utf-8")
244
+
245
+ manifest_file = dest / "kimi.plugin.json"
246
+ manifest_file.write_bytes(manifest_bytes)
247
+ written.append({
248
+ "path": str(manifest_file),
249
+ "status": "created",
250
+ "backup": None,
251
+ "created": True,
252
+ })
253
+
254
+ dot_plugin_dir = dest / ".kimi-plugin"
255
+ dot_plugin_dir.mkdir(parents=True, exist_ok=True)
256
+ (dot_plugin_dir / "plugin.json").write_bytes(manifest_bytes)
257
+
258
+ # 3. 部署官方 Logo 图标 (icon.png / assets/icon.png)
259
+ avatar_src = _find_bugx_avatar_source()
260
+ if avatar_src and avatar_src.is_file():
261
+ avatar_bytes = avatar_src.read_bytes()
262
+ icon_dest = dest / "icon.png"
263
+ icon_dest.write_bytes(avatar_bytes)
264
+ written.append({
265
+ "path": str(icon_dest),
266
+ "status": "created",
267
+ "backup": None,
268
+ "created": True,
269
+ })
270
+ assets_dir = dest / "assets"
271
+ assets_dir.mkdir(parents=True, exist_ok=True)
272
+ (assets_dir / "icon.png").write_bytes(avatar_bytes)
273
+
274
+ # 4. 部署 skills/ 与 agents/
275
+ agents_dir = dest / "agents"
276
+ agents_dir.mkdir(parents=True, exist_ok=True)
277
+ agent_main = agents_dir / "bugx.md"
278
+ agent_main.write_text(_build_agent_bugx(), encoding="utf-8")
279
+ written.append({
280
+ "path": str(agent_main),
281
+ "status": "created",
282
+ "backup": None,
283
+ "created": True,
284
+ })
285
+ agent_worker = agents_dir / "bugx-worker.md"
286
+ agent_worker.write_text(_build_agent_worker(), encoding="utf-8")
287
+ written.append({
288
+ "path": str(agent_worker),
289
+ "status": "created",
290
+ "backup": None,
291
+ "created": True,
292
+ })
293
+
294
+ skills_dir = dest / "skills" / "bugx"
295
+ skills_dir.mkdir(parents=True, exist_ok=True)
296
+ skill_src = _find_bugx_skill_source(root, source)
297
+ if skill_src and skill_src.is_file():
298
+ target_skill = skills_dir / "SKILL.md"
299
+ target_skill.write_bytes(skill_src.read_bytes())
300
+ written.append({
301
+ "path": str(target_skill),
302
+ "status": "created",
303
+ "backup": None,
304
+ "created": True,
305
+ })
306
+
307
+ # 5. 直接写入并激活到当前 Kimi Code 的 installed.json(免用户点击安装)
308
+ now_iso = datetime.datetime.now(datetime.timezone.utc).isoformat().replace("+00:00", "Z")
309
+ entry = next(
310
+ (p for p in plugins_list if isinstance(p, dict) and p.get("id") == "bugx"),
311
+ None,
312
+ )
313
+ if entry is None:
314
+ entry = {
315
+ "id": "bugx",
316
+ "root": str(dest),
317
+ "source": "local-path",
318
+ "origin": "custom",
319
+ "enabled": True,
320
+ "installedAt": now_iso,
321
+ "updatedAt": now_iso,
322
+ "originalSource": str(dest),
323
+ }
324
+ plugins_list.append(entry)
325
+ else:
326
+ entry["root"] = str(dest)
327
+ entry["enabled"] = True
328
+ entry["updatedAt"] = now_iso
329
+
330
+ installed_file.parent.mkdir(parents=True, exist_ok=True)
331
+ installed_file.write_text(
332
+ json.dumps(installed_data, indent=2, ensure_ascii=False) + "\n",
333
+ encoding="utf-8",
334
+ )
335
+ written.append({
336
+ "path": str(installed_file),
337
+ "status": "updated",
338
+ "backup": None,
339
+ "created": False,
340
+ })
341
+
342
+ return {
343
+ "dir": str(dest),
344
+ "home": str(kimi_home),
345
+ "registry": str(installed_file),
346
+ "written": written,
347
+ "backups": [],
348
+ }
@@ -0,0 +1,322 @@
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 ..common import CliError, asset_root, global_engine_root
17
+
18
+ _PLUGIN_NAME = "bugx"
19
+ _SCHEMA_VERSION = 1
20
+ _PLUGIN_SCHEMA = "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json"
21
+ _MCP_SCHEMA = "https://agent-plugins.org/schemas/1.0.0/mcp.schema.json"
22
+
23
+
24
+ def _minimax_data_dir() -> Path:
25
+ """Return MiniMax's data directory; the env override is BugX's test hook."""
26
+ configured = os.environ.get("MINIMAX_DATA_DIR")
27
+ if configured is not None:
28
+ if not configured.strip():
29
+ raise CliError("MINIMAX_DATA_DIR 不能为空。")
30
+ return Path(configured).expanduser().resolve()
31
+ return (Path.home() / ".minimax").resolve()
32
+
33
+
34
+ def _minimax_plugin_root() -> Path:
35
+ return _minimax_data_dir() / "plugins" / _PLUGIN_NAME
36
+
37
+
38
+ def _find_bugx_skill_source(root: Path, source: Path) -> Path | None:
39
+ candidates = (
40
+ source / "skills" / "bugx" / "SKILL.md",
41
+ source / "plugins" / "bugx" / "skills" / "bugx" / "SKILL.md",
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
54
+
55
+
56
+ def _find_bugx_avatar_source() -> Path | None:
57
+ candidates = (
58
+ asset_root() / "bugx-avatar-512.png",
59
+ asset_root() / "assets" / "bugx-avatar-512.png",
60
+ global_engine_root() / "assets" / "bugx-avatar-512.png",
61
+ Path(__file__).resolve().parents[4] / "core" / "assets" / "bugx-avatar-512.png",
62
+ )
63
+ for candidate in candidates:
64
+ if not candidate.is_symlink() and candidate.is_file():
65
+ return candidate
66
+ return None
67
+
68
+
69
+ def _build_main_agent() -> str:
70
+ return """---
71
+ name: bugx
72
+ description: An autonomous code review and testing agent designed to safeguard software delivery. It surfaces hidden bugs for developers to eliminate painful debugging and rework, while automating black-box, functional, and performance testing across complex edge cases for QA. Ensures code runs reliably, meets all requirements, and frees engineers to focus on what matters.
73
+ tools:
74
+ - read
75
+ - write
76
+ - edit
77
+ - bash
78
+ - grep
79
+ - glob
80
+ - web_fetch
81
+ mcpServers:
82
+ - bugx-supervisor
83
+ - bugx-docs
84
+ skills:
85
+ - bugx
86
+ x-mavis:
87
+ displayName: BugX
88
+ ---
89
+
90
+ # BugX
91
+
92
+ Read bugx engine path --name bugx-runtime-contract.md and
93
+ bugx engine path --name bugx-quick.md before starting. Use the BugX supervisor
94
+ MCP tools for lifecycle, evidence, checkpoints, findings and final reporting.
95
+
96
+ This Agent is the MiniMax Code host entry. It delegates execution to the
97
+ BugX runtime through the declared MCP servers; it does not invent a second
98
+ lifecycle or bypass supervisor evidence.
99
+ """
100
+
101
+
102
+ def _build_worker_agent() -> str:
103
+ return """---
104
+ name: bugx-worker
105
+ description: BugX Worker Agent for targeted audits and vulnerability reproduction.
106
+ tools:
107
+ - read
108
+ - write
109
+ - edit
110
+ - bash
111
+ - grep
112
+ - glob
113
+ mcpServers:
114
+ - bugx-supervisor-worker
115
+ skills:
116
+ - bugx
117
+ x-mavis:
118
+ displayName: BugX Worker
119
+ ---
120
+
121
+ # BugX Worker
122
+
123
+ Obey the assigned claim and lease. Send heartbeats and checkpoints through
124
+ bugx-supervisor-worker, attach reproducible evidence to confirmed findings,
125
+ and do not delegate to another Agent.
126
+ """
127
+
128
+
129
+ def _build_plugin_manifest(version: str = "0.1.3") -> dict[str, Any]:
130
+ return {
131
+ "$schema": _PLUGIN_SCHEMA,
132
+ "schemaVersion": _SCHEMA_VERSION,
133
+ "name": _PLUGIN_NAME,
134
+ "displayName": "BugX",
135
+ "version": version,
136
+ "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.",
137
+ "author": {"name": "BugX"},
138
+ "icon": "icon.png",
139
+ "category": "Code",
140
+ "exampleQueries": [
141
+ "对当前项目执行自主代码审查,找出深层 Bug",
142
+ "为当前项目执行自动化测试并提交可复现证据",
143
+ ],
144
+ "apps": [],
145
+ "mcpServers": ["servers.mcp.json"],
146
+ "skills": ["skills/bugx/SKILL.md"],
147
+ "agents": ["agents/bugx.md", "agents/bugx-worker.md"],
148
+ }
149
+
150
+
151
+ def _server(command_args: list[str]) -> dict[str, Any]:
152
+ return {
153
+ "type": "stdio",
154
+ "command": "bugx",
155
+ "args": command_args,
156
+ }
157
+
158
+
159
+ def _build_mcp_manifest() -> dict[str, Any]:
160
+ return {
161
+ "$schema": _MCP_SCHEMA,
162
+ "mcpServers": {
163
+ "bugx-supervisor": _server(
164
+ ["mcp", "serve", "--root", ".", "--role", "host"]
165
+ ),
166
+ "bugx-supervisor-worker": _server(
167
+ ["mcp", "serve", "--root", ".", "--role", "worker"]
168
+ ),
169
+ "bugx-docs": _server(
170
+ [
171
+ "mcp", "docs", "serve", "--root", ".", "--db",
172
+ ".bugx/knowledge/docs.sqlite3"
173
+ ]
174
+ ),
175
+ },
176
+ }
177
+
178
+
179
+ def _write_owned_file(
180
+ path: Path,
181
+ payload: bytes,
182
+ written: list[dict[str, Any]],
183
+ ) -> None:
184
+ if path.is_symlink():
185
+ raise CliError(f"MiniMax 插件路径禁止符号链接: {path}")
186
+ if path.exists() and not path.is_file():
187
+ raise CliError(f"MiniMax 插件目标不是普通文件: {path}")
188
+ status = "created"
189
+ if path.is_file():
190
+ if path.read_bytes() == payload:
191
+ status = "unchanged"
192
+ else:
193
+ status = "updated"
194
+ if status != "unchanged":
195
+ path.parent.mkdir(parents=True, exist_ok=True)
196
+ path.write_bytes(payload)
197
+ written.append({
198
+ "path": str(path),
199
+ "status": status,
200
+ "backup": None,
201
+ "created": status == "created",
202
+ })
203
+
204
+
205
+ def _validate_existing_package(dest: Path) -> None:
206
+ if dest.is_symlink():
207
+ raise CliError(f"MiniMax 插件目录禁止符号链接: {dest}")
208
+ if not dest.exists():
209
+ return
210
+ if not dest.is_dir():
211
+ raise CliError(f"MiniMax 插件目标不是目录: {dest}")
212
+ manifest = dest / ".minimax-plugin" / "plugin.json"
213
+ if not manifest.exists():
214
+ if any(dest.iterdir()):
215
+ raise CliError(
216
+ f"MiniMax 插件目录已有未知内容,拒绝覆盖: {dest}"
217
+ )
218
+ return
219
+ if manifest.is_symlink() or not manifest.is_file():
220
+ raise CliError(f"MiniMax 插件 manifest 无效: {manifest}")
221
+ try:
222
+ existing = json.loads(manifest.read_text(encoding="utf-8"))
223
+ except (OSError, UnicodeError, json.JSONDecodeError) as exc:
224
+ raise CliError(f"MiniMax 插件 manifest 无法解析,已阻断覆盖: {manifest}") from exc
225
+ if not isinstance(existing, dict) or existing.get("name") != _PLUGIN_NAME:
226
+ raise CliError(f"MiniMax 插件目录属于其他插件,拒绝覆盖: {dest}")
227
+
228
+ entries = list(dest.rglob("*"))
229
+ if len(entries) > 2048:
230
+ raise CliError(f"MiniMax 插件目录条目超过 V1 上限: {dest}")
231
+ total_bytes = 0
232
+ for entry in entries:
233
+ if entry.is_symlink():
234
+ raise CliError(f"MiniMax 插件包禁止符号链接: {entry}")
235
+ if entry.is_dir():
236
+ continue
237
+ if not entry.is_file():
238
+ raise CliError(f"MiniMax 插件包包含特殊文件: {entry}")
239
+ stat_result = entry.stat()
240
+ if stat_result.st_nlink > 1:
241
+ raise CliError(f"MiniMax 插件包禁止硬链接文件: {entry}")
242
+ if stat_result.st_size > 16 * 1024 * 1024:
243
+ raise CliError(f"MiniMax 插件单文件超过 V1 上限: {entry}")
244
+ total_bytes += stat_result.st_size
245
+ relative = entry.relative_to(dest).as_posix()
246
+ try:
247
+ relative.encode("ascii")
248
+ except UnicodeEncodeError as exc:
249
+ raise CliError(f"MiniMax 插件路径必须是 ASCII: {entry}") from exc
250
+ if len(relative.encode("ascii")) > 512 or len(relative.split("/")) > 16:
251
+ raise CliError(f"MiniMax 插件路径超过 V1 上限: {entry}")
252
+ if total_bytes > 64 * 1024 * 1024:
253
+ raise CliError(f"MiniMax 插件包总大小超过 V1 上限: {dest}")
254
+
255
+
256
+ def _ensure_minimax_plugin(
257
+ root: Path,
258
+ source: Path,
259
+ *,
260
+ locale: str | None = None,
261
+ ) -> dict[str, Any]:
262
+ """Install the complete MiniMax Plugin V1 package and return an audit receipt."""
263
+ del locale
264
+ data_dir = _minimax_data_dir()
265
+ if not data_dir.is_dir():
266
+ raise CliError(
267
+ f"未找到 MiniMax Code 数据目录: {data_dir}。"
268
+ "请先启动一次 MiniMax Code,或设置有效的 MINIMAX_DATA_DIR。"
269
+ )
270
+
271
+ skill_src = _find_bugx_skill_source(root, source)
272
+ if skill_src is None:
273
+ raise CliError("未找到 BugX SKILL.md,已阻断 MiniMax 插件安装。")
274
+ avatar_src = _find_bugx_avatar_source()
275
+ if avatar_src is None:
276
+ raise CliError("未找到 BugX PNG 图标,已阻断 MiniMax 插件安装。")
277
+
278
+ dest = _minimax_plugin_root()
279
+ _validate_existing_package(dest)
280
+ dest.mkdir(parents=True, exist_ok=True)
281
+
282
+ manifest_bytes = (
283
+ json.dumps(_build_plugin_manifest(), indent=2, ensure_ascii=False) + "\n"
284
+ ).encode("utf-8")
285
+ mcp_bytes = (
286
+ json.dumps(_build_mcp_manifest(), indent=2, ensure_ascii=False) + "\n"
287
+ ).encode("utf-8")
288
+ avatar_bytes = avatar_src.read_bytes()
289
+ written: list[dict[str, Any]] = []
290
+
291
+ _write_owned_file(dest / ".minimax-plugin" / "plugin.json", manifest_bytes, written)
292
+ _write_owned_file(dest / "servers.mcp.json", mcp_bytes, written)
293
+ _write_owned_file(dest / "icon.png", avatar_bytes, written)
294
+ _write_owned_file(
295
+ dest / "agents" / "bugx.md",
296
+ _build_main_agent().encode("utf-8"),
297
+ written,
298
+ )
299
+ _write_owned_file(
300
+ dest / "agents" / "bugx-worker.md",
301
+ _build_worker_agent().encode("utf-8"),
302
+ written,
303
+ )
304
+ _write_owned_file(
305
+ dest / "skills" / "bugx" / "SKILL.md",
306
+ skill_src.read_bytes(),
307
+ written,
308
+ )
309
+ _validate_existing_package(dest)
310
+
311
+ changed = any(item["status"] != "unchanged" for item in written)
312
+ return {
313
+ "status": "updated" if changed else "unchanged",
314
+ "dir": str(dest),
315
+ "home": str(data_dir),
316
+ "manifest_path": str(dest / ".minimax-plugin" / "plugin.json"),
317
+ "mcp_path": str(dest / "servers.mcp.json"),
318
+ "agent_path": str(dest / "agents" / "bugx.md"),
319
+ "worker_agent_path": str(dest / "agents" / "bugx-worker.md"),
320
+ "written": written,
321
+ "backups": [],
322
+ }