vod-devkit 0.4.4 → 0.5.1

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 (81) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/QUICKSTART.md +1 -1
  3. package/README.en.md +190 -56
  4. package/README.md +210 -56
  5. package/bin/vod-devkit +502 -460
  6. package/contract/tools.schema.json +114 -7
  7. package/integrations/codeartsdoer/host.json +11 -0
  8. package/integrations/codex/host.json +20 -0
  9. package/integrations/dsh/host.json +15 -0
  10. package/integrations/hermes/host.json +20 -0
  11. package/integrations/opencode/command/vod-doctor.md +10 -0
  12. package/integrations/opencode/host.json +28 -0
  13. package/package.json +13 -10
  14. package/plugins/vod-devkit/.codex-plugin/plugin.json +1 -1
  15. package/plugins/vod-devkit/build-info.json +3 -3
  16. package/plugins/vod-devkit/skills/vod-core/SKILL.md +43 -15
  17. package/plugins/vod-devkit/skills/vod-core/references/acceptance-criteria.md +9 -0
  18. package/plugins/vod-devkit/skills/vod-core/references/verification-method.md +29 -0
  19. package/plugins/vod-devkit/skills/vod-feedback-collect/SKILL.md +57 -11
  20. package/plugins/vod-devkit/skills/vod-feedback-collect/references/acceptance-criteria.md +28 -0
  21. package/plugins/vod-devkit/skills/vod-feedback-collect/references/verification-method.md +31 -0
  22. package/plugins/vod-devkit/skills/vod-problem-classification-rules/SKILL.md +3 -1
  23. package/plugins/vod-devkit/skills/vod-scoring-rules/SKILL.md +22 -1
  24. package/plugins/vod-devkit/vod_mcp/__init__.py +1 -1
  25. package/plugins/vod-devkit/vod_mcp/attribution.py +378 -0
  26. package/plugins/vod-devkit/vod_mcp/config_forms.py +154 -0
  27. package/plugins/vod-devkit/vod_mcp/guardrails.py +25 -0
  28. package/plugins/vod-devkit/vod_mcp/host_adapters/__init__.py +26 -0
  29. package/plugins/vod-devkit/vod_mcp/host_adapters/base.py +73 -0
  30. package/plugins/vod-devkit/vod_mcp/host_adapters/codearts.py +57 -0
  31. package/plugins/vod-devkit/vod_mcp/host_adapters/codex.py +209 -0
  32. package/plugins/vod-devkit/vod_mcp/host_adapters/dsh.py +176 -0
  33. package/plugins/vod-devkit/vod_mcp/host_adapters/generic.py +132 -0
  34. package/plugins/vod-devkit/vod_mcp/host_adapters/hermes.py +76 -0
  35. package/plugins/vod-devkit/vod_mcp/host_adapters/opencode.py +52 -0
  36. package/plugins/vod-devkit/vod_mcp/hosts.py +100 -0
  37. package/plugins/vod-devkit/vod_mcp/packs.py +19 -3
  38. package/plugins/vod-devkit/vod_mcp/payload.py +174 -0
  39. package/plugins/vod-devkit/vod_mcp/remote_app.py +100 -0
  40. package/plugins/vod-devkit/vod_mcp/server.py +43 -16
  41. package/plugins/vod-devkit/vod_mcp/skills_registry.py +124 -0
  42. package/plugins/vod-devkit/vod_mcp/tools.py +455 -55
  43. package/plugins/vod-devkit/vod_mcp/transport_remote.py +289 -0
  44. package/plugins/vod-devkit/vod_mcp/update_check.py +133 -0
  45. package/skills/vod-core/SKILL.md +43 -15
  46. package/skills/vod-core/references/acceptance-criteria.md +9 -0
  47. package/skills/vod-core/references/verification-method.md +29 -0
  48. package/skills/vod-feedback-collect/SKILL.md +57 -11
  49. package/skills/vod-feedback-collect/references/acceptance-criteria.md +28 -0
  50. package/skills/vod-feedback-collect/references/verification-method.md +31 -0
  51. package/skills/vod-problem-classification-rules/SKILL.md +3 -1
  52. package/skills/vod-scoring-rules/SKILL.md +22 -1
  53. package/vod_mcp/__init__.py +1 -1
  54. package/vod_mcp/attribution.py +378 -0
  55. package/vod_mcp/config_forms.py +154 -0
  56. package/vod_mcp/guardrails.py +25 -0
  57. package/vod_mcp/host_adapters/__init__.py +26 -0
  58. package/vod_mcp/host_adapters/__pycache__/__init__.cpython-314.pyc +0 -0
  59. package/vod_mcp/host_adapters/__pycache__/base.cpython-314.pyc +0 -0
  60. package/vod_mcp/host_adapters/__pycache__/codearts.cpython-314.pyc +0 -0
  61. package/vod_mcp/host_adapters/__pycache__/codex.cpython-314.pyc +0 -0
  62. package/vod_mcp/host_adapters/__pycache__/dsh.cpython-314.pyc +0 -0
  63. package/vod_mcp/host_adapters/__pycache__/generic.cpython-314.pyc +0 -0
  64. package/vod_mcp/host_adapters/__pycache__/hermes.cpython-314.pyc +0 -0
  65. package/vod_mcp/host_adapters/__pycache__/opencode.cpython-314.pyc +0 -0
  66. package/vod_mcp/host_adapters/base.py +73 -0
  67. package/vod_mcp/host_adapters/codearts.py +57 -0
  68. package/vod_mcp/host_adapters/codex.py +209 -0
  69. package/vod_mcp/host_adapters/dsh.py +176 -0
  70. package/vod_mcp/host_adapters/generic.py +132 -0
  71. package/vod_mcp/host_adapters/hermes.py +76 -0
  72. package/vod_mcp/host_adapters/opencode.py +52 -0
  73. package/vod_mcp/hosts.py +100 -0
  74. package/vod_mcp/packs.py +19 -3
  75. package/vod_mcp/payload.py +174 -0
  76. package/vod_mcp/remote_app.py +100 -0
  77. package/vod_mcp/server.py +43 -16
  78. package/vod_mcp/skills_registry.py +124 -0
  79. package/vod_mcp/tools.py +455 -55
  80. package/vod_mcp/transport_remote.py +289 -0
  81. package/vod_mcp/update_check.py +133 -0
package/bin/vod-devkit CHANGED
@@ -16,8 +16,16 @@ from pathlib import Path
16
16
 
17
17
  ROOT = Path(__file__).resolve().parent.parent
18
18
  sys.path.insert(0, str(ROOT))
19
- HERMES_MCP_DIR = Path.home() / ".hermes" / "mcp" # 约定:写入前打印供确认
20
- HERMES_SKILLS_DIR = Path.home() / ".hermes" / "skills" / "devops" / "vod-devkit"
19
+
20
+ from vod_mcp import hosts as host_specs # noqa: E402 宿主适配层(数据驱动:路径/探测/生成物)
21
+ from vod_mcp.host_adapters import REGISTRY as HOST_ADAPTERS # noqa: E402 宿主安装逻辑(每宿主一模块)
22
+ from vod_mcp.host_adapters import generic as generic_host # noqa: E402
23
+
24
+ # 路径常量一律来自 integrations/<host>/host.json(单一来源):新增宿主=加
25
+ # 目录,不改这里;平台差异也在数据里(opencode 的 windows 分叉)。
26
+ _HERMES_SPEC = host_specs.load("hermes")
27
+ HERMES_MCP_DIR = Path(_HERMES_SPEC["configPath"]).parent # 约定:写入前打印供确认
28
+ HERMES_SKILLS_DIR = Path(_HERMES_SPEC["skillsDir"])
21
29
 
22
30
 
23
31
  def git_sha(strict: bool) -> str | None:
@@ -72,22 +80,7 @@ PRESETS = {
72
80
  }
73
81
 
74
82
 
75
- def _server_entry() -> str:
76
- return str(ROOT / "vod_mcp" / "server.py")
77
-
78
-
79
- def _server_env(args, packs: str) -> dict:
80
- # 无 key 不写空串(空串会让探针/严格解析器误当字面值;运行时空=未设置,
81
- # 自动兜底 runtime.json java_key 或首提申请匿名令牌)
82
- env = {"VOD_PACKS": packs,
83
- "VOD_JAVA_API_BASE": args.java_api_base}
84
- key = os.environ.get("VOD_JAVA_API_KEY", "")
85
- if key:
86
- env["VOD_JAVA_API_KEY"] = key
87
- return env
88
-
89
-
90
- def _skill_installs(manifest_path: Path, oc_skills, cx_skills) -> list:
83
+ def _skill_installs(manifest_path: Path, extra_dirs) -> list:
91
84
  """多宿主技能落点并集(名册对账):manifest 按「最近一次安装」覆盖会
92
85
  互相冲掉落点(实锤:codex 装完 opencode 落点消失),按 host+dir
93
86
  去重保留历史落点。"""
@@ -105,8 +98,7 @@ def _skill_installs(manifest_path: Path, oc_skills, cx_skills) -> list:
105
98
  prev[(si["host"], d)] = si
106
99
  except Exception:
107
100
  pass
108
- for h, d in (("hermes", HERMES_SKILLS_DIR),
109
- ("opencode", oc_skills), ("codex", cx_skills)):
101
+ for h, d in [("hermes", HERMES_SKILLS_DIR)] + list(extra_dirs or []):
110
102
  if d is not None:
111
103
  prev[(h, str(d))] = {"host": h, "dir": str(d)}
112
104
  return sorted(prev.values(), key=lambda x: (x["host"], x["dir"]))
@@ -153,365 +145,78 @@ def _drifted_skills(manifest: dict) -> list:
153
145
  return drifted
154
146
 
155
147
 
