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.
- package/README.md +26 -29
- package/core/agent/agent_orchestrator.py +3 -0
- package/core/agent/agent_workspace.py +14 -2
- 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 +2 -2
- package/core/bugx_paths.py +2 -2
- package/core/cli-help.txt +1 -1
- package/core/contracts/bugx-opencode.md +1 -1
- package/core/contracts/bugx-runtime-contract.md +1 -1
- package/core/contracts/bugx-worker.md +1 -1
- package/core/engine-integrity.json +82 -42
- package/core/host_acp/kimi.py +175 -0
- package/core/host_acp/minimax.py +28 -0
- package/core/host_runtime/host_registry.py +23 -3
- package/core/hosts/dsh.py +1 -1
- package/core/hosts/kimi.py +293 -0
- package/core/hosts/minimax.py +248 -0
- package/core/hosts/zcode.py +5 -0
- package/core/infra/build_info.py +30 -5
- package/core/launch_phases/startup_version_gate.py +2 -2
- package/core/launch_phases/supervisor_bridge.py +14 -23
- package/core/metadata.txt +2 -2
- package/core/runtime/scenario_eval.py +1 -1
- package/core/runtime/setup_ui_env.py +4 -7
- package/core/supervisor/cli.py +2 -2
- package/core/webui/mcp_inspector.py +6 -0
- 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 +1 -1
- package/ecosystem/integrations/dsh/agents/bugx.md +1 -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 +1 -1
- 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 +1 -1
- package/ecosystem/integrations/pi/extensions/bugx/manifest.json +1 -1
- package/ecosystem/integrations/pi/skills/bugx/SKILL.md +1 -1
- 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 +2 -2
- 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 +1 -1
- package/ecosystem/plugins/bugx/agents/bugx.md +1 -1
- package/ecosystem/plugins/bugx/skills/bugx/SKILL.md +3 -3
- 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 +1 -1
- package/interfaces/bin/bugx.js +2 -0
- package/interfaces/cli/bugx_cli/__init__.py +2 -2
- package/interfaces/cli/bugx_cli/cli.py +15 -0
- package/interfaces/cli/bugx_cli/commands/agent.py +192 -67
- package/interfaces/cli/bugx_cli/commands/doctor.py +18 -0
- package/interfaces/cli/bugx_cli/commands/lifecycle.py +54 -47
- package/interfaces/cli/bugx_cli/commands/plugin.py +6 -6
- package/interfaces/cli/bugx_cli/commands/plugin_claude.py +27 -13
- package/interfaces/cli/bugx_cli/commands/plugin_kimi.py +348 -0
- package/interfaces/cli/bugx_cli/commands/plugin_minimax.py +322 -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 +64 -4
- package/interfaces/cli/bugx_cli/common.py +96 -7
- package/interfaces/cli/bugx_cli/host_adapters.py +150 -4
- package/interfaces/cli/bugx_cli/hosts/registry.py +4 -2
- package/interfaces/cli/bugx_cli/hosts/template_engine.py +10 -9
- package/interfaces/cli/bugx_cli/infra/engine_installer.py +4 -4
- package/interfaces/cli/bugx_cli/infra/host_sync.py +1 -1
- package/interfaces/cli/bugx_cli/infra/mcp_advisor.py +2 -2
- package/package.json +37 -13
- package/pyproject.toml +36 -12
- package/scripts/sync-version.mjs +1 -1
- package/skills/README.md +25 -0
- package/skills/platform/bugx-user/SKILL.md +92 -0
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""core/hosts/kimi.py - Kimi Code CLI 插件(DOC-239 六面架构完整适配)。
|
|
3
|
+
|
|
4
|
+
事实来源(2026-11-23 实测,Kimi Code 1.4.2 / ``KIMI_CODE_HOME``):
|
|
5
|
+
|
|
6
|
+
* identity ← ``kimi --help``:可执行文件名为 ``kimi``,别名 ``kimi-code`` / ``kimicode``;
|
|
7
|
+
项目标记为 ``.kimi-code/mcp.json`` 与 ``.kimi-code``。
|
|
8
|
+
* install ← ``subagent`` 入口:``.kimi-code/agents/bugx.md`` 与
|
|
9
|
+
``.kimi-code/agents/bugx-worker.md``;支持项目级与用户级
|
|
10
|
+
``~/.kimi-code/skills/`` 及原生 ``mcpServers`` 配置。
|
|
11
|
+
* engine_run ← 无头通道为 ``kimi -p <prompt>``,自治执行为
|
|
12
|
+
``kimi -p <prompt> --output-format stream-json --auto``;
|
|
13
|
+
支持自定义 subagent 定义(``--agent`` / ``--agent-file``)。
|
|
14
|
+
* worker_runtime← ``mode="multi"``,支持 CLI 并发调度。
|
|
15
|
+
* mcp_write ← 配置容器键为 ``mcpServers``,项目级作用域为 ``.kimi-code/mcp.json``,
|
|
16
|
+
全局作用域为 ``<KIMI_CODE_HOME>/mcp.json``(默认 ``~/.kimi-code/mcp.json``)。
|
|
17
|
+
* distribution ← 桌面端插件目录为 ``<KIMI_CODE_HOME>/plugins/managed/<id>``,
|
|
18
|
+
启用注册表为 ``<KIMI_CODE_HOME>/plugins/installed.json``。
|
|
19
|
+
* acp ← ``kimi acp`` 原生支持标准 JSON-RPC 2.0 ACP 协议,由
|
|
20
|
+
``core/host_acp/kimi.py`` 以 ``status="ready"`` 声明。
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
from __future__ import annotations
|
|
24
|
+
|
|
25
|
+
import os
|
|
26
|
+
import platform
|
|
27
|
+
import shutil
|
|
28
|
+
from pathlib import Path
|
|
29
|
+
|
|
30
|
+
from .base import (
|
|
31
|
+
AcpFacet,
|
|
32
|
+
EngineRunFacet,
|
|
33
|
+
HostPlugin,
|
|
34
|
+
IdentityFacet,
|
|
35
|
+
InstallFacet,
|
|
36
|
+
McpWriteFacet,
|
|
37
|
+
RunContext,
|
|
38
|
+
STATUS_READY,
|
|
39
|
+
WorkerRuntimeFacet,
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
__all__ = ["PLUGIN", "is_available", "run_static_degraded"]
|
|
43
|
+
|
|
44
|
+
_NAME = "kimi"
|
|
45
|
+
|
|
46
|
+
_PROJECT_PATHS: tuple[str, ...] = (
|
|
47
|
+
".kimi-code/agents/bugx.md",
|
|
48
|
+
".kimi-code/agents/bugx-worker.md",
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
_CUSTOM_TITLE = "# BugX\n\n这是 BugX 的 Kimi Code 审计智能体入口。"
|
|
52
|
+
|
|
53
|
+
_CUSTOM_PREAMBLE = (
|
|
54
|
+
"先读取全局引擎协议:\n"
|
|
55
|
+
"通过 `bugx engine path --name bugx-runtime-contract.md` 读取全局协议,\n"
|
|
56
|
+
"并遵守其中的寿命、Supervisor、证据和报告协议。\n\n"
|
|
57
|
+
"该入口只把任务交给当前 Kimi Code 会话;BugX CLI 只安装资源,不启动 Kimi Code、不执行审计。\n"
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def _kimi_code_home() -> Path:
|
|
62
|
+
configured = os.environ.get("KIMI_CODE_HOME")
|
|
63
|
+
if configured and configured.strip():
|
|
64
|
+
return Path(configured).expanduser()
|
|
65
|
+
return Path.home() / ".kimi-code"
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def _resolve_kimi_executable() -> str | None:
|
|
69
|
+
found = shutil.which("kimi")
|
|
70
|
+
if found:
|
|
71
|
+
return found
|
|
72
|
+
bin_dir = _kimi_code_home() / "bin"
|
|
73
|
+
names = ("kimi.exe", "kimi.cmd", "kimi.bat", "kimi") if os.name == "nt" else ("kimi",)
|
|
74
|
+
for name in names:
|
|
75
|
+
fallback = bin_dir / name
|
|
76
|
+
if fallback.is_file():
|
|
77
|
+
return str(fallback)
|
|
78
|
+
return None
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def _windows_drive_roots() -> tuple[Path, ...]:
|
|
82
|
+
"""返回 Windows 当前可用的逻辑驱动器根目录。"""
|
|
83
|
+
if platform.system() != "Windows":
|
|
84
|
+
return ()
|
|
85
|
+
try:
|
|
86
|
+
import ctypes
|
|
87
|
+
|
|
88
|
+
mask = int(ctypes.windll.kernel32.GetLogicalDrives())
|
|
89
|
+
except (AttributeError, OSError, TypeError, ValueError):
|
|
90
|
+
return ()
|
|
91
|
+
return tuple(
|
|
92
|
+
Path(f"{chr(ord('A') + index)}:/")
|
|
93
|
+
for index in range(26)
|
|
94
|
+
if mask & (1 << index)
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def _headless_argv(ctx: RunContext) -> list[str]:
|
|
99
|
+
command = [_resolve_kimi_executable() or "kimi", "-p", ctx.prompt]
|
|
100
|
+
if ctx.session:
|
|
101
|
+
command[1:1] = ["--session", ctx.session]
|
|
102
|
+
if ctx.model:
|
|
103
|
+
command += ["-m", ctx.model]
|
|
104
|
+
return command
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def _autonomous_argv(ctx: RunContext) -> list[str]:
|
|
108
|
+
command = [_resolve_kimi_executable() or "kimi"]
|
|
109
|
+
if ctx.session:
|
|
110
|
+
command += ["--session", ctx.session]
|
|
111
|
+
if ctx.model:
|
|
112
|
+
command += ["-m", ctx.model]
|
|
113
|
+
command += [
|
|
114
|
+
"-p",
|
|
115
|
+
ctx.prompt,
|
|
116
|
+
"--output-format",
|
|
117
|
+
"stream-json",
|
|
118
|
+
"--auto",
|
|
119
|
+
]
|
|
120
|
+
return command
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def _mcp_config_paths(root: Path) -> tuple[Path, ...]:
|
|
124
|
+
return (root / ".kimi-code" / "mcp.json",)
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def _kimi_app_markers() -> tuple[Path, ...]:
|
|
128
|
+
"""Kimi 桌面端已知安装位置。"""
|
|
129
|
+
home = Path.home()
|
|
130
|
+
markers: list[Path] = []
|
|
131
|
+
if platform.system() == "Darwin":
|
|
132
|
+
markers.extend((
|
|
133
|
+
Path("/Applications/Kimi.app"),
|
|
134
|
+
Path("/Applications/Kimi Code.app"),
|
|
135
|
+
home / "Applications" / "Kimi.app",
|
|
136
|
+
home / "Applications" / "Kimi Code.app",
|
|
137
|
+
home / "Library" / "Application Support" / "kimi-desktop",
|
|
138
|
+
home / "Library" / "Application Support" / "Kimi Code",
|
|
139
|
+
))
|
|
140
|
+
elif os.name != "nt":
|
|
141
|
+
markers.extend((
|
|
142
|
+
home / ".local" / "share" / "applications" / "kimi.desktop",
|
|
143
|
+
home / ".local" / "share" / "applications" / "kimi-code.desktop",
|
|
144
|
+
Path("/usr/bin/kimi-desktop"),
|
|
145
|
+
Path("/usr/bin/kimi-code"),
|
|
146
|
+
Path("/opt/Kimi/kimi"),
|
|
147
|
+
Path("/opt/Kimi Code/kimi-code"),
|
|
148
|
+
))
|
|
149
|
+
|
|
150
|
+
bases: list[Path] = []
|
|
151
|
+
for variable in (
|
|
152
|
+
"LOCALAPPDATA", "APPDATA", "PROGRAMFILES", "PROGRAMFILES(X86)",
|
|
153
|
+
):
|
|
154
|
+
value = os.environ.get(variable)
|
|
155
|
+
if value:
|
|
156
|
+
bases.append(Path(value))
|
|
157
|
+
bases.extend(_windows_drive_roots())
|
|
158
|
+
for base in bases:
|
|
159
|
+
markers.extend((
|
|
160
|
+
base / "Kimi" / "Kimi.exe",
|
|
161
|
+
base / "kimi-desktop" / "Kimi.exe",
|
|
162
|
+
base / "Kimi Code" / "Kimi Code.exe",
|
|
163
|
+
base / "Programs" / "Kimi" / "Kimi.exe",
|
|
164
|
+
base / "Programs" / "kimi-desktop" / "Kimi.exe",
|
|
165
|
+
base / "Programs" / "Kimi Code" / "Kimi Code.exe",
|
|
166
|
+
base / "Program Files" / "Kimi Code" / "Kimi Code.exe",
|
|
167
|
+
base / "Program Files (x86)" / "Kimi Code" / "Kimi Code.exe",
|
|
168
|
+
))
|
|
169
|
+
return tuple(markers)
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def _agent_config_path(root: Path) -> Path:
|
|
173
|
+
return root / ".kimi-code"
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
PLUGIN = HostPlugin(
|
|
177
|
+
identity=IdentityFacet(
|
|
178
|
+
name=_NAME,
|
|
179
|
+
label="Kimi Code",
|
|
180
|
+
order=14,
|
|
181
|
+
executable="kimi",
|
|
182
|
+
markers=(".kimi-code/mcp.json", ".kimi-code"),
|
|
183
|
+
aliases=("kimi-code", "kimicode"),
|
|
184
|
+
app_markers=_kimi_app_markers,
|
|
185
|
+
native_question=True,
|
|
186
|
+
),
|
|
187
|
+
status=STATUS_READY,
|
|
188
|
+
install=InstallFacet(
|
|
189
|
+
kind="subagent",
|
|
190
|
+
path=".kimi-code/agents/bugx.md",
|
|
191
|
+
marker=".kimi-code",
|
|
192
|
+
required_paths=_PROJECT_PATHS,
|
|
193
|
+
capabilities=frozenset(
|
|
194
|
+
{
|
|
195
|
+
"native-mcp-config",
|
|
196
|
+
"extra-tracked-paths",
|
|
197
|
+
"skills",
|
|
198
|
+
"user-agent-registration",
|
|
199
|
+
}
|
|
200
|
+
),
|
|
201
|
+
interaction={
|
|
202
|
+
"tool": "AskUserQuestion",
|
|
203
|
+
"single_select": "multiSelect=false",
|
|
204
|
+
"multi_select": "tooling:batch 时使用 multiSelect=true",
|
|
205
|
+
},
|
|
206
|
+
tools_line="Bash, Read, Grep, Glob, Edit, Write",
|
|
207
|
+
mcp_relpaths=(".kimi-code/mcp.json",),
|
|
208
|
+
worker_subagent=True,
|
|
209
|
+
worker_entry_path=".kimi-code/agents/bugx-worker.md",
|
|
210
|
+
custom_title=_CUSTOM_TITLE,
|
|
211
|
+
custom_preamble=_CUSTOM_PREAMBLE,
|
|
212
|
+
generated_dirs=(".kimi-code",),
|
|
213
|
+
sweepable=True,
|
|
214
|
+
),
|
|
215
|
+
engine_run=EngineRunFacet(
|
|
216
|
+
supports_headless=True,
|
|
217
|
+
headless_argv=_headless_argv,
|
|
218
|
+
autonomous_argv=_autonomous_argv,
|
|
219
|
+
mcp_config_paths=_mcp_config_paths,
|
|
220
|
+
agent_config_path=_agent_config_path,
|
|
221
|
+
mcp_health=None,
|
|
222
|
+
host_surface="tui",
|
|
223
|
+
recon_scout_argv=lambda _root, text, _prompt_file, _inventory=None: [
|
|
224
|
+
_resolve_kimi_executable() or "kimi",
|
|
225
|
+
"-p",
|
|
226
|
+
text,
|
|
227
|
+
"--output-format",
|
|
228
|
+
"text",
|
|
229
|
+
"--auto",
|
|
230
|
+
],
|
|
231
|
+
native_task=True,
|
|
232
|
+
),
|
|
233
|
+
worker_runtime=WorkerRuntimeFacet(
|
|
234
|
+
mode="multi",
|
|
235
|
+
max_concurrency=None,
|
|
236
|
+
requires_process_mode=False,
|
|
237
|
+
sandbox_sync=(),
|
|
238
|
+
),
|
|
239
|
+
mcp_write=McpWriteFacet(
|
|
240
|
+
container_key="mcpServers",
|
|
241
|
+
writer_key=_NAME,
|
|
242
|
+
project_relpath=".kimi-code/mcp.json",
|
|
243
|
+
global_scope="~/.kimi-code/mcp.json",
|
|
244
|
+
mirror_relpaths=(),
|
|
245
|
+
requires_absolutize=True,
|
|
246
|
+
entry_extra={},
|
|
247
|
+
),
|
|
248
|
+
acp=AcpFacet(plugin=_NAME),
|
|
249
|
+
)
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
def is_available() -> tuple[bool, str]:
|
|
253
|
+
"""降级契约:机械探活 Kimi Code CLI 是否安装(零子进程)。"""
|
|
254
|
+
path = _resolve_kimi_executable()
|
|
255
|
+
if path is None:
|
|
256
|
+
return False, "kimi 可执行文件未安装;headless(kimi -p)与 ACP(kimi acp)通道不可用"
|
|
257
|
+
return True, path
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
def run_static_degraded(root: Path | None = None) -> dict:
|
|
261
|
+
"""Kimi Code CLI 缺失时的静态降级输出:只声明插件事实,绝不伪装宿主健康。"""
|
|
262
|
+
available, availability_detail = is_available()
|
|
263
|
+
return {
|
|
264
|
+
"plugin": _NAME,
|
|
265
|
+
"schema_version": 1,
|
|
266
|
+
"success": available,
|
|
267
|
+
"status": "degraded",
|
|
268
|
+
"degraded": True,
|
|
269
|
+
"degraded_reason": (
|
|
270
|
+
"static_facts_only" if available else "kimi_cli_not_installed"
|
|
271
|
+
),
|
|
272
|
+
"probe_mode": "static_degraded",
|
|
273
|
+
"headless_available": available,
|
|
274
|
+
"native_task_available": bool(available and PLUGIN.engine_run.native_task),
|
|
275
|
+
"identity": {
|
|
276
|
+
"executable": PLUGIN.identity.executable,
|
|
277
|
+
"aliases": list(PLUGIN.identity.aliases),
|
|
278
|
+
"markers": list(PLUGIN.identity.markers),
|
|
279
|
+
},
|
|
280
|
+
"agent_entry": PLUGIN.install.path,
|
|
281
|
+
"mcp_project_relpath": PLUGIN.mcp_write.project_relpath,
|
|
282
|
+
"mcp_global_scope": PLUGIN.mcp_write.global_scope,
|
|
283
|
+
"findings": [],
|
|
284
|
+
"evidence": {
|
|
285
|
+
"availability_detail": availability_detail,
|
|
286
|
+
"project_root": str(root) if root else None,
|
|
287
|
+
},
|
|
288
|
+
"metadata": {
|
|
289
|
+
"degraded_mode": "static_plugin_facts_only",
|
|
290
|
+
"acp": "ready(kimi acp 原生支持标准 ACP,见 core/host_acp/kimi.py)",
|
|
291
|
+
"fallback": "宿主 CLI 缺失时由外层宿主/用户决策接管;BugX 不代装宿主 CLI",
|
|
292
|
+
},
|
|
293
|
+
}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""core/hosts/minimax.py - MiniMax Code desktop Plugin V1 host.
|
|
3
|
+
|
|
4
|
+
Facts captured from the installed MiniMax Code 3.1.0 package on Windows and its
|
|
5
|
+
embedded local-plugin-v1 contract:
|
|
6
|
+
|
|
7
|
+
* user plugins are discovered below ~/.minimax/plugins/<plugin>/;
|
|
8
|
+
* the package manifest is .minimax-plugin/plugin.json;
|
|
9
|
+
* MCP servers are declared in servers.mcp.json;
|
|
10
|
+
* plugin Agents are Markdown files under agents/ and Skills under skills/.
|
|
11
|
+
|
|
12
|
+
The desktop package exposes the PluginSystem/MCP/Agent surface, but this
|
|
13
|
+
repository has not verified a MiniMax Code headless or standard ACP entry point.
|
|
14
|
+
Those channels therefore fail closed instead of borrowing Kimi or another host's
|
|
15
|
+
flags.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
from __future__ import annotations
|
|
19
|
+
|
|
20
|
+
import os
|
|
21
|
+
import platform
|
|
22
|
+
import shutil
|
|
23
|
+
from pathlib import Path
|
|
24
|
+
|
|
25
|
+
from .base import (
|
|
26
|
+
AcpFacet,
|
|
27
|
+
EngineRunFacet,
|
|
28
|
+
HostPlugin,
|
|
29
|
+
HostPluginError,
|
|
30
|
+
IdentityFacet,
|
|
31
|
+
InstallFacet,
|
|
32
|
+
McpWriteFacet,
|
|
33
|
+
RunContext,
|
|
34
|
+
STATUS_READY,
|
|
35
|
+
WorkerRuntimeFacet,
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
__all__ = ["PLUGIN", "is_available", "run_static_degraded"]
|
|
39
|
+
|
|
40
|
+
_NAME = "minimax"
|
|
41
|
+
_DATA_ENV = "MINIMAX_DATA_DIR"
|
|
42
|
+
_DEFAULT_DATA_DIR_NAME = ".minimax"
|
|
43
|
+
_PLUGIN_RELATIVE_ROOT = ("plugins", "bugx")
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def _minimax_data_dir() -> Path:
|
|
47
|
+
configured = os.environ.get(_DATA_ENV)
|
|
48
|
+
if configured is not None:
|
|
49
|
+
if not configured.strip():
|
|
50
|
+
raise HostPluginError(f"{_DATA_ENV} 不能为空")
|
|
51
|
+
return Path(configured).expanduser()
|
|
52
|
+
return Path.home() / _DEFAULT_DATA_DIR_NAME
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def _minimax_plugin_root() -> Path:
|
|
56
|
+
return _minimax_data_dir().joinpath(*_PLUGIN_RELATIVE_ROOT)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _windows_drive_roots() -> tuple[Path, ...]:
|
|
60
|
+
if platform.system() != "Windows":
|
|
61
|
+
return ()
|
|
62
|
+
try:
|
|
63
|
+
import ctypes
|
|
64
|
+
|
|
65
|
+
mask = int(ctypes.windll.kernel32.GetLogicalDrives())
|
|
66
|
+
except (AttributeError, OSError, TypeError, ValueError):
|
|
67
|
+
return ()
|
|
68
|
+
return tuple(
|
|
69
|
+
Path(f"{chr(ord('A') + index)}:/")
|
|
70
|
+
for index in range(26)
|
|
71
|
+
if mask & (1 << index)
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def _minimax_app_markers() -> tuple[Path, ...]:
|
|
76
|
+
"""Return bounded MiniMax Code installation candidates; never scan a drive."""
|
|
77
|
+
home = Path.home()
|
|
78
|
+
markers: list[Path] = []
|
|
79
|
+
if platform.system() == "Darwin":
|
|
80
|
+
markers.extend((
|
|
81
|
+
Path("/Applications/MiniMax Code.app"),
|
|
82
|
+
home / "Applications" / "MiniMax Code.app",
|
|
83
|
+
))
|
|
84
|
+
elif os.name != "nt":
|
|
85
|
+
markers.extend((
|
|
86
|
+
home / ".local" / "share" / "applications" / "minimax-code.desktop",
|
|
87
|
+
Path("/opt/minimax/MiniMax Code/MiniMax Code"),
|
|
88
|
+
))
|
|
89
|
+
|
|
90
|
+
bases: list[Path] = []
|
|
91
|
+
for variable in (
|
|
92
|
+
"LOCALAPPDATA", "APPDATA", "PROGRAMFILES", "PROGRAMFILES(X86)",
|
|
93
|
+
):
|
|
94
|
+
value = os.environ.get(variable)
|
|
95
|
+
if value:
|
|
96
|
+
bases.append(Path(value))
|
|
97
|
+
bases.extend(_windows_drive_roots())
|
|
98
|
+
|
|
99
|
+
for base in bases:
|
|
100
|
+
markers.extend((
|
|
101
|
+
base / "minimax" / "MiniMax Code" / "MiniMax Code.exe",
|
|
102
|
+
base / "MiniMax" / "MiniMax Code" / "MiniMax Code.exe",
|
|
103
|
+
base / "Programs" / "minimax" / "MiniMax Code" / "MiniMax Code.exe",
|
|
104
|
+
base / "Programs" / "MiniMax" / "MiniMax Code" / "MiniMax Code.exe",
|
|
105
|
+
base / "Program Files" / "minimax" / "MiniMax Code" / "MiniMax Code.exe",
|
|
106
|
+
base / "Program Files (x86)" / "minimax" / "MiniMax Code" / "MiniMax Code.exe",
|
|
107
|
+
))
|
|
108
|
+
return tuple(dict.fromkeys(markers))
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def _unsupported_headless(_ctx: RunContext) -> list[str]:
|
|
112
|
+
raise HostPluginError(
|
|
113
|
+
"MiniMax Code 当前仅完成桌面 Plugin V1 适配;headless CLI 入口和 flag 尚未取证,拒绝伪造启动参数"
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def _unsupported_autonomous(_ctx: RunContext) -> list[str]:
|
|
118
|
+
raise HostPluginError(
|
|
119
|
+
"MiniMax Code 当前仅完成桌面 Agent/MCP 插件适配;自治 CLI 入口尚未取证,拒绝伪造启动参数"
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def _mcp_config_paths(_root: Path) -> tuple[Path, ...]:
|
|
124
|
+
return (_minimax_plugin_root() / "servers.mcp.json",)
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def _agent_config_path(_root: Path) -> Path:
|
|
128
|
+
return _minimax_plugin_root() / ".minimax-plugin" / "plugin.json"
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def _resolve_minimax_cli() -> str | None:
|
|
132
|
+
"""Only report a PATH-resolved CLI; do not infer its command-line contract."""
|
|
133
|
+
return shutil.which("mcode")
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
PLUGIN = HostPlugin(
|
|
137
|
+
identity=IdentityFacet(
|
|
138
|
+
name=_NAME,
|
|
139
|
+
label="MiniMax Code",
|
|
140
|
+
order=16,
|
|
141
|
+
executable="mcode",
|
|
142
|
+
markers=(".minimax/plugins/bugx/.minimax-plugin/plugin.json", ".minimax"),
|
|
143
|
+
aliases=("minimax-code", "minimaxcode", "mcode"),
|
|
144
|
+
app_markers=_minimax_app_markers,
|
|
145
|
+
native_question=False,
|
|
146
|
+
),
|
|
147
|
+
status=STATUS_READY,
|
|
148
|
+
install=InstallFacet(
|
|
149
|
+
kind="plugin",
|
|
150
|
+
path=".minimax/plugins/bugx",
|
|
151
|
+
entry_mode="user-registration",
|
|
152
|
+
marker=".minimax",
|
|
153
|
+
required_paths=(),
|
|
154
|
+
capabilities=frozenset({
|
|
155
|
+
"user-agent-registration",
|
|
156
|
+
"user-level-plugin",
|
|
157
|
+
}),
|
|
158
|
+
interaction={
|
|
159
|
+
"tool": "MiniMax Code Agent UI",
|
|
160
|
+
"single_select": "host-native",
|
|
161
|
+
"multi_select": "host-native",
|
|
162
|
+
},
|
|
163
|
+
tools_line="read, write, edit, bash, grep, glob, web_fetch",
|
|
164
|
+
mcp_relpaths=(),
|
|
165
|
+
worker_subagent=True,
|
|
166
|
+
worker_entry_path=".minimax/plugins/bugx/agents/bugx-worker.md",
|
|
167
|
+
generated_dirs=(),
|
|
168
|
+
sweepable=False,
|
|
169
|
+
),
|
|
170
|
+
engine_run=EngineRunFacet(
|
|
171
|
+
supports_headless=False,
|
|
172
|
+
headless_argv=_unsupported_headless,
|
|
173
|
+
autonomous_argv=_unsupported_autonomous,
|
|
174
|
+
mcp_config_paths=_mcp_config_paths,
|
|
175
|
+
agent_config_path=_agent_config_path,
|
|
176
|
+
mcp_health=None,
|
|
177
|
+
host_surface="desktop",
|
|
178
|
+
native_task=False,
|
|
179
|
+
),
|
|
180
|
+
worker_runtime=WorkerRuntimeFacet(
|
|
181
|
+
mode="serial",
|
|
182
|
+
max_concurrency=1,
|
|
183
|
+
requires_process_mode=False,
|
|
184
|
+
sandbox_sync=(),
|
|
185
|
+
provider_key=_NAME,
|
|
186
|
+
autonomous_cli=False,
|
|
187
|
+
),
|
|
188
|
+
mcp_write=McpWriteFacet(
|
|
189
|
+
container_key="mcpServers",
|
|
190
|
+
writer_key=_NAME,
|
|
191
|
+
project_relpath=None,
|
|
192
|
+
global_scope="~/.minimax/plugins/bugx/servers.mcp.json",
|
|
193
|
+
mirror_relpaths=(),
|
|
194
|
+
requires_absolutize=False,
|
|
195
|
+
entry_extra={},
|
|
196
|
+
custom_writer=True,
|
|
197
|
+
),
|
|
198
|
+
acp=AcpFacet(plugin=_NAME),
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
def is_available() -> tuple[bool, str]:
|
|
203
|
+
"""Report the local CLI without claiming its unverified flags are supported."""
|
|
204
|
+
path = _resolve_minimax_cli()
|
|
205
|
+
if path:
|
|
206
|
+
return True, path
|
|
207
|
+
app_path = next((path for path in _minimax_app_markers() if path.is_file()), None)
|
|
208
|
+
if app_path:
|
|
209
|
+
return True, str(app_path)
|
|
210
|
+
return False, "MiniMax Code desktop/CLI 未在已知位置找到"
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
def run_static_degraded(root: Path | None = None) -> dict:
|
|
214
|
+
"""Return static plugin facts; never report a live desktop session as healthy."""
|
|
215
|
+
available, availability_detail = is_available()
|
|
216
|
+
plugin_root = _minimax_plugin_root()
|
|
217
|
+
manifest = plugin_root / ".minimax-plugin" / "plugin.json"
|
|
218
|
+
return {
|
|
219
|
+
"plugin": _NAME,
|
|
220
|
+
"schema_version": 1,
|
|
221
|
+
"success": available,
|
|
222
|
+
"status": "degraded",
|
|
223
|
+
"degraded": True,
|
|
224
|
+
"degraded_reason": "static_facts_only" if available else "minimax_host_not_found",
|
|
225
|
+
"probe_mode": "static_degraded",
|
|
226
|
+
"headless_available": False,
|
|
227
|
+
"native_task_available": False,
|
|
228
|
+
"identity": {
|
|
229
|
+
"executable": PLUGIN.identity.executable,
|
|
230
|
+
"aliases": list(PLUGIN.identity.aliases),
|
|
231
|
+
"markers": list(PLUGIN.identity.markers),
|
|
232
|
+
},
|
|
233
|
+
"agent_entry": str(plugin_root / "agents" / "bugx.md"),
|
|
234
|
+
"worker_entry": str(plugin_root / "agents" / "bugx-worker.md"),
|
|
235
|
+
"plugin_manifest": str(manifest),
|
|
236
|
+
"mcp_config": str(plugin_root / "servers.mcp.json"),
|
|
237
|
+
"findings": [],
|
|
238
|
+
"evidence": {
|
|
239
|
+
"availability_detail": availability_detail,
|
|
240
|
+
"project_root": str(root) if root else None,
|
|
241
|
+
"plugin_installed": manifest.is_file(),
|
|
242
|
+
},
|
|
243
|
+
"metadata": {
|
|
244
|
+
"degraded_mode": "static_plugin_facts_only",
|
|
245
|
+
"acp": "unavailable(尚未取证到 MiniMax Code 标准 ACP 入口)",
|
|
246
|
+
"fallback": "MiniMax Code 以桌面 Plugin V1 运行;BugX 不代装宿主、不伪造 headless/ACP",
|
|
247
|
+
},
|
|
248
|
+
}
|
package/core/hosts/zcode.py
CHANGED
|
@@ -106,6 +106,11 @@ def _zcode_app_markers() -> tuple[Path, ...]:
|
|
|
106
106
|
base / "Z.ai" / "ZCode" / "ZCode.exe",
|
|
107
107
|
base / "Programs" / "ZCode" / "ZCode.exe",
|
|
108
108
|
base / "Programs" / "Z.ai" / "ZCode.exe",
|
|
109
|
+
base / "Programs" / "Z.ai" / "ZCode" / "ZCode.exe",
|
|
110
|
+
base / "Program Files" / "ZCode" / "ZCode.exe",
|
|
111
|
+
base / "Program Files (x86)" / "ZCode" / "ZCode.exe",
|
|
112
|
+
base / "Program Files" / "Z.ai" / "ZCode" / "ZCode.exe",
|
|
113
|
+
base / "Program Files (x86)" / "Z.ai" / "ZCode" / "ZCode.exe",
|
|
109
114
|
))
|
|
110
115
|
return tuple(markers)
|
|
111
116
|
|
package/core/infra/build_info.py
CHANGED
|
@@ -12,8 +12,8 @@ import re
|
|
|
12
12
|
from pathlib import Path
|
|
13
13
|
|
|
14
14
|
VERSION_ENV = "BUGX_VERSION"
|
|
15
|
-
VERSION_TOKEN = "0.1.
|
|
16
|
-
_DEFAULT_VERSION = "0.1.
|
|
15
|
+
VERSION_TOKEN = "0.1.3"
|
|
16
|
+
_DEFAULT_VERSION = "0.1.3"
|
|
17
17
|
_VERSION_RE = re.compile(r"^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$")
|
|
18
18
|
|
|
19
19
|
|
|
@@ -88,10 +88,34 @@ def bump_build_id(root: Path | None = None) -> int:
|
|
|
88
88
|
return next_id
|
|
89
89
|
|
|
90
90
|
|
|
91
|
+
def is_dev_mode(root: Path | None = None) -> bool:
|
|
92
|
+
"""是否处于 dev / alpha 开发模式。正式版返回 False。"""
|
|
93
|
+
if os.environ.get("BUGX_DEV") in ("1", "true", "yes", "on"):
|
|
94
|
+
return True
|
|
95
|
+
env = os.environ.get("BUGX_ENV", "").strip().lower()
|
|
96
|
+
if env in ("dev", "development", "local", "test"):
|
|
97
|
+
return True
|
|
98
|
+
meta_path = _resolve_metadata_path(root)
|
|
99
|
+
if meta_path.is_file():
|
|
100
|
+
try:
|
|
101
|
+
content = meta_path.read_text(encoding="utf-8")
|
|
102
|
+
m_chan = re.search(r"^bugx_channel:\s*[\"']?([A-Za-z0-9_-]+)", content, re.M)
|
|
103
|
+
m_mark = re.search(r"^bugx_marker:\s*[\"']?([A-Za-z0-9_-]+)", content, re.M)
|
|
104
|
+
channel = m_chan.group(1).lower() if m_chan else "stable"
|
|
105
|
+
marker = m_mark.group(1).lower() if m_mark else "stable"
|
|
106
|
+
if channel != "stable" or marker in ("dev", "alpha"):
|
|
107
|
+
return True
|
|
108
|
+
except OSError:
|
|
109
|
+
pass
|
|
110
|
+
return False
|
|
111
|
+
|
|
112
|
+
|
|
91
113
|
def get_full_version_string(root: Path | None = None) -> str:
|
|
92
|
-
"""
|
|
93
|
-
|
|
94
|
-
|
|
114
|
+
"""返回标准版本展示字符串。正式版(Stable)不带 build ID;仅 dev 模式携带。"""
|
|
115
|
+
if is_dev_mode(root):
|
|
116
|
+
bid = get_build_id(root)
|
|
117
|
+
return f"{BASE_VERSION}+build.{bid}"
|
|
118
|
+
return BASE_VERSION
|
|
95
119
|
|
|
96
120
|
|
|
97
121
|
__all__ = [
|
|
@@ -101,5 +125,6 @@ __all__ = [
|
|
|
101
125
|
"bump_build_id",
|
|
102
126
|
"get_build_id",
|
|
103
127
|
"get_full_version_string",
|
|
128
|
+
"is_dev_mode",
|
|
104
129
|
"resolve_base_version",
|
|
105
130
|
]
|
|
@@ -240,8 +240,8 @@ def version_marker(path: Path) -> str | None:
|
|
|
240
240
|
if not match:
|
|
241
241
|
return None
|
|
242
242
|
value = match.group(1)
|
|
243
|
-
if value == "0.1.
|
|
244
|
-
value = os.environ.get("BUGX_VERSION", "0.1.
|
|
243
|
+
if value == "0.1.3":
|
|
244
|
+
value = os.environ.get("BUGX_VERSION", "0.1.3")
|
|
245
245
|
return value
|
|
246
246
|
|
|
247
247
|
def startup_release_version(value: object) -> tuple[int, int, int] | None:
|
|
@@ -1056,8 +1056,6 @@ def supervisor_mcp_gate(*, review_mode: str | None,
|
|
|
1056
1056
|
* ``"restart_required"`` —— 配置已写入/已存在但当前宿主未加载 ⇒ 必须重启宿主;
|
|
1057
1057
|
* ``"blocked"`` —— 需要用户/宿主决策或安装未完成。
|
|
1058
1058
|
"""
|
|
1059
|
-
if review_mode != "mcp-auto":
|
|
1060
|
-
return "ok"
|
|
1061
1059
|
# [BEGIN DEV_ONLY: FAST_VERIFICATION_MCP_GATE]
|
|
1062
1060
|
try:
|
|
1063
1061
|
from core.runtime.interaction import try_get_preset_runtime_config
|
|
@@ -1071,27 +1069,20 @@ def supervisor_mcp_gate(*, review_mode: str | None,
|
|
|
1071
1069
|
if preset_cfg.get("supervisor_mcp") in {"manual", "skip"}:
|
|
1072
1070
|
return "ok"
|
|
1073
1071
|
# [END DEV_ONLY: FAST_VERIFICATION_MCP_GATE]
|
|
1072
|
+
|
|
1074
1073
|
status = _supervisor_mcp_status()
|
|
1075
|
-
|
|
1074
|
+
# 强制重启门禁:若项目已配置 Supervisor MCP 但当前宿主会话未加载该工具链(stale),
|
|
1075
|
+
# 宿主进程无法动态感知新配置,探活绝不能替代重启,必须阻断并强制要求重启宿主。
|
|
1076
|
+
if status is not None and _mcp_session_is_stale(status):
|
|
1077
|
+
host = str(status.get("host") or "当前宿主")
|
|
1078
|
+
print(f"[launch_bugx] ✗ 必须强制重启宿主:{host} 已配置 Supervisor MCP,但当前会话尚未加载该 MCP 工具链。")
|
|
1079
|
+
print(" 宿主进程(IDE/终端)不支持动态热重载配置,必须【重载窗口 / 重启宿主会话】后再启动 BugX。")
|
|
1080
|
+
return "restart_required"
|
|
1081
|
+
|
|
1082
|
+
if review_mode != "mcp-auto":
|
|
1076
1083
|
return "ok"
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
# gate here, otherwise the host can silently choose manual review and move
|
|
1080
|
-
# on to the polling question (the bug this gate is meant to prevent).
|
|
1081
|
-
if _mcp_session_is_stale(status):
|
|
1082
|
-
# 尝试快速 stdio 活体探活(A1 自愈机制)
|
|
1083
|
-
try:
|
|
1084
|
-
from core.supervisor import supervisor_host
|
|
1085
|
-
probe_result = supervisor_host.probe_builtin_mcp_session(resolve_project_root(), deadline=None)
|
|
1086
|
-
if not probe_result.get("error"):
|
|
1087
|
-
os.environ[supervisor_host.MCP_SESSION_PROOF_ENV] = json.dumps(probe_result, ensure_ascii=False)
|
|
1088
|
-
return "ok"
|
|
1089
|
-
except Exception:
|
|
1090
|
-
pass
|
|
1091
|
-
if autonomous:
|
|
1092
|
-
print("[launch_bugx] ✗ 需要重启宿主:Supervisor MCP 已配置但当前宿主未加载且探活未通过;"
|
|
1093
|
-
"支持使用 stdio JSON-RPC 等效通道驱动,或重启宿主会话后重试。")
|
|
1094
|
-
return "restart_required"
|
|
1084
|
+
|
|
1085
|
+
if status is None:
|
|
1095
1086
|
return "ok"
|
|
1096
1087
|
if autonomous:
|
|
1097
1088
|
# The installer is already constrained to the BugX-managed host
|
|
@@ -1100,7 +1091,7 @@ def supervisor_mcp_gate(*, review_mode: str | None,
|
|
|
1100
1091
|
if not _install_supervisor_mcp(status):
|
|
1101
1092
|
print("[launch_bugx] 自治模式已停止:Supervisor MCP 安装失败(需宿主重启后重试)。")
|
|
1102
1093
|
return "restart_required"
|
|
1103
|
-
print("[launch_bugx] Supervisor MCP
|
|
1094
|
+
print("[launch_bugx] ✗ 必须强制重启宿主:Supervisor MCP 配置已写入;宿主重新启动后才能加载。")
|
|
1104
1095
|
return "restart_required"
|
|
1105
1096
|
choice = _prompt_supervisor_mcp(status, allow_manual=False)
|
|
1106
1097
|
if choice is None:
|
|
@@ -1133,7 +1124,7 @@ def supervisor_mcp_gate(*, review_mode: str | None,
|
|
|
1133
1124
|
return "blocked"
|
|
1134
1125
|
if choice == "install":
|
|
1135
1126
|
_install_supervisor_mcp(status)
|
|
1136
|
-
print("[launch_bugx] Supervisor MCP
|
|
1127
|
+
print("[launch_bugx] ✗ 必须强制重启宿主:Supervisor MCP 配置已写入;宿主重新启动后才能加载。")
|
|
1137
1128
|
return "restart_required"
|
|
1138
1129
|
if choice == "later":
|
|
1139
1130
|
print("[launch_bugx] Supervisor MCP 安装已延后,本轮启动停止。")
|