156
- def _install_hermes(args, packs: str) -> Path:
157
- """Hermes:官方途径 hermes mcp add(config.yaml mcp_servers)。"""
158
- conf = HERMES_MCP_DIR / "vod-devkit.json"
159
- conf.parent.mkdir(parents=True, exist_ok=True)
160
- conf.write_text(json.dumps({
161
- "name": "vod-devkit", "command": sys.executable,
162
- "args": [_server_entry()], "env": _server_env(args, packs),
163
- }, ensure_ascii=False, indent=2), encoding="utf-8")
164
- env_args = []
165
- for k, v in _server_env(args, packs).items():
166
- env_args.extend([k + "=" + v])
167
- r = subprocess.run(
168
- ["hermes", "mcp", "add", "vod-devkit", "--command", sys.executable,
169
- *["--env"] + env_args, "--args", _server_entry()],
170
- input="y\ny\n", capture_output=True, text=True)
171
- # D-hook-1:强制评估路由插件(pre_llm_call 确定性意图路由,业界 forced-eval 模式)
172
- import shutil as _sh
173
- plug_src = ROOT / "hermes-plugin" / "vod-feedback-router"
174
- plug_dst = Path.home() / ".hermes" / "plugins" / "vod-feedback-router"
175
- if plug_src.is_dir():
176
- if plug_dst.exists():
177
- _sh.rmtree(plug_dst)
178
- _sh.copytree(plug_src, plug_dst)
179
- print("已安装 vod-feedback-router 路由插件(~/.hermes/plugins/);"
180
- "需在 plugins.enabled 加入该名单后生效"
181
- "(hermes config set plugins.enabled ...,重启会话生效)")
182
- if r.returncode == 0:
183
- print("已注册 Hermes MCP(hermes mcp list 可见;重启会话生效)")
184
- else:
185
- print(f"提示:hermes mcp add 未成功({r.stderr.strip()[:150]});"
186
- f"可将 {conf} 内容并入 Hermes 配置")
187
- return conf
188
-
189
-
190
- def _install_opencode(args, packs: str) -> Path:
191
- """OpenCode:~/.config/opencode/opencode.json 的 mcp 段无损合并。
192
-
193
- schema 实测要求:command=数组、enabled 必填;既有内容(provider 等)
194
- 原样保留(读改写,只动 mcp.vod-devkit 键)。
195
- """
196
- import platform
197
- base = Path.home() / (".config/opencode" if platform.system() != "Windows"
198
- else "AppData/Local/opencode")
199
- conf = base / "opencode.json"
200
- conf.parent.mkdir(parents=True, exist_ok=True)
201
- cfg = {}
202
- if conf.exists():
203
- try:
204
- cfg = json.loads(conf.read_text(encoding="utf-8"))
205
- except Exception:
206
- cfg = {}
207
- cfg.setdefault("mcp", {})["vod-devkit"] = {
208
- "type": "local",
209
- "command": [sys.executable, _server_entry()],
210
- "enabled": True,
211
- "environment": _server_env(args, packs),
212
- }
213
- conf.write_text(json.dumps(cfg, ensure_ascii=False, indent=2), encoding="utf-8")
214
- print(f"已写入 OpenCode 配置:{conf}(重启 OpenCode 会话生效)")
215
- cmd_dir = base / "command"
216
- cmd_dir.mkdir(parents=True, exist_ok=True)
217
- (cmd_dir / "vod-doctor.md").write_text(
218
- "---\n"
219
- "description: 自检 VOD DevKit 就绪状态(MCP 连通/版本/key/账本)。\n"
220
- "---\n\n"
221
- "使用 vod-devkit 工具做就绪自检,按序执行并汇总 OK/缺失:\n"
222
- "1. 调用 vod_devkit_info:确认 version 与 commitSha 非空(版本/来源溯源)。\n"
223
- "2. 调用 vod_auth_status:报告 key 配置态与引擎连通性;无 key 属正常(首次提交自动取匿名令牌)。\n"
224
- "3. 调用 vod_list_submitted(limit 5):报告本机已提交反馈数(本地账本口径)。\n"
225
- "4. 汇总:installed(OK)vs 缺失(需处理项)。不要打印任何 key/令牌明文。\n"
226
- "若 MCP 工具不可用(刚装完未重启),提示用户重启 OpenCode 会话。\n",
227
- encoding="utf-8")
228
- print(f"已写入 OpenCode 自检命令:/vod-doctor({cmd_dir / 'vod-doctor.md'})")
229
- return conf
230
-
231
-
232
- def _strip_codex_vod_blocks(text: str) -> str:
233
- """幂等剥离:按行删除 [mcp_servers.vod-devkit] 及 .env 子表整块。
234
-
235
- 不能用行内正则截断式剥离——args = ["…"] 行内的 '[' 会让正则提前断块,
236
- 旧 env 子表残留(实测:二次安装后 env 表×2、旧 VOD_PACKS 滞留,
237
- 换 preset 不生效)。按行扫描到下一个 '[' 开头的节头为止才是整块。
238
- """
239
- out, skipping = [], False
240
- for line in text.splitlines():
241
- s = line.strip()
242
- # P2(深审 2026-11-06):精确匹配表头——startswith("…vod-devkit")
243
- # 会误删 [mcp_servers.vod-devkit2] 等无关表
244
- if s == "[mcp_servers.vod-devkit]":
245
- skipping = True
246
- continue
247
- if skipping and s.startswith("["):
248
- skipping = False
249
- if not skipping:
250
- out.append(line)
251
- return "\n".join(out).rstrip()
252
-
253
-
254
148
  _AGENTS_MARKER_BEGIN = "<!-- vod-devkit:feedback-skill BEGIN -->"
255
149
  _AGENTS_MARKER_END = "<!-- vod-devkit:feedback-skill END -->"
256
150
 
257
151
 
258
- def _strip_agents_vod_block(text: str) -> str:
259
- """幂等剥离 AGENTS.md 中带标记的 vod-devkit 技能块(历史方案清理)。
152
+ def _expected_remote_tools() -> set:
153
+ """远程面应当暴露的工具集 = 契约全集 - REMOTE_WITHHELD(写面本机工具不进远程)。"""
154
+ from vod_mcp import packs as _packs
155
+ contract = json.loads((ROOT / "contract" / "tools.schema.json").read_text(encoding="utf-8"))
156
+ return set(contract["tools"]) - set(_packs.REMOTE_WITHHELD)
260
157
 
261
- P2(深审 2026-11-06):只有 BEGIN 没有 END 时不得静默吞掉文件剩余
262
- 全部内容——抛错拒绝(调用方 exit 2 不落盘),宁可装不上不可删用户文件。
263
- """
264
- lines, skipping, out = text.splitlines(), False, []
265
- for line in lines:
266
- if line.strip() == _AGENTS_MARKER_BEGIN:
267
- skipping = True
268
- continue
269
- if line.strip() == _AGENTS_MARKER_END:
270
- skipping = False
271
- continue
272
- if not skipping:
273
- out.append(line)
274
- if skipping:
275
- raise RuntimeError(
276
- "AGENTS.md 存在 vod-devkit BEGIN 标记但缺失 END 标记"
277
- "(文件可能被手动截断)——拒绝自动清理,请手动检查该文件")
278
- return "\n".join(out).rstrip()
279
-
280
-
281
- def _install_codex(args, packs: str) -> Path:
282
- """Codex(D-codex-agents-1 终态):原生插件路径——
283
- codex plugin marketplace add <仓>/plugins + plugin add vod-devkit@vod-local,
284
- 打包 skills(渐进式按需加载的采集工作流)+ .mcp.json(vod-devkit serve)。
285
- 历史遗留清理:旧 config.toml [mcp_servers.vod-devkit] 段与 AGENTS.md 技能块
286
- 一并移除(与原生插件同名会双注册;AGENTS.md 方案被原生 skill 取代)。
287
- 前置:codex CLI 与 vod-devkit 命令在 PATH(npm i -g vod-devkit ≥0.1.12)。"""
288
- codex = shutil.which("codex")
289
- if not codex:
290
- print("[vod-devkit] 未找到 codex CLI,无法走原生插件安装", file=sys.stderr)
291
- sys.exit(2)
292
- conf = Path.home() / ".codex" / "config.toml"
293
- if conf.exists(): # 历史遗留:config.toml MCP 段与插件同名=双注册,移除
294
- text = conf.read_text(encoding="utf-8")
295
- cleaned = _strip_codex_vod_blocks(text)
296
- if cleaned != text.rstrip():
297
- conf.write_text(cleaned + "\n", encoding="utf-8")
298
- print(f"已移除旧 config.toml MCP 段(原生插件取代):{conf}")
299
- agents = Path.home() / ".codex" / "AGENTS.md"
300
- if agents.exists(): # 历史遗留:AGENTS.md 技能块已被原生 skill 取代
301
- text = agents.read_text(encoding="utf-8")
302
- try:
303
- cleaned = _strip_agents_vod_block(text)
304
- except RuntimeError as e:
305
- print(f"[vod-devkit] {e}", file=sys.stderr)
306
- sys.exit(2)
307
- if cleaned != text.rstrip():
308
- agents.write_text(cleaned + "\n", encoding="utf-8")
309
- print(f"已移除旧 AGENTS.md 技能块(原生 skill 取代):{agents}")
310
- mp_root = ROOT / "plugins"
311
-
312
- def _run(cmd):
313
- r = subprocess.run(cmd, capture_output=True, text=True, timeout=120)
314
- if r.returncode != 0:
315
- raise RuntimeError(f"{' '.join(cmd)} → {r.stderr.strip() or r.stdout.strip()}")
316
- return r.stdout
317
-
318
- mp_name = "vod-local"
319
- # devkit 卫生实践:stale cache 先清——codex 插件缓存不自动失效,不清则
320
- # 重装/升级后旧版本残留(marketplace 指向与 cache 内容漂移)
321
- for stale in (Path.home() / ".codex" / "plugins" / "marketplaces" / mp_name,
322
- Path.home() / ".codex" / "plugins" / "cache" / mp_name):
323
- if stale.exists():
324
- shutil.rmtree(stale)
325
- print(f"已清理 stale 插件缓存:{stale}")
326
- ml = subprocess.run([codex, "plugin", "marketplace", "list"], capture_output=True, text=True, timeout=120).stdout
327
- if mp_name not in ml:
328
- _run([codex, "plugin", "marketplace", "add", str(mp_root)])
329
- print(f"已注册本地 marketplace:{mp_root}")
330
- _run([codex, "plugin", "add", f"vod-devkit@{mp_name}"])
331
- print("已安装 codex 原生插件 vod-devkit(skills + MCP,重启 Codex 会话生效)")
332
- # P1-5(深审 2026-11-06):插件自带的 .mcp.json 硬编码 env.VOD_PACKS=
333
- # core,collect——--packs 对 codex 半失效(运行期仍注册 collect 工具)。
334
- # plugin add 后把缓存内 .mcp.json 的 packs 对齐本次安装值。
335
- import glob as _glob
336
- mcp_jsons = sorted(
337
- _glob.glob(str(Path.home() / ".codex" / "plugins" / "cache"
338
- / mp_name / "vod-devkit" / "*" / ".mcp.json")),
339
- key=lambda p: Path(p).stat().st_mtime, reverse=True)
340
- if mcp_jsons:
341
- try:
342
- mj = json.loads(Path(mcp_jsons[0]).read_text(encoding="utf-8"))
343
- srv = mj.get("mcpServers", {}).get("vod-devkit")
344
- if srv is not None:
345
- srv.setdefault("env", {})["VOD_PACKS"] = packs
346
- Path(mcp_jsons[0]).write_text(
347
- json.dumps(mj, ensure_ascii=False, indent=2) + "\n",
348
- encoding="utf-8")
349
- print(f"已对齐插件 MCP packs:{mcp_jsons[0]}(VOD_PACKS={packs})")
350
- except Exception as e:
351
- print(f"[vod-devkit] warn: 插件 .mcp.json packs 对齐失败({e})——"
352
- "运行期熔断门禁仍会兜底", file=sys.stderr)
353
- return Path(mcp_jsons[0])
354
- # 深审 P0-3:绝不再返回 ~/.codex/config.toml——它是用户整份 codex 配置,
355
- # uninstall 对 mcpConfig 是删除语义,指向它=卸载删光用户配置(破坏性)
356
- print("[vod-devkit] warn: 未定位到插件 .mcp.json(uninstall 将跳过 MCP 清理,"
357
- "可手动删除插件缓存目录)", file=sys.stderr)
358
- return None
359
-
360
-
361
- def _install_dsh(args, packs: str) -> Path:
362
- """dsh 工具壳(D-dsh-install-1,2026-11-06 用户拍板 A):三壳口径统一——
363
- --product 安装期硬校验(cmd_install 已先行,到达此处必已过)+ 校验先于
364
- add + 幂等写 profile cordis.patch.yml config override。
365
- 生效通道真机实测(2026-11-06,dsh 0.2.1-rc.5):profile cordis.patch.yml
366
- 的 id-targeted config override 是工具壳读取 product/apiBase/uiBase/
367
- confirmWrites 的唯一运行时通道(启动 banner + 桩引擎提交链实证)。
368
- uiBase(D-uiBase-direct):浏览器半(反馈按钮)直连引擎——apiBase 是
369
- server 半(Node)自用,浏览器同源策略下用不上;缺 uiBase 时 UI 提交
370
- 发往 dsh 同源(404→本地暂存),嵌入方真机实锤。dsh plugin add 会自建
371
- profile,无需前置。"""
372
- dsh = shutil.which("dsh")
373
- profile = (getattr(args, "dsh_profile", "") or "").strip()
374
- if not profile:
375
- # argparse 进入安装前校验(cmd_install 已兜底,直调防御)
376
- print("[vod-devkit] --profile 必填:dsh 按 profile 组织插件与配置"
377
- "(--profile <name>)", file=sys.stderr)
378
- sys.exit(2)
379
- if not dsh:
380
- print("[vod-devkit] 未找到 dsh CLI(PATH),拒绝安装(宁可不装不可装错)。"
381
- "前置:npm i -g @deepseek-ai/dsh(需 pnpm)", file=sys.stderr)
382
- sys.exit(2)
383
- r = subprocess.run([dsh, "plugin", "--profile", profile,
384
- "add", "dsh-vod-devkit"],
385
- capture_output=True, text=True, timeout=300)
386
- if r.returncode != 0:
387
- print(f"[vod-devkit] dsh plugin add 失败:{(r.stderr or r.stdout).strip()[-300:]}",
388
- file=sys.stderr)
389
- sys.exit(1)
390
- print(f"已安装 dsh 插件 dsh-vod-devkit(profile={profile},dsh plugin list 可见)")
391
-
392
- patch = Path.home() / ".dsh" / "profiles" / profile / "cordis.patch.yml"
393
- # name 行必须保留:cordis.patch.yml 的 insert 块靠 name 绑定 client 半
394
- # (反馈按钮)——只写 id+config 会在重装幂等替换时把 name 吞掉,UI 静默
395
- # 失激活(2026-11-06 真机实锤:重装后入口消失)
396
- # 嵌套铁律(2026-11-10 真机实锤):块必须缩进在 `- insert:` 之下——平铺
397
- # 形态被 dsh 组合层丢弃,插件掉出组合树(banner/工具/UI 全消失)。
398
- block = ("- insert:\n"
399
- " - id: vod-devkit\n"
400
- " name: dsh-vod-devkit\n"
401
- " config:\n"
402
- f" product: {args.product}\n"
403
- f" apiBase: {args.java_api_base}\n"
404
- f" uiBase: {args.java_api_base}\n" # D-uiBase-direct:浏览器半直连引擎
405
- " # headless 无审批通道:原生 ask 门禁会永久阻断写工具(四宿主实测实锤:\n"
406
- " # requires approval, but no approval channel)。同意确认由 SKILL 话术层\n"
407
- " # 承担(draft→用户确认→commit / 明确指令直发),web 端如需硬门禁按\n"
408
- " # profile 覆盖回 true。\n"
409
- " confirmWrites: false\n")
410
- try:
411
- written = _upsert_dsh_patch(patch, block)
412
- except Exception as e:
413
- # 回滚/修复指引:插件已装但配置未写 = 半成品,给明确的手动修复格式
414
- print(f"[vod-devkit] 插件已装入 profile={profile},但配置写入失败"
415
- f"({e.__class__.__name__})。请手动把下段并入 {patch}"
416
- f"(顶层 YAML 数组元素,已有 - id: vod-devkit 段则原位替换):\n"
417
- f"{block}", file=sys.stderr)
418
- sys.exit(1)
419
- if written:
420
- print(f"已写入归因/引擎配置(幂等 upsert):{patch}")
421
- else:
422
- print(f"配置未变化(幂等跳过):{patch}")
423
- return patch
424
-
425
-
426
- def _find_dsh_block(lines):
427
- """定位 cordis.patch.yml 中 vod-devkit 块的 (start, end);不存在返回
428
- (None, None)。块边界=下一顶层元素行(`- ` 开头)或 EOF。
429
- 嵌套铁律(真机实锤,2026-11-10 复现):dsh 只认缩进在 `- insert:` 下
430
- 的块——平铺 `- id:` 会被组合层丢弃=插件整个掉出组合树(banner/工具/
431
- UI 全消失)。当命中行是嵌套形态(带缩进)时,start 向上归并到其
432
- `- insert:` 组头,整组替换;平铺旧形态(历史安装器写的)按原语义
433
- 顶格替换。install 的幂等 upsert 与 uninstall 的摘除共用本边界语义
434
- (单一实现,防两处扫描规则漂移——双载体漂移已在本仓 dsh/UI 壳实锤过)。"""
435
- for i, ln in enumerate(lines):
436
- if ln.strip().startswith("- id: vod-devkit"):
437
- start = i
438
- if ln[:1] == " ": # 嵌套形态:向上归并组头(- insert: 或其它顶层 -)
439
- for k in range(i - 1, -1, -1):
440
- if lines[k].startswith("- "):
441
- start = k
442
- break
443
- end = len(lines)
444
- for j in range(start + 1, len(lines)):
445
- if lines[j].startswith("- "): # 下一顶层元素:本块结束
446
- end = j
447
- break
448
- return start, end
449
- return None, None
450
-
451
-
452
- def _upsert_dsh_patch(patch: Path, block: str) -> bool:
453
- """幂等写 profile cordis.patch.yml:已存在 `- id: vod-devkit` 段则原位整块
454
- 替换(不重复插入);无则追加。按行扫描块边界(下一行 `- ` 顶层元素或 EOF),
455
- 不引 YAML 依赖(本仓零第三方依赖红线)。返回是否有写入。"""
456
- lines = patch.read_text(encoding="utf-8").splitlines() if patch.exists() else []
457
- start, end = _find_dsh_block(lines)
458
- if start is None:
459
- # 空数组占位清除(四宿主实测实锤:dsh plugin add 自建的模板含字面量
460
- # `[]` 顶层行,直接追加块 = `[]` 后跟 `- id:` 顶层元素 = 非法 YAML,
461
- # 整个 profile 启动崩溃)。`[]` 语义=空数组,被块 entries 取代即删。
462
- lines = [ln for ln in lines if ln.strip() != "[]"]
463
- new = lines + ([""] if lines and lines[-1].strip() else []) + block.splitlines()
464
- else:
465
- new = lines[:start] + block.splitlines() + lines[end:]
466
- new_text = "\n".join(new).rstrip("\n") + "\n"
467
- # 空 `- insert:` 组头清理(损坏态自愈):孤儿组头(下一个顶层元素前无
468
- # 子项)来自历史平铺替换的残留——留它在 dsh 组合层是空组,可能拖垮
469
- # 整个 patch 解析。upsert 后顺手摘除(幂等,不碰正常组)。
470
- cleaned = []
471
- for idx, ln in enumerate(new):
472
- if ln.strip() == "- insert:":
473
- nxt = new[idx + 1] if idx + 1 < len(new) else ""
474
- if nxt.startswith("- ") or (not nxt.strip() and idx + 2 >= len(new)):
475
- continue # 孤儿组头:下一行已是新顶层元素(无子项)→ 摘除
476
- cleaned.append(ln)
477
- new_text = "\n".join(cleaned).rstrip("\n") + "\n"
478
- old_text = patch.read_text(encoding="utf-8") if patch.exists() else ""
479
- if new_text == old_text:
480
- return False
481
- patch.parent.mkdir(parents=True, exist_ok=True)
482
- patch.write_text(new_text, encoding="utf-8")
483
- return True
484
158
 
159
+ def _probe_remote(url: str, token: str, timeout: int = 15) -> list:
160
+ """远程 MCP 端点探活:initialize + tools/list,返回工具名清单(失败抛 RuntimeError)。
485
161
 
486
- def _remove_dsh_patch_block(patch: Path) -> bool:
487
- """从 cordis.patch.yml 摘除 vod-devkit 块(uninstall 用)。返回是否摘除。"""
488
- if not patch.exists():
489
- return False
490
- lines = patch.read_text(encoding="utf-8").splitlines()
491
- start, end = _find_dsh_block(lines)
492
- if start is None:
162
+ 走 stdlib urllib(安装器零第三方依赖红线);Accept 双类型,兼容 SSE 单事件响应。
163
+ 探活在**写入任何配置之前**执行——装不上就不留半成品。
164
+ """
165
+ import urllib.request
166
+
167
+ def _post(payload: dict) -> dict:
168
+ req = urllib.request.Request(
169
+ url, data=json.dumps(payload).encode(), method="POST",
170
+ headers={"content-type": "application/json",
171
+ "accept": "application/json, text/event-stream",
172
+ **({"Authorization": f"Bearer {token}"} if token else {})})
173
+ with urllib.request.urlopen(req, timeout=timeout) as resp:
174
+ body = resp.read().decode("utf-8", "replace")
175
+ if body.startswith("event:") or body.startswith("data:"):
176
+ for line in body.splitlines():
177
+ if line.startswith("data:"):
178
+ body = line[5:].strip()
179
+ break
180
+ data = json.loads(body or "{}")
181
+ if isinstance(data, dict) and data.get("error"):
182
+ raise RuntimeError(f"JSON-RPC 错误:{data['error']}")
183
+ return data
184
+
185
+ _post({"jsonrpc": "2.0", "id": 1, "method": "initialize",
186
+ "params": {"protocolVersion": "2025-06-18",
187
+ "clientInfo": {"name": "vod-devkit-installer", "version": "1"},
188
+ "capabilities": {}}})
189
+ listed = _post({"jsonrpc": "2.0", "id": 2, "method": "tools/list"})
190
+ names = [t.get("name") for t in (listed.get("result") or {}).get("tools") or []]
191
+ if not names:
192
+ raise RuntimeError("tools/list 返回空——端点可能不是 Streamable HTTP MCP")
193
+ return names
194
+
195
+
196
+ def _remote_reachable(url: str, timeout: int = 6) -> bool:
197
+ """端点是否可达:GET 得到任何 HTTP 响应(405 是远程面契约的正常应答)即算通。"""
198
+ import urllib.error
199
+ import urllib.request
200
+ try:
201
+ with urllib.request.urlopen(url, timeout=timeout):
202
+ return True
203
+ except urllib.error.HTTPError:
204
+ return True # 405/401/406 都证明端点活着
205
+ except Exception:
493
206
  return False
494
- patch.write_text(
495
- "\n".join(lines[:start] + lines[end:]).rstrip("\n") + "\n",
496
- encoding="utf-8")
497
- return True
498
207
 
499
208
 
500
- _INSTALLERS = {"hermes": _install_hermes, "opencode": _install_opencode,
501
- "codex": _install_codex, "dsh": _install_dsh}
502
209
 
503
210
 
504
211
  def detect_targets() -> list:
505
- """0/1/N 探测:按各家配置目录存在性判断已装宿主。"""
212
+ """0/1/N 探测:按 host.json 的 detect 段判断宿主是否在场(CLI 或配置目录)。"""
506
213
  found = []
507
- if shutil.which("hermes"):
508
- found.append("hermes")
509
- if (Path.home() / ".config/opencode").exists():
510
- found.append("opencode")
511
- if (Path.home() / ".codex").exists():
512
- found.append("codex")
513
- if shutil.which("dsh"):
514
- found.append("dsh")
214
+ for host in host_specs.hosts():
215
+ spec = host_specs.raw(host) # 探测不解析路径(dsh 的 {profile} 占位符必填)
216
+ if spec.get("detectCLI") and shutil.which(spec["detectCLI"]):
217
+ found.append(host)
218
+ elif spec.get("detectPath") and Path(spec["detectPath"]).exists():
219
+ found.append(host)
515
220
  return found
516
221
 
517
222
 
@@ -596,19 +301,36 @@ def cmd_install(args):
596
301
  target = args.target
597
302
  if target == "auto":
598
303
  found = detect_targets()
304
+ generic_found = generic_host.detect_known()
599
305
  if len(found) == 1:
600
306
  target = found[0]
307
+ elif not found and len(generic_found) == 1:
308
+ # A 层兜底:没有专属模块但有已知通用 MCP 宿主 → 走通用写入
309
+ #(探到唯一一个才自动写,多个/零个都要人选定,不许猜)
310
+ target = "generic"
311
+ if not getattr(args, "mcp_config", ""):
312
+ args.mcp_config = str(generic_host._expand(generic_found[0]["config"]))
313
+ print(f"探测到通用 MCP 宿主: {generic_found[0]['label']} → 通用写入 "
314
+ f"({args.mcp_config})")
601
315
  elif not found:
602
- print("未探测到任何宿主;用 --target hermes|opencode|codex 显式指定",
603
- file=sys.stderr)
316
+ known = "、".join(h["label"] + "(" + h["config"] + ")" for h in generic_found)
317
+ print("未探测到可自动安装的宿主;用 --target hermes|opencode|codeartsdoer|codex|dsh 显式指定"
318
+ + (f",或通用写入:--target generic --mcp-config <配置>(探测到 {known})"
319
+ if generic_found else ""), file=sys.stderr)
604
320
  sys.exit(2)
605
321
  else:
606
- print(f"探测到多个宿主: {found};请 --target 显式指定其一", file=sys.stderr)
322
+ print(f"探测到多个宿主: {found + [h['id'] for h in generic_found]};"
323
+ "请 --target 显式指定其一", file=sys.stderr)
607
324
  sys.exit(2)
608
325
  print(f"探测到宿主: {target}")
609
- installer = _INSTALLERS.get(target)
610
- if installer is None:
611
- print(f"不支持目标: {target}(可选 hermes|opencode|codex|auto)", file=sys.stderr)
326
+ adapter = HOST_ADAPTERS.get(target)
327
+ if adapter is None:
328
+ g = [(h["id"], h["config"]) for h in generic_host.detect_known()]
329
+ hint = ("\n 探测到通用 MCP 宿主:" + ";".join(f"{i}({c})" for i, c in g)
330
+ if g else "")
331
+ print(f"不支持目标: {target}(可选 hermes|opencode|codeartsdoer|codex|dsh|generic|auto){hint}\n"
332
+ " 通用宿主:install --target generic --mcp-config <配置文件>",
333
+ file=sys.stderr)
612
334
  sys.exit(2)
613
335
  packs = args.packs or PRESETS.get(args.preset, "")
614
336
  # 恢复门禁(D-codex-circuit-breaker-1,2026-11-06 负责人确认):
@@ -629,19 +351,10 @@ def cmd_install(args):
629
351
  "(draft→commit 审计链/重复 commit 被拒/未确认可检测)。",
630
352
  file=sys.stderr)
631
353
  sys.exit(2)
632
- # 归因绑定(T7d 统一:安装必配,与 dsh UI 加载必配同口径):--product 必填——
633
- # 缺省宿主名在生态部署是错归陷阱(高校AI开发者平台 agent 底座=hermes,
634
- # 不填则反馈全归 hermes)。宿主名仍是合法值(自反馈场景显式传
635
- # --product hermes),但必须显式选择,不做静默默认(归因错误比没数据更糟)。
636
- if not args.product:
637
- print(
638
- "[vod-devkit] --product 必填:产品归因是安装必配项(与 UI 嵌入注入同口径)。\n"
639
- " 取值=生态看板产品名(可用 GET /external/products 查询权威名单),如:\n"
640
- " --product \"高校AI开发者平台\" / --product \"GTD\" / --product \"Skills门户\"\n"
641
- " 取值必须在产品名录内(安装期硬校验,D-product-id-2);完整名单:\n"
642
- " GET /external/products",
643
- file=sys.stderr)
644
- sys.exit(2)
354
+ # 归因绑定降级(D-attrib-B,2026-11-11 负责人拍板 P1-P4 全 A):--product
355
+ # 由必填改为**可选先验**——归因主路径改成运行期从用户原话解析(证据唯一
356
+ # 命中才采信),安装绑定只在「无字面证据且无记忆」时兜底。保留「给了就
357
+ # 必须对」:显式提供时仍做名录硬校验(拼错照样 exit 2),不给不拦装。
645
358
  # D-dsh-install-1:--profile 必填在进入任何安装动作前校验(先校验后写入)
646
359
  if target == "dsh" and not (args.dsh_profile or "").strip():
647
360
  print("[vod-devkit] --profile 必填:dsh 按 profile 组织插件与配置。\n"
@@ -656,7 +369,8 @@ def cmd_install(args):
656
369
  # 目录不可达(离线/引擎异常)同样拒绝——宁可不装不可装错(postinstall 拒绝
657
370
  # 猜测同源纪律)。插件提交链的 name 兼容通道不受影响(那是老版本插件兼容,
658
371
  # 不是安装期放行理由)。
659
- _validate_product_or_exit(args.product, args.java_api_base)
372
+ if args.product: # 可选先验:给了就校验,不给不拦装(D-attrib-B)
373
+ _validate_product_or_exit(args.product, args.java_api_base)
660
374
  # D-key-guard-2 红线:preset(产品分发)形态下 key 禁止随包——环境变量里的
661
375
  # key 不透传给宿主配置(客户机一律走匿名令牌自领),并当场告警
662
376
  distribution = args.distribution
@@ -676,10 +390,58 @@ def cmd_install(args):
676
390
  cfg["local_ledger"] = False
677
391
  # base 同步落 runtime.json:宿主 env 透传不稳是实测坑,透传挂了静默落回
678
392
  # 127.0.0.1:8090;文件兑底与 env 同值不构成双真源(优先级链 env>文件)
393
+ # 宿主产品(host_default 兜底用,D-product-ask-1):只有 integrations 声明了才写
394
+ spec_raw = host_specs.raw(target) if target in host_specs.hosts() else {}
395
+ if spec_raw.get("productDefault"):
396
+ cfg["host_product"] = spec_raw["productDefault"]
679
397
  cfg["java_base"] = args.java_api_base
680
398
  rt.write_text(json.dumps(cfg, ensure_ascii=False, indent=2), encoding="utf-8")
681
399
 
682
- mcp_conf = installer(args, packs)
400
+ # ── 远程 attach / skills-only(D-attach-1)───────────────────────────
401
+ # 形态:MCP 单独部署一个远程端点,宿主只把 MCP 配置指向它(+ 本地技能)。
402
+ # 约束:远程面无匿名链(缺 key fail fast)→ token 必填;探活先于写入,
403
+ # 失败零副作用。dsh 壳不走 MCP,这两种模式对 dsh 无意义(显式拒绝)。
404
+ remote_url = (getattr(args, "mcp_url", "") or "").strip()
405
+ skills_only = bool(getattr(args, "skills_only", False))
406
+ if remote_url or skills_only:
407
+ if not getattr(adapter, "SUPPORTS_REMOTE", False):
408
+ what = "dsh 壳不走 MCP" if target == "dsh" else f"{target} 不走 MCP"
409
+ print(f"[vod-devkit] {what},不支持 --mcp-url / --skills-only\n"
410
+ f" {target} 请用本地形态:install --target {target} "
411
+ + ("--profile <name>" if target == "dsh" else ""),
412
+ file=sys.stderr)
413
+ sys.exit(2)
414
+ token = (getattr(args, "mcp_token", "") or os.environ.get("VOD_MCP_TOKEN") or "").strip()
415
+ if remote_url:
416
+ if not token:
417
+ print("[vod-devkit] 远程 attach 必须提供 --mcp-token 或 env VOD_MCP_TOKEN:\n"
418
+ " 远程面不代签匿名令牌(身份只从请求头来),无 token 装上也提交不了",
419
+ file=sys.stderr)
420
+ sys.exit(2)
421
+ try:
422
+ names = _probe_remote(remote_url, token)
423
+ except Exception as e: # noqa: BLE001
424
+ print(f"[vod-devkit] 远程 MCP 探活失败(未写入任何配置):{e}", file=sys.stderr)
425
+ sys.exit(2)
426
+ expected = _expected_remote_tools()
427
+ missing = expected - set(names)
428
+ if missing:
429
+ print(f"[vod-devkit] 远程面工具面不符:缺 {sorted(missing)}\n"
430
+ f" 实际 = {sorted(names)}\n"
431
+ " 该端点可能不是 vod-devkit 远程面,或版本/角色不匹配;拒绝安装",
432
+ file=sys.stderr)
433
+ sys.exit(2)
434
+ print(f"远程面探活通过:{len(names)} 个工具({', '.join(sorted(names))})")
435
+ mcp_conf = None if skills_only else adapter.install_remote(args, remote_url, token)
436
+ extra_dirs = _install_skills(target, packs, args,
437
+ (getattr(args, "dsh_profile", "") or "").strip() or None)
438
+ _write_install_manifest(args, target, packs, bound_product, mcp_conf, extra_dirs,
439
+ transport=("skills-only" if skills_only else "remote"),
440
+ mcp_url=remote_url)
441
+ return
442
+
443
+ payload_dir = _stage_payload() # 载荷固化:入口指向这份副本,不再指向 npx 缓存
444
+ mcp_conf = adapter.install(args, packs)
683
445
 
684
446
  # P1-4 修正:ack 解除后置——安装全部成功才落(解除先于安装=失败安装
685
447
  # 也绕过了恢复门禁语义)
@@ -694,33 +456,59 @@ def cmd_install(args):
694
456
  print(f"[vod-devkit] 已显式解除 codex 采集熔断(安装成功),审计已记录:{audit}")
695
457
 
696
458
  # G1 修复:技能全量拷贝(目录型技能+平铺规则文档),按 packs 过滤
697
- oc_skills, cx_skills = _install_skills(target, packs)
459
+ extra_dirs = _install_skills(target, packs, args,
460
+ (getattr(args, "dsh_profile", "") or "").strip() or None)
698
461
 
699
462
  _write_install_manifest(args, target, packs, bound_product, mcp_conf,
700
- oc_skills, cx_skills)
463
+ extra_dirs, payload_dir=payload_dir)
464
+
701
465
 
466
+ def _stage_payload():
467
+ """把 server/contract/safety/skills 拷进 ~/.vod-devkit/payloads/<ver>/ 并指过去。
702
468
 
703
- def _install_skills(target: str, packs: str):
704
- """技能段:全量拷贝(目录型技能+平铺规则文档),按 packs 过滤,落
705
- hermes 主目录 + opencode/codex 原生目录。返回 (oc_skills, cx_skills)
706
- 落点(供 manifest 名册对账)。"""
469
+ 对标 devkit 的 copyServerPayload(D-payload-1):npx 安装时仓在
470
+ ~/.npm/_npx/<hash>/,npm 清缓存/换版本后入口指向已删除路径 → 宿主 MCP 静默掉线。
471
+ """
472
+ from vod_mcp import payload as _payload
473
+ from vod_mcp.host_adapters import base as _base
474
+ dest = _payload.stage()
475
+ # 把安装期运行配置种进载荷(载荷 runtime 与仓内 runtime 是两份文件):
476
+ # 否则 host_product/product/java_base 只写在仓内,真正跑起来的副本看不到
477
+ seeded = {k: v for k, v in _runtime_cfg_read().items()
478
+ if k in ("product", "host_product", "java_base", "local_ledger")}
479
+ if seeded:
480
+ rt = dest / "vod_mcp" / "runtime.json"
481
+ cur = {}
482
+ if rt.exists():
483
+ try:
484
+ cur = json.loads(rt.read_text(encoding="utf-8"))
485
+ except Exception:
486
+ cur = {}
487
+ cur.update(seeded)
488
+ rt.write_text(json.dumps(cur, ensure_ascii=False, indent=2), encoding="utf-8")
489
+ _base.set_payload_dir(dest)
490
+ return dest
491
+
492
+
493
+ def _install_skills(target: str, packs: str, args, profile: str | None = None):
494
+ """技能段:按 packs 过滤后拷到 hermes 主目录 + 目标宿主的技能发现目录。
495
+
496
+ 目标宿主列表由 integrations/<host>/host.json 的 skillsDir 决定——2026-11-11
497
+ 实锤:dsh 此前不在拷贝分支里,npx 装 dsh 只拿到工具、拿不到任何技能文
498
+ 件(同意前置/逐字回显/追问判定这些话术纪律整层缺失),而 ~/.dsh/skills
499
+ 下的副本是 /opt/vod-install 脚本手工刷的,不是安装器产物。
500
+ 返回 [(host, Path)] 落点清单(供 manifest 名册对账)。"""
707
501
  HERMES_SKILLS_DIR.mkdir(parents=True, exist_ok=True)
708
502
  # opencode 原生技能目录(2026-11-06 实测:opencode 自动发现
709
503
  # ~/.config/opencode/skills/ 并经 skill 工具按需加载——此前安装器漏拷,
710
504
  # opencode 只有工具描述一条约束通道,话术类约束全部失效)
711
- oc_skills = None
712
- cx_skills = None
713
- if target == "opencode":
714
- import platform as _pf
715
- oc_base = Path.home() / (".config/opencode" if _pf.system() != "Windows"
716
- else "AppData/Local/opencode")
717
- oc_skills = oc_base / "skills"
718
- oc_skills.mkdir(parents=True, exist_ok=True)
719
- elif target == "codex":
720
- cx_skills = Path.home() / ".codex" / "skills"
721
- cx_skills.mkdir(parents=True, exist_ok=True)
505
+ extra_dirs = [] # [(host, Path)]
506
+ adapter = HOST_ADAPTERS.get(target)
507
+ dst = adapter.skills_dir(args) if adapter and target != "hermes" else None
508
+ if dst is not None:
509
+ dst.mkdir(parents=True, exist_ok=True)
510
+ extra_dirs.append((target, dst))
722
511
  pack_set = set(p for p in packs.split(",") if p)
723
- extra_skill_dirs = [d for d in (oc_skills, cx_skills) if d is not None]
724
512
  for entry in sorted((ROOT / "skills").iterdir()):
725
513
  if entry.is_dir(): # vod-core / vod-feedback-collect
726
514
  skill = entry.name
@@ -732,17 +520,39 @@ def _install_skills(target: str, packs: str):
732
520
  if dst.exists():
733
521
  shutil.rmtree(dst)
734
522
  shutil.copytree(entry, dst)
735
- for oc_dst in extra_skill_dirs:
523
+ for _host, oc_dst in extra_dirs:
736
524
  dst2 = oc_dst / skill
737
525
  if dst2.exists():
738
526
  shutil.rmtree(dst2)
739
527
  shutil.copytree(entry, dst2)
740
- # vendored 领域规则已由 vendor_rules.py 落成技能目录结构
741
- return oc_skills, cx_skills
528
+ # 领域规则技能为静态副本,与引擎真源的对账见 scripts/rules_provenance.py
529
+ return extra_dirs
530
+
531
+
532
+ def _read_manifest() -> dict:
533
+ p = manifest_path()
534
+ if not p.exists():
535
+ return {}
536
+ try:
537
+ return json.loads(p.read_text(encoding="utf-8"))
538
+ except Exception:
539
+ return {}
540
+
541
+
542
+ def _install_rows(prev: dict, row: dict) -> list:
543
+ """按 target 去重的安装行(D-installs-1):一个 manifest 记全部宿主安装。
544
+
545
+ 起因(结构债):顶电平字段只记「最近一次安装」,装 hermes 再装 codearts 后
546
+ uninstall 只清最后一个宿主的 MCP 条目,另一台宿主的配置永远留在那。
547
+ """
548
+ rows = [r for r in (prev.get("installs") or []) if r.get("target") != row["target"]]
549
+ rows.append(row)
550
+ return sorted(rows, key=lambda r: r.get("installedAt") or "")
742
551
 
743
552
 
744
553
  def _write_install_manifest(args, target, packs, bound_product, mcp_conf,
745
- oc_skills, cx_skills) -> None:
554
+ extra_dirs, transport: str = "stdio",
555
+ mcp_url: str = "", payload_dir=None) -> None:
746
556
  """manifest 段:落安装名册(版本/来源/归因/落点指纹),并给出 key
747
557
  配置提示。名册对账口径见各字段注释(原 cmd_install 尾段,整段平移)。"""
748
558
  bi = json.loads((ROOT / "build-info.json").read_text(encoding="utf-8"))
@@ -753,6 +563,10 @@ def _write_install_manifest(args, target, packs, bound_product, mcp_conf,
753
563
  cwd=ROOT, capture_output=True, text=True).stdout.strip(),
754
564
  "commitSha": bi["commitSha"]},
755
565
  "target": target,
566
+ # 传输形态(D-attach-1):stdio=宿主本机拉起进程;remote=指向单独部署的
567
+ # 远程端点;skills-only=只装技能(MCP 由别处注册)
568
+ "transport": transport,
569
+ "mcpUrl": mcp_url or None,
756
570
  "installedAt": datetime.datetime.now().isoformat(timespec="seconds"),
757
571
  "preset": args.preset,
758
572
  "distribution": getattr(args, "distribution", "devkit"),
@@ -769,16 +583,30 @@ def _write_install_manifest(args, target, packs, bound_product, mcp_conf,
769
583
  # 不再只盯 hermes 单目录(opencode 漏拷静默失效的针对性防线)。
770
584
  # 多宿主并集合并:manifest 按「最近一次安装」覆盖会互相冲掉落点
771
585
  # (实锤:codex 装完 opencode 落点消失),按 host+dir 去重保留历史
772
- "skillInstalls": _skill_installs(manifest_path(), oc_skills, cx_skills),
586
+ "skillInstalls": _skill_installs(manifest_path(), extra_dirs),
773
587
  "skillHashes": _skill_hashes(),
588
+ # 载荷副本(D-payload-1):宿主入口指向这里,而不是仓/npx 缓存路径
589
+ "payloadDir": str(payload_dir) if payload_dir else None,
774
590
  }
591
+ row = {k: manifest[k] for k in
592
+ ("target", "transport", "mcpUrl", "installedAt", "product", "packs",
593
+ "dshProfile", "apiBase", "mcpConfig", "skillsDir", "payloadDir")}
594
+ row["version"] = manifest["version"]
595
+ row["commitSha"] = manifest["source"]["commitSha"]
596
+ row["skillInstalls"] = [si for si in manifest["skillInstalls"]
597
+ if si["host"] == target]
598
+ prev = _read_manifest()
599
+ manifest["installs"] = _install_rows(prev, row)
775
600
  manifest_path().write_text(json.dumps(manifest, ensure_ascii=False, indent=2),
776
601
  encoding="utf-8")
777
602
  print("installed:", json.dumps(manifest, ensure_ascii=False, indent=2))
778
603
  missing = [k for k in ("VOD_JAVA_API_KEY",) if
779
604
  not os.environ.get(k) and not _runtime_cfg_read().get("java_key")]
780
- if missing:
605
+ if missing and transport == "stdio":
781
606
  print(f"提示:{missing} 未配置——首次提交将自动申请零字段匿名令牌(无需配置)")
607
+ elif transport == "remote":
608
+ print("远程形态提示:身份随请求头走(token 已由宿主配置承载);"
609
+ "本机 runtime.json 的匿名链不参与远程提交")
782
610
 
783
611
 
784
612
  def _runtime_cfg_read() -> dict:
@@ -801,6 +629,9 @@ def cmd_status(_args):
801
629
  text = p.read_text(encoding="utf-8")
802
630
  text = re.sub(r'"apiBase": "http://127\.0\.0\.1:\d+"',
803
631
  '"apiBase": "http://127.0.0.1:<PORT>"', text)
632
+ # 载荷路径含 HOME/版本,按 <PAYLOAD> 归一(golden 不随环境漂)
633
+ text = re.sub(r'"payloadDir": ".*?/payloads/[^"]+"',
634
+ '"payloadDir": "<PAYLOAD>"', text)
804
635
  print(text)
805
636
 
806
637
 
@@ -813,10 +644,20 @@ def _repair_dsh_patch_block(mf: dict) -> str | None:
813
644
  dsh 的配置序列化只保留它能识别的块,手工游离块会被下次写盘冲掉。
814
645
  """
815
646
  prof = mf["dshProfile"]
816
- patch = Path.home() / ".dsh" / "profiles" / prof / "cordis.patch.yml"
647
+ patch = Path(host_specs.load("dsh", prof)["configPath"])
817
648
  if not patch.exists():
818
649
  return None
650
+ from vod_mcp import config_forms as cf
819
651
  lines = patch.read_text(encoding="utf-8").splitlines()
652
+ try:
653
+ verdict, reason = cf.classify_dsh_patch(lines)
654
+ except cf.Refused as e:
655
+ verdict, reason = "refuse", str(e)
656
+ if verdict == "refuse":
657
+ # 自愈也不越界:文件形态未知时只报告,不动字节
658
+ print(f"[doctor] skip(cordis.patch.yml 形态不受支持,未自愈):{reason}",
659
+ file=sys.stderr)
660
+ return None
820
661
  vod_idx = next((i for i, ln in enumerate(lines)
821
662
  if ln.strip().startswith("- id: vod-devkit")), None)
822
663
  if vod_idx is not None and lines[vod_idx].startswith((" ", "\t")):
@@ -868,6 +709,25 @@ def cmd_doctor(_args):
868
709
  problems.append("install-manifest 与 build-info 的 commitSHA 不一致")
869
710
  if mf.get("mcpConfig") and not Path(mf["mcpConfig"]).exists():
870
711
  problems.append("MCP 配置文件缺失")
712
+ if mf.get("transport") == "remote" and mf.get("mcpUrl"):
713
+ url = mf["mcpUrl"]
714
+ token = (os.environ.get("VOD_MCP_TOKEN")
715
+ or os.environ.get("MCP_VOD_DEVKIT_API_KEY") or "").strip()
716
+ try:
717
+ names = _probe_remote(url, token, timeout=8)
718
+ missing = _expected_remote_tools() - set(names)
719
+ if missing:
720
+ problems.append(f"远程面工具面不符(缺 {sorted(missing)}):{url}")
721
+ else:
722
+ print(f"[doctor] 远程面可达:{url}({len(names)} 工具)")
723
+ except Exception as e: # noqa: BLE001
724
+ if not _remote_reachable(url):
725
+ problems.append(f"远程 MCP 端点不可达:{url}")
726
+ elif not token:
727
+ print("[doctor] 远程端点可达,但未提供 token(401 属预期):"
728
+ "设 VOD_MCP_TOKEN 可验工具面")
729
+ else:
730
+ problems.append(f"远程面探活失败(带 token):{e}")
871
731
  if not Path(mf["skillsDir"]).exists():
872
732
  problems.append("skills 目录缺失")
873
733
  drifted = _drifted_skills(mf)
@@ -889,6 +749,45 @@ def cmd_doctor(_args):
889
749
  problems.append(f"技能文件缺失({si['host']}):{rel}")
890
750
  elif hashlib.sha256(f.read_bytes()).hexdigest() != sha:
891
751
  problems.append(f"技能文件漂移({si['host']}):{rel}")
752
+ # 载荷(D-payload-1):MCP 入口指向副本 → 副本必须在且未被改
753
+ from vod_mcp import payload as _payload
754
+ pd = mf.get("payloadDir")
755
+ if pd:
756
+ if not Path(pd).is_dir():
757
+ problems.append(f"载荷目录缺失:{pd}(MCP 入口指向它,宿主起不来)——重跑 install")
758
+ else:
759
+ bad = _payload.verify(Path(pd))
760
+ if bad:
761
+ problems.append("载荷被改动:" + ";".join(bad[:5]))
762
+ if _payload.marker_path().exists():
763
+ print(f"[doctor] 载荷已换({pd})——重启宿主会话生效")
764
+ else:
765
+ print("[doctor] 提示:本次安装无载荷副本(旧版),入口指向仓内路径;重跑 install 可固化")
766
+ for res in _payload.residue():
767
+ print(f"[doctor] 载荷残留(无 payload.json):{res}——可手动删除")
768
+ # 旧一代 AGENTS.md 注入(2026-11-05 之前的 one-liner):教模型跳过同意 +
769
+ # 归因由安装绑定。实测 1705 个 codex 会话带着它 → 不动它就等于红线失效。
770
+ legacy_agents = Path.home() / ".codex" / "AGENTS.md"
771
+ if legacy_agents.exists() and "vod-submit-one-liner" in legacy_agents.read_text(
772
+ encoding="utf-8"):
773
+ problems.append(f"AGENTS.md 仍含旧一代注入(教模型跳过同意):{legacy_agents}"
774
+ "——重跑 install --target codex 自动清理")
775
+ # 路由插件副本(hermes):仓内话术改了但装机副本没刷新 → 宿主还在注入旧口径
776
+ # (2026-11-11 实锤:仓里已把"归因由安装绑定决定"改成"原话解析",装机副本仍是旧的)
777
+ rp_dst = Path.home() / ".hermes" / "plugins" / "vod-feedback-router" / "router.py"
778
+ rp_src = ROOT / "hermes-plugin" / "vod-feedback-router" / "router.py"
779
+ if rp_dst.exists() and rp_src.exists() and rp_dst.read_text(encoding="utf-8") != \
780
+ rp_src.read_text(encoding="utf-8"):
781
+ problems.append(f"路由插件副本落后于仓内:{rp_dst}(重跑 install --target hermes)")
782
+ # CodeArts Agent 冒烟:官方 CLI 在就 list 一次(实测通道=codearts_cli.json 的 mcp 段)
783
+ if mf.get("target") == "codeartsdoer" and shutil.which("codearts"):
784
+ r = subprocess.run(["codearts", "mcp", "list"], capture_output=True,
785
+ text=True, timeout=60)
786
+ if "vod-devkit" in (r.stdout or ""):
787
+ print("[doctor] CodeArts Agent 已识别 vod-devkit(codearts mcp list)")
788
+ else:
789
+ problems.append("CodeArts Agent 未列出 vod-devkit"
790
+ "(codearts mcp list)——检查 codearts_cli.json 的 mcp 段")
892
791
  if problems:
893
792
  for x in problems:
894
793
  print("FAIL:", x)
@@ -956,8 +855,20 @@ def cmd_verify(_args):
956
855
  print(f"verify: OK(commit {sha[:12]} 存在于本仓/origin)")
957
856
 
958
857
 
959
- def cmd_update(_args):
960
- """更新:git fetch 比较 origin/main,落后则 ff 拉取并重烧 build-info。"""
858
+ def cmd_update(args=None):
859
+ """更新:git fetch 比较 origin/main,落后则 ff 拉取并重烧 build-info。
860
+
861
+ --skip / --clear-skip(D-devtoolchain-7,对齐 devkit update-skip 裁剪版):
862
+ 只维护「跳过某个版本提醒」的运行时状态,不动代码——所以放在 git 拉取之前返回。
863
+ """
864
+ if getattr(args, "skip", False) or getattr(args, "clear_skip", False):
865
+ from vod_mcp import update_check as uc
866
+ out = uc.check({"clearSkip": True} if getattr(args, "clear_skip", False)
867
+ else {"skip": True})
868
+ print(out.get("note") or "")
869
+ if out.get("latestVersion"):
870
+ print(f"latest = {out['latestVersion']}(clearSkip=true 可撤销)")
871
+ return
961
872
  if _distribution() == "preset":
962
873
  # D-key-guard-3②:产品分发形态插件版本随 agent 发版管理,客户机禁止自更新
963
874
  #(绕过产品版本管理=未测试代码进客户现场)
@@ -984,59 +895,164 @@ def cmd_update(_args):
984
895
  print(" 并重启 agent 会话")
985
896
 
986
897
 
898
+ # 共享用户配置文件:uninstall 只摘「我们的托管条目」,绝不删除文件
899
+ #(深审 P0-3 只挡了 config.toml;opencode.json 同类且更危险——里面有用户整份
900
+ # provider 配置。2026-11-11 远程 attach 落地时一并收口。)
901
+ _SHARED_CONFIG_NAMES = {"config.toml", "config.yaml", "config.yml",
902
+ "opencode.json", "opencode.jsonc"}
903
+
904
+
905
+ def _remove_managed_mcp_entry(target: str, path: Path) -> None:
906
+ """从宿主共享配置里摘掉 vod-devkit 条目(保留其它键/其它 server)。"""
907
+ section = {"opencode": "mcp", "codeartsdoer": "mcp", "generic": "mcpServers"}.get(target)
908
+ if section:
909
+ if not path.exists():
910
+ return
911
+ try:
912
+ cfg = json.loads(path.read_text(encoding="utf-8"))
913
+ except Exception:
914
+ print(f"skip({path} 不是合法 JSON,未改动)")
915
+ return
916
+ block = cfg.get(section) or {}
917
+ if "vod-devkit" not in block:
918
+ return
919
+ block.pop("vod-devkit")
920
+ if not block:
921
+ cfg.pop(section, None)
922
+ else:
923
+ cfg[section] = block
924
+ path.write_text(json.dumps(cfg, ensure_ascii=False, indent=2), encoding="utf-8")
925
+ print(f"removed {section}.vod-devkit: {path}")
926
+ return
927
+ cli, args = None, None
928
+ if target == "hermes" and shutil.which("hermes"):
929
+ cli, args = "hermes", ["mcp", "remove", "vod-devkit"]
930
+ elif target == "codex" and shutil.which("codex"):
931
+ cli, args = "codex", ["mcp", "remove", "vod-devkit"]
932
+ if cli:
933
+ r = subprocess.run([cli, *args], capture_output=True, text=True, timeout=120)
934
+ print(f"{cli} mcp remove:", "OK" if r.returncode == 0
935
+ else (r.stderr or r.stdout).strip()[-120:])
936
+
937
+
938
+ def _remove_managed_skills(mf: dict, path: Path, target: str) -> None:
939
+ """技能摘除:hermes 目录是专属的(整目录删);其它宿主技能目录是**共享**的
940
+ (opencode ~/.config/opencode/skills 等),只摘本插件改名下的技能。
941
+ 2026-11-11 与 uninstall 共享配置收口同批修:整目录删会连带删掉用户的其它技能。"""
942
+ if target == "hermes":
943
+ if path.exists():
944
+ shutil.rmtree(path)
945
+ print("removed:", path)
946
+ return
947
+ names = {rel.split("/")[0] for rel in (mf.get("skillHashes") or {})}
948
+ removed = []
949
+ for n in sorted(names):
950
+ d = path / n
951
+ if d.is_dir():
952
+ shutil.rmtree(d)
953
+ removed.append(n)
954
+ print(f"removed skills: {removed}(共享目录保留):{path}") if removed \
955
+ else print(f"skip(无需摘除的技能):{path}")
956
+
957
+
958
+ def _cleanup_install_row(row: dict, skill_hashes: dict | None = None) -> None:
959
+ """按一条安装记录清理:MCP 条目 / 技能落点 / 宿主专属产物。
960
+
961
+ 技能名清单来自 manifest 顶层 skillHashes(各安装行共用同一份技能集合)。
962
+ """
963
+ target = row.get("target")
964
+ mf = dict(row)
965
+ mf["skillHashes"] = skill_hashes or {}
966
+ for key in ("mcpConfig", "skillsDir"):
967
+ path_s = row.get(key)
968
+ if not path_s:
969
+ continue # codex 等宿主 mcpConfig 可为 None(P0-3:无托管配置文件)
970
+ if key == "skillsDir":
971
+ _remove_managed_skills(mf, Path(path_s), target)
972
+ continue
973
+ path = Path(path_s)
974
+ # 深审 P0-3(破坏性路径一票否决):共享用户配置永不整文件删除
975
+ #(config.toml/opencode.json/codearts_cli.json/.claude.json 里有用户自己的
976
+ # provider、其它 server)。JSON 合并型宿主一律走"摘条目",与文件名无关——
977
+ # codearts_cli.json 第一版没进 _SHARED_CONFIG_NAMES,卸载把整份配置删了(实锤)。
978
+ if target in ("opencode", "codeartsdoer", "generic") or path.name in _SHARED_CONFIG_NAMES:
979
+ print(f"skip(用户配置文件,uninstall 只摘托管条目):{path}")
980
+ _remove_managed_mcp_entry(target, path)
981
+ continue
982
+ if path.exists():
983
+ shutil.rmtree(path) if path.is_dir() else path.unlink()
984
+ print("removed:", path)
985
+ # codex 摘除:remote 形态摘 MCP 条目;stdio 形态摘原生插件(best-effort)
986
+ if target == "codex":
987
+ codex = shutil.which("codex")
988
+ if codex and (row.get("transport") or "stdio") == "remote":
989
+ _remove_managed_mcp_entry("codex", Path.home() / ".codex" / "config.toml")
990
+ elif codex:
991
+ r = subprocess.run([codex, "plugin", "remove", "vod-devkit@vod-local"],
992
+ capture_output=True, text=True, timeout=120)
993
+ print("codex plugin remove:",
994
+ "OK" if r.returncode == 0 else (r.stderr or r.stdout).strip()[-120:])
995
+ # opencode 随装生成物(/vod-doctor 命令)
996
+ if target == "opencode":
997
+ for g in host_specs.load("opencode")["generated"]:
998
+ gen = Path(g["dest"])
999
+ if gen.exists():
1000
+ gen.unlink()
1001
+ print("removed:", gen)
1002
+ # dsh 壳(D-dsh-install-1):摘插件 + 从 profile patch 移除 config 段
1003
+ if target == "dsh":
1004
+ dsh = shutil.which("dsh")
1005
+ prof = (row.get("dshProfile") or "").strip()
1006
+ if dsh and prof:
1007
+ subprocess.run([dsh, "plugin", "--profile", prof, "remove",
1008
+ "dsh-vod-devkit"], capture_output=True, text=True)
1009
+ if prof: # 无 profile 记录=没写过 patch,无需(也无法)摘除
1010
+ patch_path = Path(host_specs.load("dsh", prof)["configPath"])
1011
+ from vod_mcp.host_adapters import dsh as dsh_adapter
1012
+ if dsh_adapter.remove_patch_block(patch_path):
1013
+ print("removed vod-devkit config block:", patch_path)
1014
+ # codeartsdoer / opencode / generic 共用 JSON 配置:条目已在上面按 mcpConfig 摘除
1015
+
1016
+
987
1017
  def cmd_uninstall(_args):
988
1018
  p = manifest_path()
989
- if p.exists():
990
- mf = json.loads(p.read_text(encoding="utf-8"))
991
- for key in ("mcpConfig", "skillsDir"):
992
- path_s = mf.get(key)
993
- if not path_s:
994
- continue # codex 等宿主 mcpConfig 可为 None(P0-3:无托管配置文件)
995
- path = Path(path_s)
996
- # 深审 P0-3(破坏性路径一票否决):config.toml 是用户整份 codex
997
- # 配置,永不在 uninstall 删除——旧版 manifest 曾把它记成 mcpConfig
998
- if path.name == "config.toml":
999
- print(f"skip(用户配置文件,uninstall 永不删除):{path}")
1000
- continue
1001
- if path.exists():
1002
- shutil.rmtree(path) if path.is_dir() else path.unlink()
1003
- print("removed:", path)
1004
- # codex 原生插件摘除(best-effort:CLI 命令名随版本可能变化,失败不阻塞)
1005
- if mf.get("target") == "codex":
1006
- codex = shutil.which("codex")
1007
- if codex:
1008
- r = subprocess.run([codex, "plugin", "remove",
1009
- "vod-devkit@vod-local"],
1010
- capture_output=True, text=True, timeout=120)
1011
- print("codex plugin remove:",
1012
- "OK" if r.returncode == 0
1013
- else (r.stderr or r.stdout).strip()[-120:])
1014
- oc_cmd = Path.home() / ".config/opencode/command/vod-doctor.md"
1015
- if oc_cmd.exists():
1016
- oc_cmd.unlink()
1017
- print("removed:", oc_cmd)
1018
- # dsh 壳(D-dsh-install-1):摘插件 + 从 profile patch 移除 config 段
1019
- dsh = shutil.which("dsh")
1020
- if dsh:
1021
- prof = (mf.get("dshProfile") or "").strip()
1022
- if prof:
1023
- subprocess.run([dsh, "plugin", "--profile", prof, "remove",
1024
- "dsh-vod-devkit"], capture_output=True, text=True)
1025
- patch = Path.home() / ".dsh" / "profiles" / prof / "cordis.patch.yml"
1026
- if _remove_dsh_patch_block(patch):
1027
- print("removed vod-devkit config block:", patch)
1028
- p.unlink()
1029
- print("removed:", p)
1030
- else:
1019
+ if not p.exists():
1031
1020
  print("未安装")
1021
+ return
1022
+ mf = json.loads(p.read_text(encoding="utf-8"))
1023
+ rows = mf.get("installs") or [mf] # 老 manifest(无 installs[])退化为单条
1024
+ for row in rows:
1025
+ _cleanup_install_row(row, mf.get("skillHashes"))
1026
+ # 载荷清理(D-payload-1):所有安装记录共用的副本,逐目录去重后删,再删 marker
1027
+ from vod_mcp import payload as _payload
1028
+ seen = set()
1029
+ for row in rows:
1030
+ pd = row.get("payloadDir")
1031
+ if not pd or pd in seen:
1032
+ continue
1033
+ seen.add(pd)
1034
+ if Path(pd).is_dir():
1035
+ shutil.rmtree(pd, ignore_errors=True)
1036
+ print("removed payload:", pd)
1037
+ try:
1038
+ _payload.marker_path().unlink(missing_ok=True)
1039
+ except Exception:
1040
+ pass
1041
+ p.unlink()
1042
+ print("removed:", p)
1032
1043
 
1033
1044
 
1034
1045
  def main():
1046
+ # `serve` 后的参数整体透传给 MCP server(argparse 的 REMAINDER 会把
1047
+ # --transport 当成未知参数拦下,devkit 的二进制本身就是 server,同形处理)
1048
+ if len(sys.argv) > 1 and sys.argv[1] == "serve":
1049
+ os.execv(sys.executable,
1050
+ [sys.executable, str(ROOT / "vod_mcp" / "server.py"), *sys.argv[2:]])
1035
1051
  ap = argparse.ArgumentParser(prog="vod-devkit")
1036
1052
  sub = ap.add_subparsers(dest="cmd", required=True)
1037
1053
  sp = sub.add_parser("install")
1038
1054
  sp.add_argument("--target", default="auto",
1039
- help="hermes|opencode|codex|dsh|auto(默认探测)")
1055
+ help="hermes|opencode|codeartsdoer|codex|dsh|generic|auto(默认探测)")
1040
1056
  sp.add_argument("--preset", default="collect", choices=list(PRESETS),
1041
1057
  help="collect=对外默认(采集者);full=内部全量")
1042
1058
  sp.add_argument("--api-base", default="http://127.0.0.1:8000")
@@ -1052,6 +1068,16 @@ def main():
1052
1068
  "禁自更新/客户机首启重生成状态)")
1053
1069
  sp.add_argument("--profile", dest="dsh_profile", default="",
1054
1070
  help="dsh 专用:profile 名(--target dsh 时必填)")
1071
+ sp.add_argument("--mcp-url", default="",
1072
+ help="远程 attach 模式:宿主 MCP 配置指向该 Streamable HTTP 端点"
1073
+ "(hermes/opencode/codex 支持;dsh 不走 MCP)")
1074
+ sp.add_argument("--mcp-token", default="",
1075
+ help="远程 attach 的身份(也可用 env VOD_MCP_TOKEN):远程面不代签身份,"
1076
+ "缺 token 拒绝安装")
1077
+ sp.add_argument("--mcp-config", default="",
1078
+ help="通用宿主(--target generic)的 MCP 配置文件路径;不给则只打印可粘贴片段")
1079
+ sp.add_argument("--skills-only", action="store_true",
1080
+ help="只装技能,不动宿主 MCP 配置(MCP 已由别处/手工注册时用)")
1055
1081
  sp.add_argument("--no-local-ledger", action="store_true",
1056
1082
  help="关闭本地提交账本(企业数据驻留要求;vod_list_submitted 将不可用)")
1057
1083
  sp.set_defaults(fn=cmd_install)
@@ -1059,13 +1085,29 @@ def main():
1059
1085
  ("verify", cmd_verify), ("update", cmd_update),
1060
1086
  ("uninstall", cmd_uninstall)):
1061
1087
  s = sub.add_parser(name)
1088
+ if name == "update":
1089
+ s.add_argument("--skip", action="store_true",
1090
+ help="跳过当前 registry latest 的提醒(只压这一个版本,"
1091
+ "下个版本仍提醒;不提供永久静音)")
1092
+ s.add_argument("--clear-skip", action="store_true",
1093
+ help="撤销版本跳过设置,恢复正常提醒")
1062
1094
  s.set_defaults(fn=fn)
1063
1095
  sub.add_parser("build-info").set_defaults(fn=lambda a: write_build_info(strict=False))
1064
1096
 
1065
- def _serve(_a):
1066
- """codex 原生插件 .mcp.json 入口:exec MCP stdio server(可移植分发)。"""
1067
- os.execv(sys.executable, [sys.executable, str(ROOT / "vod_mcp" / "server.py")])
1068
- sub.add_parser("serve").set_defaults(fn=_serve)
1097
+ def _serve(a):
1098
+ """MCP server 入口(codex 插件 .mcp.json 与远程面共用)。
1099
+
1100
+ 透传参数:`vod-devkit serve --transport remote --port 9528` 即起 HTTP 面
1101
+ (与 huaweicloud-devkit 的 `--transport remote` 同形)。
1102
+ """
1103
+ extra = list(getattr(a, "server_args", []) or [])
1104
+ os.execv(sys.executable,
1105
+ [sys.executable, str(ROOT / "vod_mcp" / "server.py"), *extra])
1106
+ sp_serve = sub.add_parser("serve", help="启动 MCP server(默认 stdio;"
1107
+ "--transport remote 起 Streamable HTTP)")
1108
+ sp_serve.add_argument("server_args", nargs=argparse.REMAINDER,
1109
+ help="透传给 vod_mcp.server(如 --transport remote --port 9528)")
1110
+ sp_serve.set_defaults(fn=_serve)
1069
1111
  args = ap.parse_args()
1070
1112
  args.fn(args)
1071
1113