vod-devkit 0.5.1 → 0.5.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 (33) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +41 -1
  3. package/bin/vod-devkit +14 -5
  4. package/contract/tools.schema.json +1 -1
  5. package/integrations/atomcode/host.json +8 -0
  6. package/integrations/codeartswork/host.json +8 -0
  7. package/integrations/codex-desktop/host.json +8 -0
  8. package/integrations/workbuddy/host.json +8 -0
  9. package/package.json +1 -1
  10. package/plugins/vod-devkit/.codex-plugin/plugin.json +1 -1
  11. package/plugins/vod-devkit/build-info.json +3 -3
  12. package/plugins/vod-devkit/vod_mcp/__init__.py +1 -1
  13. package/plugins/vod-devkit/vod_mcp/host_adapters/__init__.py +7 -1
  14. package/plugins/vod-devkit/vod_mcp/host_adapters/atomcode.py +53 -0
  15. package/plugins/vod-devkit/vod_mcp/host_adapters/codeartswork.py +53 -0
  16. package/plugins/vod-devkit/vod_mcp/host_adapters/codex_desktop.py +153 -0
  17. package/plugins/vod-devkit/vod_mcp/host_adapters/hermes.py +52 -7
  18. package/plugins/vod-devkit/vod_mcp/host_adapters/workbuddy.py +47 -0
  19. package/plugins/vod-devkit/vod_mcp/tools.py +21 -7
  20. package/vod_mcp/__init__.py +1 -1
  21. package/vod_mcp/host_adapters/__init__.py +7 -1
  22. package/vod_mcp/host_adapters/__pycache__/__init__.cpython-314.pyc +0 -0
  23. package/vod_mcp/host_adapters/__pycache__/atomcode.cpython-314.pyc +0 -0
  24. package/vod_mcp/host_adapters/__pycache__/codeartswork.cpython-314.pyc +0 -0
  25. package/vod_mcp/host_adapters/__pycache__/codex_desktop.cpython-314.pyc +0 -0
  26. package/vod_mcp/host_adapters/__pycache__/hermes.cpython-314.pyc +0 -0
  27. package/vod_mcp/host_adapters/__pycache__/workbuddy.cpython-314.pyc +0 -0
  28. package/vod_mcp/host_adapters/atomcode.py +53 -0
  29. package/vod_mcp/host_adapters/codeartswork.py +53 -0
  30. package/vod_mcp/host_adapters/codex_desktop.py +153 -0
  31. package/vod_mcp/host_adapters/hermes.py +52 -7
  32. package/vod_mcp/host_adapters/workbuddy.py +47 -0
  33. package/vod_mcp/tools.py +21 -7
package/CHANGELOG.md CHANGED
@@ -302,3 +302,17 @@
302
302
  - e613449 feat(dsh): 归因与 MCP 侧同口径——运行期字面解析 + 记忆 + 先验 + 弃权(D-attrib-B)
303
303
  - 9b785dd feat(归因): 运行期字面解析取代安装绑定——名录别名 + 短 TTL 记忆 + 弃权(D-attrib-B)
304
304
 
305
+
306
+ ## v0.5.2(2026-11-12)
307
+
308
+ - cd1b0b0 feat(追问): 轮次上限 2 次 + 候选可解释(评审采纳)
309
+ - 2eb7886 chore(发版): golden 版本行随 bump 自动重录(两次实锤:v0.5.0/v0.5.1 都在 pre-push 被拦)
310
+
311
+
312
+ ## v0.5.3(2026-11-12)
313
+
314
+ - e8bc909 feat(hermes): 路由插件自动启用 + 修 dsh 包发布路径
315
+ - 8a93bd8 feat(宿主): 新增 4 个宿主适配(workbuddy / atomcode / codeartswork / codex-desktop)
316
+ - ba2901b chore(发版): 提交清单补根 skills/、hermes-plugin/、docs/decisions.md、build-info.json
317
+ - cbbaf17 docs(技能): 补齐 0.5.2 同批文案 + 发版清单修正
318
+
package/README.md CHANGED
@@ -20,7 +20,7 @@
20
20
  |---|---|---|
21
21
  | Node | >= 18 | `npx` 引导器;dsh 宿主请按其官方要求(Node 24.9+) |
22
22
  | Python | >= 3.10 | 安装器与 MCP server;可用 `VOD_PYTHON` 指定解释器 |
23
- | 宿主 | hermes / opencode / codeartsdoer / codex / dsh 任一 | 用 `--target auto` 探测,或显式指定 |
23
+ | 宿主 | hermes / opencode / codeartsdoer / codeartswork / codex / codex-desktop / dsh / workbuddy / atomcode 任一(另支持 claude-code / cursor / windsurf / cline 等走 `--target generic`) | 用 `--target auto` 探测,或显式指定 |
24
24
  | 网络 | 可达你的 VOD 引擎 | 缺省 `https://vod-dev.topxtopx.com`,可 `--java-api-base` 覆盖 |
25
25
 
26
26
  远程面额外需要官方 MCP SDK:`pip install 'vod-devkit[remote]'`(stdio 形态零第三方依赖)。
@@ -103,6 +103,46 @@ npx -y vod-devkit@latest uninstall # 只摘 mcp.vod-devkit,provider/model
103
103
  - **不要**写 `~/.codeartsdoer/mcp/mcp_settings.json`——那是项目级路径;用户级
104
104
  mcp_settings 读的是 `~/.config/opencode/mcp/`
105
105
 
106
+ ### CodeArts Work(codeartswork)
107
+
108
+ ```bash
109
+ npx -y vod-devkit@latest install --target codeartswork
110
+ ```
111
+
112
+ - 落点:`~/.codearts/mcp/mcp_settings.json`(平台迁移后的新址;目录不存在时回退
113
+ `~/.codeartswork/mcp/mcp_settings.json`),条目形态 `mcp.vod-devkit =
114
+ {command: 数组, environment}`——环境键名是 `environment`,不是 `env`
115
+ - 技能装到 `~/.codeartswork/skills`
116
+
117
+ ### Codex Desktop(codex-desktop)
118
+
119
+ ```bash
120
+ npx -y vod-devkit@latest install --target codex-desktop
121
+ ```
122
+
123
+ - 插件目录 `~/plugins/vod-devkit`(内含 `.mcp.json` 与 `.codex-plugin/plugin.json`),
124
+ 并在 `~/.agents/plugins/marketplace.json` 的 `plugins[]` 里登记一条
125
+ `{name, source:{source:"local", path:"./plugins/vod-devkit"}}`
126
+ - 卸载只摘自己那条登记 + 删插件目录,不碰 `~/.agents/skills` 等原生目录
127
+
128
+ ### WorkBuddy(workbuddy)
129
+
130
+ ```bash
131
+ npx -y vod-devkit@latest install --target workbuddy
132
+ ```
133
+
134
+ - 落点:`~/.workbuddy/mcp.json` 的 `mcpServers.vod-devkit`;技能装到 `~/.workbuddy/skills`
135
+
136
+ ### AtomCode(atomcode)
137
+
138
+ ```bash
139
+ npx -y vod-devkit@latest install --target atomcode
140
+ ```
141
+
142
+ - 配置根可由 `ATOMCODE_HOME` 覆盖(默认 `~/.atomcode`),落点 `mcp.json` 的
143
+ `mcpServers.vod-devkit`;技能装到 `<home>/skills`
144
+ - 不装宿主的 `hooks.json` 遥测 hook(本插件不引入遥测)
145
+
106
146
  ### DeepSeek Harness (dsh)
107
147
 
108
148
  ```bash
package/bin/vod-devkit CHANGED
@@ -314,7 +314,7 @@ def cmd_install(args):
314
314
  f"({args.mcp_config})")
315
315
  elif not found:
316
316
  known = "、".join(h["label"] + "(" + h["config"] + ")" for h in generic_found)
317
- print("未探测到可自动安装的宿主;用 --target hermes|opencode|codeartsdoer|codex|dsh 显式指定"
317
+ print("未探测到可自动安装的宿主;用 --target hermes|opencode|codeartsdoer|codeartswork|codex|codex-desktop|dsh|workbuddy|atomcode 显式指定"
318
318
  + (f",或通用写入:--target generic --mcp-config <配置>(探测到 {known})"
319
319
  if generic_found else ""), file=sys.stderr)
320
320
  sys.exit(2)
@@ -328,7 +328,7 @@ def cmd_install(args):
328
328
  g = [(h["id"], h["config"]) for h in generic_host.detect_known()]
329
329
  hint = ("\n 探测到通用 MCP 宿主:" + ";".join(f"{i}({c})" for i, c in g)
330
330
  if g else "")
331
- print(f"不支持目标: {target}(可选 hermes|opencode|codeartsdoer|codex|dsh|generic|auto){hint}\n"
331
+ print(f"不支持目标: {target}(可选 hermes|opencode|codeartsdoer|codeartswork|codex|codex-desktop|dsh|workbuddy|atomcode|generic|auto){hint}\n"
332
332
  " 通用宿主:install --target generic --mcp-config <配置文件>",
333
333
  file=sys.stderr)
334
334
  sys.exit(2)
@@ -904,7 +904,9 @@ _SHARED_CONFIG_NAMES = {"config.toml", "config.yaml", "config.yml",
904
904
 
905
905
  def _remove_managed_mcp_entry(target: str, path: Path) -> None:
906
906
  """从宿主共享配置里摘掉 vod-devkit 条目(保留其它键/其它 server)。"""
907
- section = {"opencode": "mcp", "codeartsdoer": "mcp", "generic": "mcpServers"}.get(target)
907
+ section = {"opencode": "mcp", "codeartsdoer": "mcp", "codeartswork": "mcp",
908
+ "generic": "mcpServers", "workbuddy": "mcpServers",
909
+ "atomcode": "mcpServers"}.get(target)
908
910
  if section:
909
911
  if not path.exists():
910
912
  return
@@ -961,6 +963,12 @@ def _cleanup_install_row(row: dict, skill_hashes: dict | None = None) -> None:
961
963
  技能名清单来自 manifest 顶层 skillHashes(各安装行共用同一份技能集合)。
962
964
  """
963
965
  target = row.get("target")
966
+ # codex-desktop:mcpConfig 指向共享的 marketplace.json,绝不能走"整文件删"分支
967
+ # (那会删掉用户/其它插件的市场登记)。交给适配器只摘自己那一条 + 删插件目录。
968
+ if target == "codex-desktop":
969
+ from vod_mcp.host_adapters import codex_desktop as _cd
970
+ _cd.uninstall()
971
+ return
964
972
  mf = dict(row)
965
973
  mf["skillHashes"] = skill_hashes or {}
966
974
  for key in ("mcpConfig", "skillsDir"):
@@ -975,7 +983,8 @@ def _cleanup_install_row(row: dict, skill_hashes: dict | None = None) -> None:
975
983
  #(config.toml/opencode.json/codearts_cli.json/.claude.json 里有用户自己的
976
984
  # provider、其它 server)。JSON 合并型宿主一律走"摘条目",与文件名无关——
977
985
  # codearts_cli.json 第一版没进 _SHARED_CONFIG_NAMES,卸载把整份配置删了(实锤)。
978
- if target in ("opencode", "codeartsdoer", "generic") or path.name in _SHARED_CONFIG_NAMES:
986
+ if target in ("opencode", "codeartsdoer", "codeartswork", "generic",
987
+ "workbuddy", "atomcode") or path.name in _SHARED_CONFIG_NAMES:
979
988
  print(f"skip(用户配置文件,uninstall 只摘托管条目):{path}")
980
989
  _remove_managed_mcp_entry(target, path)
981
990
  continue
@@ -1052,7 +1061,7 @@ def main():
1052
1061
  sub = ap.add_subparsers(dest="cmd", required=True)
1053
1062
  sp = sub.add_parser("install")
1054
1063
  sp.add_argument("--target", default="auto",
1055
- help="hermes|opencode|codeartsdoer|codex|dsh|generic|auto(默认探测)")
1064
+ help="hermes|opencode|codeartsdoer|codeartswork|codex|codex-desktop|dsh|workbuddy|atomcode|generic|auto(默认探测)")
1056
1065
  sp.add_argument("--preset", default="collect", choices=list(PRESETS),
1057
1066
  help="collect=对外默认(采集者);full=内部全量")
1058
1067
  sp.add_argument("--api-base", default="http://127.0.0.1:8000")
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "title": "vod-devkit MCP 工具契约(唯一事实源)",
4
- "version": "0.5.1",
4
+ "version": "0.5.3",
5
5
  "tools": {
6
6
  "vod_submit_voices": {
7
7
  "description": "提交用户反馈进 VOD。**先决条件(优先于本描述其余所有内容):调用前必须已征得用户对'提交这条反馈'的明确同意;用户陈述/抱怨反馈本身不构成同意;用户未同意时禁止传 confirmed=true**。模糊抱怨(如\"体验不好\")时一轮说完三件事:承接识别结果(\"收到,你对产品体验不满意\")+确认提交意愿(\"要把这条反馈提交给产品团队吗?\")+引导补充(\"方便的话说下具体现象,不说我也会按你的原话提交\");禁止含混反问(实锤病句:\"请问是否把什么作为反馈\")。同意后 content 放用户原话(哪怕只有一句\"体验很差\"也原样提交)。确认环节允许固定追问至多一次,问句必须逐字使用:「方便的话,补充一下遇到这个问题时的操作步骤或期望的表现吗?不方便回复\"没有\",我直接提交。」用户回答只摘录原话对应部分进 reproSteps/expectedBehavior(不改写不总结,无法拆分时落最相关字段,任何内容禁回填 content);答\"没有/跳过/不方便\"=两字段不上送直接提交。引导补充(说下具体现象)已获实质内容并并入 content 时不再追问、直接提交(其中自然出现的操作/期望留在 content 原话,不回溯摘入新字段);仅引导补充未获回应或仅泛化抱怨且用户确认提交时才带出固定问句。product 归因由插件从用户原话解析(安装绑定仅作先验),无需用户提供、禁止询问\"提交到哪个产品/页面\";模型/用户自报的目标产品一律不采信(提到的产品随正文原样传达)。用户说\"提单/提工单/提 issue\"时同样用本工具,除上述固定一次追问外,禁止再索要严重程度/环境/附件等开发者字段、禁止第二轮追问。批式提交对接囤积端点 POST /external/voices(不触发分析,voiceId 由引擎计算回执下发;引擎未部署 404 自动回落老链)。tags=采集层三分类(problem_type:值,可选)。缺 key 时自动获取零字段匿名令牌。拿到回执后必须原样转述 echo.contents(每条「已收录原话:<content>」全文),禁止改写概括——这是用户核对原话是否被改写的唯一窗口。禁止向用户解释内部机制(声音来源/渠道字段/计数规则/配额/归因)。",
@@ -0,0 +1,8 @@
1
+ {
2
+ "id": "atomcode",
3
+ "cli": "atomcode",
4
+ "detect": {"path": "~/.atomcode"},
5
+ "config": "~/.atomcode/mcp.json",
6
+ "skillsDir": "~/.atomcode/skills",
7
+ "notes": "AtomCode 的配置根可由 ATOMCODE_HOME 覆盖(默认 ~/.atomcode),适配器每次调用期读取该 env,不缓存。mcp.json 形态 mcpServers.<name> = command/args/env。宿主另有 hooks.json 的 pre_tool_use 遥测 hook——属华为工具的埋点,我们刻意不装(不引入遥测)。路径来源:huaweicloud-devkit targets.ts atomcodeHome/atomcodeMcpConfigFile/atomcodeSkillsDir。本机未装该宿主,未真机验证。"
8
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "id": "codeartswork",
3
+ "cli": "codearts",
4
+ "detect": {"path": "~/.codeartswork"},
5
+ "config": "~/.codeartswork/mcp/mcp_settings.json",
6
+ "skillsDir": "~/.codeartswork/skills",
7
+ "notes": "CodeArts Work(CodeArts Space)只有用户级配置。平台迁移后市场把插件放在 ~/.codearts/mcp/mcp_settings.json(新址),旧址 ~/.codeartswork 作为回退——适配器按『新址目录存在则用新址,否则旧址』选择,与上游 targets.ts codeartsWorkMcpSettingsFile 一致。条目形态是 mcp.<name> = {command: 数组, environment}(注意:环境键名是 environment,不是 env)。本机未装该宿主,未真机验证。"
8
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "id": "codex-desktop",
3
+ "cli": "codex",
4
+ "detect": {"path": "~/.agents"},
5
+ "config": "~/.agents/plugins/marketplace.json",
6
+ "skillsDir": "~/plugins/vod-devkit/skills",
7
+ "notes": "Codex Desktop 通过『个人市场』发现插件:~/.agents/plugins/marketplace.json 的 plugins[] 里登记 {name, source:{source:local,path:./plugins/vod-devkit}},插件目录在 ~/plugins/<name>(内含 .mcp.json 与 .codex-plugin/plugin.json)。安装=写插件目录+登记一条;卸载=摘 marketplace 条目+删插件目录,不碰 ~/.agents/skills 等原生目录。路径来源:huaweicloud-devkit targets.ts codexDesktopPluginsDir/codexMarketplacePath 与 agents/codex-desktop.ts。本机未装该宿主,未真机验证。"
8
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "id": "workbuddy",
3
+ "cli": "workbuddy",
4
+ "detect": {"path": "~/.workbuddy"},
5
+ "config": "~/.workbuddy/mcp.json",
6
+ "skillsDir": "~/.workbuddy/skills",
7
+ "notes": "WorkBuddy 用户级 mcp.json(mcpServers.<name> = command/args/env)。宿主侧另有 settings.json 的 PostToolUse hook 与 plugins/hooks 目录——那是华为工具的采集链,我们不用;只写 mcpServers 一个键,卸载只摘该条目。路径实测来源:huaweicloud-devkit targets.ts workbuddyMcpConfigFile/workbuddySkillsDir。本机未装该宿主,配置形态按对表结论实现,未真机验证。"
8
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vod-devkit",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "VOD 用户声音采集插件——MCP server + 技能 + 声明式护栏,把 agent 产品的用户反馈安全送进 VOD 平台",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vod-devkit",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "VOD user-feedback collection: structured voice capture and submission to the VOD hoarding endpoint.",
5
5
  "keywords": [
6
6
  "feedback",
@@ -1,6 +1,6 @@
1
1
  {
2
- "version": "0.5.1",
3
- "commitSha": "61577bc0502106f436825f9382b89fcb4591a653",
4
- "builtAt": "2026-11-12T17:13:52",
2
+ "version": "0.5.3",
3
+ "commitSha": "e8bc9098422e3ceafacbfee817708d76b9e8d40b",
4
+ "builtAt": "2026-11-12T20:10:47",
5
5
  "sourceRemote": "https://gitcode.com/xiaowu2119/vod-devkit.git"
6
6
  }
@@ -5,7 +5,7 @@
5
5
  2. 外部无 DB 直连路径(护栏 deny 兜底)
6
6
  3. 任务 ID 是唯一对账主键,写类工具返回一律携带
7
7
  """
8
- __version__ = "0.5.1"
8
+ __version__ = "0.5.3"
9
9
  # 默认上游:VOD 测试环境。外部用户本机无 VOD,回环默认值=装完即坏;
10
10
  # 生产地址定型后只改这一处(tools.py 与 bin/vod-devkit 共用本常量)。
11
11
  DEFAULT_JAVA_BASE = "https://vod-dev.topxtopx.com"
@@ -5,14 +5,20 @@
5
5
 
6
6
  REGISTRY 里的模块必须实现 protocol 的三件事:install / install_remote / skills_dir。
7
7
  """
8
- from vod_mcp.host_adapters import codearts, codex, dsh, generic, hermes, opencode
8
+ from vod_mcp.host_adapters import (atomcode, codearts, codeartswork, codex,
9
+ codex_desktop, dsh, generic, hermes, opencode,
10
+ workbuddy)
9
11
 
10
12
  REGISTRY = {
11
13
  "hermes": hermes,
12
14
  "opencode": opencode,
13
15
  "codeartsdoer": codearts,
16
+ "codeartswork": codeartswork,
14
17
  "codex": codex,
18
+ "codex-desktop": codex_desktop,
15
19
  "dsh": dsh,
20
+ "workbuddy": workbuddy,
21
+ "atomcode": atomcode,
16
22
  "generic": generic,
17
23
  }
18
24
 
@@ -0,0 +1,53 @@
1
+ """AtomCode 宿主适配(mcpServers.<name> 形态,配置根可由 ATOMCODE_HOME 覆盖)。
2
+
3
+ 形态来源:huaweicloud-devkit targets.ts atomcodeHome/atomcodeMcpConfigFile ——
4
+ `${ATOMCODE_HOME:-~/.atomcode}/mcp.json` 的 mcpServers,技能落 <home>/skills。
5
+
6
+ 刻意不装宿主 hooks.json 的 pre_tool_use 遥测 hook(上游那样做是为了自己的埋点);
7
+ 本插件不引入遥测。
8
+ """
9
+ import os
10
+ import sys
11
+ from pathlib import Path
12
+
13
+ from vod_mcp.host_adapters.base import server_env, server_entry
14
+ from vod_mcp.host_adapters.generic import merge_mcp_servers
15
+
16
+ HOST = "atomcode"
17
+ SUPPORTS_REMOTE = True
18
+
19
+ _VERB = {"created": "写入", "updated": "更新", "unchanged": "跳过(已一致)"}
20
+
21
+
22
+ def _home() -> Path:
23
+ """调用期读 env(测试/多宿主环境可重定向,禁止 import 期求值)。"""
24
+ raw = (os.environ.get("ATOMCODE_HOME") or "").strip()
25
+ return Path(raw).expanduser() if raw else Path.home() / ".atomcode"
26
+
27
+
28
+ def _spec() -> dict:
29
+ return {
30
+ "configPath": _home() / "mcp.json",
31
+ "skillsDir": _home() / "skills",
32
+ }
33
+
34
+
35
+ def skills_dir(args):
36
+ return _spec()["skillsDir"]
37
+
38
+
39
+ def install(args, packs):
40
+ spec = _spec()
41
+ entry = {"command": sys.executable, "args": [server_entry()],
42
+ "env": server_env(args, packs)}
43
+ action = merge_mcp_servers(spec["configPath"], entry)
44
+ print(f"已{_VERB[action]} AtomCode 配置:{spec['configPath']}(重启 AtomCode 会话生效)")
45
+ return spec["configPath"]
46
+
47
+
48
+ def install_remote(args, url, token):
49
+ conf = _spec()["configPath"]
50
+ entry = {"url": url, "headers": {"Authorization": f"Bearer {token}"}}
51
+ action = merge_mcp_servers(conf, entry)
52
+ print(f"已{_VERB[action]} AtomCode 远程 MCP:{conf}(token 明文,注意文件权限)")
53
+ return conf
@@ -0,0 +1,53 @@
1
+ """CodeArts Work(CodeArts Space)宿主适配。
2
+
3
+ 形态来源:huaweicloud-devkit targets.ts codeartsWorkMcpSettingsFile + agents/codearts-work.ts:
4
+ - 只有用户级配置;平台迁移后新址 `~/.codearts/mcp/mcp_settings.json`,旧址
5
+ `~/.codeartswork/mcp/mcp_settings.json` 作为回退(新址目录存在就用新址)。
6
+ - 条目是 `mcp.<name> = {command: [exe, ...], environment: {...}}`——注意环境键名
7
+ 是 `environment`(与 opencode 的 `environment` 同名、与 mcpServers 的 `env` 不同)。
8
+ - 技能落 `~/.codeartswork/skills`。
9
+ """
10
+ import sys
11
+ from pathlib import Path
12
+
13
+ from vod_mcp import hosts as host_specs
14
+ from vod_mcp.host_adapters.base import merge_json_mcp, server_env, server_entry
15
+
16
+ HOST = "codeartswork"
17
+ SUPPORTS_REMOTE = True
18
+
19
+ _VERB = {"created": "写入", "updated": "更新", "unchanged": "跳过(已一致)"}
20
+
21
+
22
+ def _spec() -> dict:
23
+ return host_specs.load(HOST)
24
+
25
+
26
+ def _config_path() -> Path:
27
+ new_dir = Path.home() / ".codearts" / "mcp"
28
+ if new_dir.is_dir():
29
+ return new_dir / "mcp_settings.json"
30
+ return Path(_spec()["configPath"])
31
+
32
+
33
+ def skills_dir(args):
34
+ d = _spec().get("skillsDir")
35
+ return Path(d) if d else None
36
+
37
+
38
+ def install(args, packs):
39
+ conf = _config_path()
40
+ entry = {"command": [sys.executable, server_entry()],
41
+ "environment": server_env(args, packs)}
42
+ action = merge_json_mcp(conf, entry, section="mcp")
43
+ print(f"已{_VERB[action]} CodeArts Work 配置:{conf}(重启 CodeArts Work 会话生效)")
44
+ return conf
45
+
46
+
47
+ def install_remote(args, url, token):
48
+ conf = _config_path()
49
+ entry = {"url": url,
50
+ "environment": {"Authorization": f"Bearer {token}"}}
51
+ action = merge_json_mcp(conf, entry, section="mcp")
52
+ print(f"已{_VERB[action]} CodeArts Work 远程 MCP:{conf}(token 明文,注意文件权限)")
53
+ return conf
@@ -0,0 +1,153 @@
1
+ """Codex Desktop 宿主适配:个人市场(marketplace.json)+ 插件目录。
2
+
3
+ 形态来源:huaweicloud-devkit src/targets.ts(codexDesktopPluginsDir/codexMarketplacePath)
4
+ 与 agents/codex-desktop.ts:
5
+ - 插件目录 `~/plugins/<name>`,内含 `.mcp.json`(mcpServers)与
6
+ `.codex-plugin/plugin.json`(插件清单);技能在插件目录的 skills/ 下。
7
+ - Codex Desktop 通过 `~/.agents/plugins/marketplace.json` 发现插件:
8
+ `plugins[]` 里登记 `{name, source: {source: "local", path: "./plugins/<name>"}}`。
9
+
10
+ 纪律:
11
+ - marketplace.json 是共享文件:只摘/加自己的那一条,其它插件原样保留;首改落 .bak。
12
+ - 卸载 = 摘条目 + 删插件目录;不碰 `~/.agents/skills`、`~/.agents/commands` 等原生目录。
13
+ - 本机未装该宿主:形态按对表实现,doctor 标「未真机验证」。
14
+ """
15
+ import json
16
+ import shutil
17
+ import sys
18
+ from pathlib import Path
19
+
20
+ from vod_mcp import hosts as host_specs
21
+ from vod_mcp.host_adapters.base import server_env, server_entry
22
+
23
+ HOST = "codex-desktop"
24
+ SUPPORTS_REMOTE = True
25
+ NAME = "vod-devkit"
26
+
27
+
28
+ def _version() -> str:
29
+ try:
30
+ from vod_mcp import __version__
31
+ return str(__version__)
32
+ except Exception:
33
+ return "0.0.0"
34
+
35
+
36
+ def _spec() -> dict:
37
+ return host_specs.load(HOST)
38
+
39
+
40
+ def plugin_dir() -> Path:
41
+ return Path(_spec()["skillsDir"]).parent
42
+
43
+
44
+ def marketplace_path() -> Path:
45
+ return Path(_spec()["configPath"])
46
+
47
+
48
+ def _read_json(path: Path) -> dict:
49
+ if not path.exists():
50
+ return {}
51
+ raw = path.read_text(encoding="utf-8")
52
+ if not raw.strip():
53
+ return {}
54
+ try:
55
+ parsed = json.loads(raw)
56
+ except json.JSONDecodeError as e:
57
+ raise RuntimeError(f"{path} 不是合法 JSON({e.msg}),拒绝改动") from e
58
+ if not isinstance(parsed, dict):
59
+ raise RuntimeError(f"{path} 顶层不是对象,拒绝改动")
60
+ return parsed
61
+
62
+
63
+ def _write_json(path: Path, data: dict) -> None:
64
+ if path.exists():
65
+ shutil.copyfile(path, str(path) + ".bak")
66
+ path.parent.mkdir(parents=True, exist_ok=True)
67
+ path.write_text(json.dumps(data, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
68
+
69
+
70
+ def skills_dir(args):
71
+ return Path(_spec()["skillsDir"])
72
+
73
+
74
+ def _write_mcp_entry(entry: dict) -> Path:
75
+ pdir = plugin_dir()
76
+ pdir.mkdir(parents=True, exist_ok=True)
77
+ mcp_file = pdir / ".mcp.json"
78
+ mcp = _read_json(mcp_file)
79
+ servers = mcp.get("mcpServers")
80
+ if not isinstance(servers, dict):
81
+ servers = {}
82
+ servers[NAME] = entry
83
+ mcp["mcpServers"] = servers
84
+ _write_json(mcp_file, mcp)
85
+ return mcp_file
86
+
87
+
88
+ def _register_plugin(pdir: Path) -> None:
89
+ manifest = pdir / ".codex-plugin" / "plugin.json"
90
+ manifest.parent.mkdir(parents=True, exist_ok=True)
91
+ manifest.write_text(json.dumps({
92
+ "name": NAME, "version": _version(),
93
+ "description": "VOD 用户声音采集插件(MCP + 技能)",
94
+ "skills": ["skills"],
95
+ }, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
96
+
97
+ mp_path = marketplace_path()
98
+ mp = _read_json(mp_path)
99
+ if not mp.get("name"):
100
+ mp["name"] = "personal"
101
+ plugins = mp.get("plugins")
102
+ if not isinstance(plugins, list):
103
+ plugins = []
104
+ record = {"name": NAME, "source": {"source": "local", "path": f"./plugins/{NAME}"}}
105
+ replaced = False
106
+ for i, p in enumerate(plugins):
107
+ if isinstance(p, dict) and p.get("name") == NAME:
108
+ plugins[i] = record
109
+ replaced = True
110
+ break
111
+ if not replaced:
112
+ plugins.append(record)
113
+ mp["plugins"] = plugins
114
+ _write_json(mp_path, mp)
115
+ print(f"已写入 Codex Desktop 插件目录:{pdir}")
116
+ print(f"已在个人市场登记({('更新' if replaced else '新增')}):{mp_path}(重启 Codex Desktop 生效)")
117
+
118
+
119
+ def install(args, packs):
120
+ pdir = plugin_dir()
121
+ _write_mcp_entry({"command": sys.executable, "args": [server_entry()],
122
+ "env": server_env(args, packs)})
123
+ _register_plugin(pdir)
124
+ return marketplace_path()
125
+
126
+
127
+ def install_remote(args, url, token):
128
+ pdir = plugin_dir()
129
+ mcp_file = _write_mcp_entry({"url": url,
130
+ "headers": {"Authorization": f"Bearer {token}"}})
131
+ _register_plugin(pdir)
132
+ print(f"已写入 Codex Desktop 远程 MCP:{mcp_file}(token 明文,注意文件权限)")
133
+ return mcp_file
134
+
135
+
136
+ def uninstall() -> None:
137
+ """摘市场条目 + 删插件目录(只动自己的,不删宿主原生目录)。"""
138
+ mp_path = marketplace_path()
139
+ if mp_path.exists():
140
+ try:
141
+ mp = _read_json(mp_path)
142
+ except RuntimeError as e:
143
+ print(f"skip({e})")
144
+ return
145
+ plugins = [p for p in (mp.get("plugins") or [])
146
+ if not (isinstance(p, dict) and p.get("name") == NAME)]
147
+ mp["plugins"] = plugins
148
+ _write_json(mp_path, mp)
149
+ print(f"removed marketplace entry: {mp_path}")
150
+ pdir = plugin_dir()
151
+ if pdir.exists():
152
+ shutil.rmtree(pdir)
153
+ print("removed:", pdir)
@@ -4,6 +4,7 @@
4
4
  路径字面量);新增 Hermes 特定逻辑只改本模块。
5
5
  """
6
6
  import json
7
+ import shutil
7
8
  import subprocess
8
9
  import sys
9
10
  from pathlib import Path
@@ -21,6 +22,49 @@ def skills_dir(args):
21
22
  return Path(_SPEC["skillsDir"])
22
23
 
23
24
 
25
+ PLUGIN_NAME = "vod-feedback-router"
26
+
27
+
28
+ def _enabled_plugins() -> list:
29
+ """读 hermes 配置里的 plugins.enabled(CLI 输出是 "- name" 行)。"""
30
+ r = subprocess.run(["hermes", "config", "get", "plugins.enabled"],
31
+ capture_output=True, text=True, timeout=60)
32
+ if r.returncode != 0:
33
+ return []
34
+ out = []
35
+ for line in (r.stdout or "").splitlines():
36
+ line = line.strip()
37
+ if line.startswith("- "):
38
+ out.append(line[2:].strip())
39
+ elif line.startswith("-"):
40
+ out.append(line[1:].strip())
41
+ return [x for x in out if x]
42
+
43
+
44
+ def enable_plugin(name: str = PLUGIN_NAME) -> str:
45
+ """把路由插件加进 plugins.enabled(幂等)。返回 created / unchanged / skipped。
46
+
47
+ 只追加一个名字:读现有名单 → 追加 → `hermes config set plugins.enabled '[...]'`。
48
+ 不整文件改 config.yaml(用户可能手改过格式/注释),失败只提示不动。
49
+ """
50
+ import json as _json
51
+ if not shutil.which("hermes"):
52
+ print("提示:未找到 hermes CLI,路由插件需手动在 plugins.enabled 中加入 "
53
+ f"{name} 后生效")
54
+ return "skipped"
55
+ cur = _enabled_plugins()
56
+ if name in cur:
57
+ return "unchanged"
58
+ merged = cur + [name]
59
+ r = subprocess.run(["hermes", "config", "set", "plugins.enabled",
60
+ _json.dumps(merged)], capture_output=True, text=True, timeout=60)
61
+ if r.returncode != 0:
62
+ print("提示:自动启用路由插件失败(" + (r.stderr or r.stdout).strip()[:120]
63
+ + ");请手动把 " + name + " 加入 plugins.enabled")
64
+ return "skipped"
65
+ return "created"
66
+
67
+
24
68
  def install(args, packs: str) -> Path:
25
69
  """Hermes:官方途径 hermes mcp add(config.yaml mcp_servers)。"""
26
70
  conf = _MCP_DIR / "vod-devkit.json"
@@ -37,16 +81,17 @@ def install(args, packs: str) -> Path:
37
81
  *["--env"] + env_args, "--args", server_entry()],
38
82
  input="y\ny\n", capture_output=True, text=True)
39
83
  # D-hook-1:强制评估路由插件(pre_llm_call 确定性意图路由,业界 forced-eval 模式)
40
- import shutil as _sh
41
84
  plug_src = ROOT / "hermes-plugin" / "vod-feedback-router"
42
- plug_dst = Path.home() / ".hermes" / "plugins" / "vod-feedback-router"
85
+ plug_dst = Path.home() / ".hermes" / "plugins" / PLUGIN_NAME
43
86
  if plug_src.is_dir():
44
87
  if plug_dst.exists():
45
- _sh.rmtree(plug_dst)
46
- _sh.copytree(plug_src, plug_dst)
47
- print("已安装 vod-feedback-router 路由插件(~/.hermes/plugins/);"
48
- "需在 plugins.enabled 加入该名单后生效"
49
- "(hermes config set plugins.enabled ...,重启会话生效)")
88
+ shutil.rmtree(plug_dst)
89
+ shutil.copytree(plug_src, plug_dst)
90
+ state = enable_plugin()
91
+ verb = {"created": "已自动加入 plugins.enabled",
92
+ "unchanged": "已在 plugins.enabled 中",
93
+ "skipped": "未自动启用(见上方提示)"}[state]
94
+ print(f"已安装 {PLUGIN_NAME} 路由插件(~/.hermes/plugins/,{verb};重启会话生效)")
50
95
  if r.returncode == 0:
51
96
  print("已注册 Hermes MCP(hermes mcp list 可见;重启会话生效)")
52
97
  else:
@@ -0,0 +1,47 @@
1
+ """WorkBuddy 宿主适配(mcpServers.<name> 形态)。
2
+
3
+ 形态来源:huaweicloud-devkit targets.ts / agents/workbuddy.ts —— 用户级
4
+ `~/.workbuddy/mcp.json` 的 mcpServers 里一条,技能落 `~/.workbuddy/skills`。
5
+
6
+ 纪律:
7
+ - 只写 mcpServers.vod-devkit 一个键,宿主其它 server/用户键原样保留,首改落 .bak。
8
+ - 配置文件不是合法 JSON → 报错退出、字节不动(宁可不装不可装错)。
9
+ - 本机未装该宿主:配置形态按对表实现,doctor 会标「未真机验证」。
10
+ """
11
+ import sys
12
+ from pathlib import Path
13
+
14
+ from vod_mcp import hosts as host_specs
15
+ from vod_mcp.host_adapters.base import server_env, server_entry
16
+ from vod_mcp.host_adapters.generic import merge_mcp_servers
17
+
18
+ HOST = "workbuddy"
19
+ SUPPORTS_REMOTE = True
20
+
21
+ _VERB = {"created": "写入", "updated": "更新", "unchanged": "跳过(已一致)"}
22
+
23
+
24
+ def _spec() -> dict:
25
+ return host_specs.load(HOST)
26
+
27
+
28
+ def skills_dir(args):
29
+ d = _spec().get("skillsDir")
30
+ return Path(d) if d else None
31
+
32
+
33
+ def install(args, packs):
34
+ conf = Path(_spec()["configPath"])
35
+ entry = {"command": sys.executable, "args": [server_entry()],
36
+ "env": server_env(args, packs)}
37
+ action = merge_mcp_servers(conf, entry)
38
+ print(f"已{_VERB[action]} WorkBuddy 配置:{conf}(重启 WorkBuddy 会话生效)")
39
+ return conf
40
+
41
+
42
+ def install_remote(args, url, token):
43
+ conf = Path(_spec()["configPath"])
44
+ entry = {"url": url, "headers": {"Authorization": f"Bearer {token}"}}
45
+ action = merge_mcp_servers(conf, entry)
46
+ print(f"已{_VERB[action]} WorkBuddy 远程 MCP:{conf}(token 明文,注意文件权限)")
47
+ return conf
@@ -266,17 +266,19 @@ def search_products(params: dict) -> dict:
266
266
  continue
267
267
  seen.add(pid)
268
268
  cands.append({"id": pid, "name": h["product"],
269
- "score": round(min(1.0, len(h["alias"]) / max(len(query), 1)), 2)})
269
+ "score": round(min(1.0, len(h["alias"]) / max(len(query), 1)), 2),
270
+ "matchReason": f"alias:{h['alias']}"})
270
271
  if not cands: # 别名没命中:退回名字子串(用户可能打错/只说一半)
271
272
  q = query.lower()
272
273
  for item in catalog:
273
274
  name = str(item.get("name") or "")
274
275
  if q and (q in name.lower() or name.lower() in q):
275
- cands.append({"id": str(item.get("id")), "name": name, "score": 0.5})
276
+ cands.append({"id": str(item.get("id")), "name": name, "score": 0.5,
277
+ "matchReason": "name-substring"})
276
278
  if not cands: # 完全无关联词:给名录前 N 个当"可选项"(问用户用)
277
279
  for item in catalog[:limit]:
278
280
  cands.append({"id": str(item.get("id")), "name": str(item.get("name") or ""),
279
- "score": 0.0})
281
+ "score": 0.0, "matchReason": "catalog-default"})
280
282
  cands.sort(key=lambda c: (c["score"], len(c["name"])), reverse=True)
281
283
  return {"candidates": cands[:limit], "total": len(catalog)}
282
284
 
@@ -357,25 +359,35 @@ def _attribute_product(items: list, params: dict, client_info: dict | None = Non
357
359
  "ignored": None}
358
360
 
359
361
 
360
- def _require_product_or_ask(attr: dict, items: list) -> None:
362
+ def _require_product_or_ask(attr: dict, items: list, client_info: dict | None = None) -> None:
361
363
  """缺产品且用户没说不知道 → 可执行错误:先问一次(D-product-ask-1)。
362
364
 
363
365
  错误里带候选(来自原话关键词),模型照着问一句就能补齐;不是"参考文档"。
364
366
  """
365
367
  if attr.get("product"):
366
368
  return
369
+ # 追问轮次上限(2026-11-12 评审采纳):同一会话最多追问 2 次,之后明确终止——
370
+ # 避免"用户连续给两个都查不到的名字"时模型无限重问。
371
+ mem = _memory_get(client_info)
372
+ fails = int(mem.get("ask_failures") or 0) + 1
373
+ _memory_put(client_info, ask_failures=fails)
374
+ stop = fails > 2
375
+ tail = "(已追问 2 次仍未确认:别再问了,直接告诉用户这条反馈因为没有产品归属而不提交)"
376
+
367
377
  if attr.get("unmatched_answer"):
368
378
  cands = attr.get("candidates") or []
369
379
  hint = "、".join(f"{c['name']}({c['id']})" for c in cands) or "(名录为空)"
370
380
  raise ToolError(
371
381
  f"用户说的产品「{attr['rawText']}」不在产品名录里,不能按它提交。"
372
- f"请按名录再确认一次是哪一个:{hint};用户仍说不出来就说明这条先不提交。",
382
+ f"请按名录再确认一次是哪一个:{hint};用户仍说不出来就说明这条先不提交。"
383
+ + (tail if stop else ""),
373
384
  code=_UNRESOLVED_CODE)
374
385
  if attr.get("not_specified"):
375
386
  raise ToolError(
376
387
  "用户没有提供产品,这条反馈**不能提交**:请告诉用户「没有产品归属的反馈我不提交,"
377
388
  "因为不知道要转给哪个产品团队」,并请他补充是哪个产品;他仍不想说就说明这条先不提交。"
378
- f"可选候选:{'、'.join(c['name'] + '(' + str(c['id']) + ')' for c in search_products({'query': '\n'.join(x[2] for x in items), 'limit': 5})['candidates'])}",
389
+ f"可选候选:{'、'.join(c['name'] + '(' + str(c['id']) + ')' for c in search_products({'query': '\n'.join(x[2] for x in items), 'limit': 5})['candidates'])}"
390
+ + (tail if stop else ""),
379
391
  code=_UNRESOLVED_CODE)
380
392
  if os.environ.get("VOD_ALLOW_UNKNOWN_PRODUCT") == "1":
381
393
  # 旧客户端兼容(业界口径:可选字段 + 明确默认值,不做破坏性变更):
@@ -431,6 +443,8 @@ def _remember_attribution(result: dict, client_info: dict | None = None) -> None
431
443
  """
432
444
  # 会话记忆(D-product-ask-1):只记「有证据/用户明确回答/用户说不知道」三种
433
445
  src = result.get("source")
446
+ if result.get("product"):
447
+ _memory_put(client_info, ask_failures=0)
434
448
  if src in ("user_input", "user_answer"):
435
449
  _memory_put(client_info, product=result.get("product"),
436
450
  productName=result.get("productName"),
@@ -756,7 +770,7 @@ def submit_voices(params: dict, client_info: dict | None = None,
756
770
  code=-32012)
757
771
 
758
772
  # 缺产品且用户没说不知道 → 可执行错误(先问一次),不许裸提交 UNKNOWN
759
- _require_product_or_ask(attr, items)
773
+ _require_product_or_ask(attr, items, client_info)
760
774
  # ---- 主路径:囤积端点批式提交 ----
761
775
  # 分类白名单按产品取(引擎 ?productId= 下发);product 非数字 id 时取不到→不过滤
762
776
  allowed_tags = _allowed_tags(product)
@@ -5,7 +5,7 @@
5
5
  2. 外部无 DB 直连路径(护栏 deny 兜底)
6
6
  3. 任务 ID 是唯一对账主键,写类工具返回一律携带
7
7
  """
8
- __version__ = "0.5.1"
8
+ __version__ = "0.5.3"
9
9
  # 默认上游:VOD 测试环境。外部用户本机无 VOD,回环默认值=装完即坏;
10
10
  # 生产地址定型后只改这一处(tools.py 与 bin/vod-devkit 共用本常量)。
11
11
  DEFAULT_JAVA_BASE = "https://vod-dev.topxtopx.com"
@@ -5,14 +5,20 @@
5
5
 
6
6
  REGISTRY 里的模块必须实现 protocol 的三件事:install / install_remote / skills_dir。
7
7
  """
8
- from vod_mcp.host_adapters import codearts, codex, dsh, generic, hermes, opencode
8
+ from vod_mcp.host_adapters import (atomcode, codearts, codeartswork, codex,
9
+ codex_desktop, dsh, generic, hermes, opencode,
10
+ workbuddy)
9
11
 
10
12
  REGISTRY = {
11
13
  "hermes": hermes,
12
14
  "opencode": opencode,
13
15
  "codeartsdoer": codearts,
16
+ "codeartswork": codeartswork,
14
17
  "codex": codex,
18
+ "codex-desktop": codex_desktop,
15
19
  "dsh": dsh,
20
+ "workbuddy": workbuddy,
21
+ "atomcode": atomcode,
16
22
  "generic": generic,
17
23
  }
18
24
 
@@ -0,0 +1,53 @@
1
+ """AtomCode 宿主适配(mcpServers.<name> 形态,配置根可由 ATOMCODE_HOME 覆盖)。
2
+
3
+ 形态来源:huaweicloud-devkit targets.ts atomcodeHome/atomcodeMcpConfigFile ——
4
+ `${ATOMCODE_HOME:-~/.atomcode}/mcp.json` 的 mcpServers,技能落 <home>/skills。
5
+
6
+ 刻意不装宿主 hooks.json 的 pre_tool_use 遥测 hook(上游那样做是为了自己的埋点);
7
+ 本插件不引入遥测。
8
+ """
9
+ import os
10
+ import sys
11
+ from pathlib import Path
12
+
13
+ from vod_mcp.host_adapters.base import server_env, server_entry
14
+ from vod_mcp.host_adapters.generic import merge_mcp_servers
15
+
16
+ HOST = "atomcode"
17
+ SUPPORTS_REMOTE = True
18
+
19
+ _VERB = {"created": "写入", "updated": "更新", "unchanged": "跳过(已一致)"}
20
+
21
+
22
+ def _home() -> Path:
23
+ """调用期读 env(测试/多宿主环境可重定向,禁止 import 期求值)。"""
24
+ raw = (os.environ.get("ATOMCODE_HOME") or "").strip()
25
+ return Path(raw).expanduser() if raw else Path.home() / ".atomcode"
26
+
27
+
28
+ def _spec() -> dict:
29
+ return {
30
+ "configPath": _home() / "mcp.json",
31
+ "skillsDir": _home() / "skills",
32
+ }
33
+
34
+
35
+ def skills_dir(args):
36
+ return _spec()["skillsDir"]
37
+
38
+
39
+ def install(args, packs):
40
+ spec = _spec()
41
+ entry = {"command": sys.executable, "args": [server_entry()],
42
+ "env": server_env(args, packs)}
43
+ action = merge_mcp_servers(spec["configPath"], entry)
44
+ print(f"已{_VERB[action]} AtomCode 配置:{spec['configPath']}(重启 AtomCode 会话生效)")
45
+ return spec["configPath"]
46
+
47
+
48
+ def install_remote(args, url, token):
49
+ conf = _spec()["configPath"]
50
+ entry = {"url": url, "headers": {"Authorization": f"Bearer {token}"}}
51
+ action = merge_mcp_servers(conf, entry)
52
+ print(f"已{_VERB[action]} AtomCode 远程 MCP:{conf}(token 明文,注意文件权限)")
53
+ return conf
@@ -0,0 +1,53 @@
1
+ """CodeArts Work(CodeArts Space)宿主适配。
2
+
3
+ 形态来源:huaweicloud-devkit targets.ts codeartsWorkMcpSettingsFile + agents/codearts-work.ts:
4
+ - 只有用户级配置;平台迁移后新址 `~/.codearts/mcp/mcp_settings.json`,旧址
5
+ `~/.codeartswork/mcp/mcp_settings.json` 作为回退(新址目录存在就用新址)。
6
+ - 条目是 `mcp.<name> = {command: [exe, ...], environment: {...}}`——注意环境键名
7
+ 是 `environment`(与 opencode 的 `environment` 同名、与 mcpServers 的 `env` 不同)。
8
+ - 技能落 `~/.codeartswork/skills`。
9
+ """
10
+ import sys
11
+ from pathlib import Path
12
+
13
+ from vod_mcp import hosts as host_specs
14
+ from vod_mcp.host_adapters.base import merge_json_mcp, server_env, server_entry
15
+
16
+ HOST = "codeartswork"
17
+ SUPPORTS_REMOTE = True
18
+
19
+ _VERB = {"created": "写入", "updated": "更新", "unchanged": "跳过(已一致)"}
20
+
21
+
22
+ def _spec() -> dict:
23
+ return host_specs.load(HOST)
24
+
25
+
26
+ def _config_path() -> Path:
27
+ new_dir = Path.home() / ".codearts" / "mcp"
28
+ if new_dir.is_dir():
29
+ return new_dir / "mcp_settings.json"
30
+ return Path(_spec()["configPath"])
31
+
32
+
33
+ def skills_dir(args):
34
+ d = _spec().get("skillsDir")
35
+ return Path(d) if d else None
36
+
37
+
38
+ def install(args, packs):
39
+ conf = _config_path()
40
+ entry = {"command": [sys.executable, server_entry()],
41
+ "environment": server_env(args, packs)}
42
+ action = merge_json_mcp(conf, entry, section="mcp")
43
+ print(f"已{_VERB[action]} CodeArts Work 配置:{conf}(重启 CodeArts Work 会话生效)")
44
+ return conf
45
+
46
+
47
+ def install_remote(args, url, token):
48
+ conf = _config_path()
49
+ entry = {"url": url,
50
+ "environment": {"Authorization": f"Bearer {token}"}}
51
+ action = merge_json_mcp(conf, entry, section="mcp")
52
+ print(f"已{_VERB[action]} CodeArts Work 远程 MCP:{conf}(token 明文,注意文件权限)")
53
+ return conf
@@ -0,0 +1,153 @@
1
+ """Codex Desktop 宿主适配:个人市场(marketplace.json)+ 插件目录。
2
+
3
+ 形态来源:huaweicloud-devkit src/targets.ts(codexDesktopPluginsDir/codexMarketplacePath)
4
+ 与 agents/codex-desktop.ts:
5
+ - 插件目录 `~/plugins/<name>`,内含 `.mcp.json`(mcpServers)与
6
+ `.codex-plugin/plugin.json`(插件清单);技能在插件目录的 skills/ 下。
7
+ - Codex Desktop 通过 `~/.agents/plugins/marketplace.json` 发现插件:
8
+ `plugins[]` 里登记 `{name, source: {source: "local", path: "./plugins/<name>"}}`。
9
+
10
+ 纪律:
11
+ - marketplace.json 是共享文件:只摘/加自己的那一条,其它插件原样保留;首改落 .bak。
12
+ - 卸载 = 摘条目 + 删插件目录;不碰 `~/.agents/skills`、`~/.agents/commands` 等原生目录。
13
+ - 本机未装该宿主:形态按对表实现,doctor 标「未真机验证」。
14
+ """
15
+ import json
16
+ import shutil
17
+ import sys
18
+ from pathlib import Path
19
+
20
+ from vod_mcp import hosts as host_specs
21
+ from vod_mcp.host_adapters.base import server_env, server_entry
22
+
23
+ HOST = "codex-desktop"
24
+ SUPPORTS_REMOTE = True
25
+ NAME = "vod-devkit"
26
+
27
+
28
+ def _version() -> str:
29
+ try:
30
+ from vod_mcp import __version__
31
+ return str(__version__)
32
+ except Exception:
33
+ return "0.0.0"
34
+
35
+
36
+ def _spec() -> dict:
37
+ return host_specs.load(HOST)
38
+
39
+
40
+ def plugin_dir() -> Path:
41
+ return Path(_spec()["skillsDir"]).parent
42
+
43
+
44
+ def marketplace_path() -> Path:
45
+ return Path(_spec()["configPath"])
46
+
47
+
48
+ def _read_json(path: Path) -> dict:
49
+ if not path.exists():
50
+ return {}
51
+ raw = path.read_text(encoding="utf-8")
52
+ if not raw.strip():
53
+ return {}
54
+ try:
55
+ parsed = json.loads(raw)
56
+ except json.JSONDecodeError as e:
57
+ raise RuntimeError(f"{path} 不是合法 JSON({e.msg}),拒绝改动") from e
58
+ if not isinstance(parsed, dict):
59
+ raise RuntimeError(f"{path} 顶层不是对象,拒绝改动")
60
+ return parsed
61
+
62
+
63
+ def _write_json(path: Path, data: dict) -> None:
64
+ if path.exists():
65
+ shutil.copyfile(path, str(path) + ".bak")
66
+ path.parent.mkdir(parents=True, exist_ok=True)
67
+ path.write_text(json.dumps(data, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
68
+
69
+
70
+ def skills_dir(args):
71
+ return Path(_spec()["skillsDir"])
72
+
73
+
74
+ def _write_mcp_entry(entry: dict) -> Path:
75
+ pdir = plugin_dir()
76
+ pdir.mkdir(parents=True, exist_ok=True)
77
+ mcp_file = pdir / ".mcp.json"
78
+ mcp = _read_json(mcp_file)
79
+ servers = mcp.get("mcpServers")
80
+ if not isinstance(servers, dict):
81
+ servers = {}
82
+ servers[NAME] = entry
83
+ mcp["mcpServers"] = servers
84
+ _write_json(mcp_file, mcp)
85
+ return mcp_file
86
+
87
+
88
+ def _register_plugin(pdir: Path) -> None:
89
+ manifest = pdir / ".codex-plugin" / "plugin.json"
90
+ manifest.parent.mkdir(parents=True, exist_ok=True)
91
+ manifest.write_text(json.dumps({
92
+ "name": NAME, "version": _version(),
93
+ "description": "VOD 用户声音采集插件(MCP + 技能)",
94
+ "skills": ["skills"],
95
+ }, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
96
+
97
+ mp_path = marketplace_path()
98
+ mp = _read_json(mp_path)
99
+ if not mp.get("name"):
100
+ mp["name"] = "personal"
101
+ plugins = mp.get("plugins")
102
+ if not isinstance(plugins, list):
103
+ plugins = []
104
+ record = {"name": NAME, "source": {"source": "local", "path": f"./plugins/{NAME}"}}
105
+ replaced = False
106
+ for i, p in enumerate(plugins):
107
+ if isinstance(p, dict) and p.get("name") == NAME:
108
+ plugins[i] = record
109
+ replaced = True
110
+ break
111
+ if not replaced:
112
+ plugins.append(record)
113
+ mp["plugins"] = plugins
114
+ _write_json(mp_path, mp)
115
+ print(f"已写入 Codex Desktop 插件目录:{pdir}")
116
+ print(f"已在个人市场登记({('更新' if replaced else '新增')}):{mp_path}(重启 Codex Desktop 生效)")
117
+
118
+
119
+ def install(args, packs):
120
+ pdir = plugin_dir()
121
+ _write_mcp_entry({"command": sys.executable, "args": [server_entry()],
122
+ "env": server_env(args, packs)})
123
+ _register_plugin(pdir)
124
+ return marketplace_path()
125
+
126
+
127
+ def install_remote(args, url, token):
128
+ pdir = plugin_dir()
129
+ mcp_file = _write_mcp_entry({"url": url,
130
+ "headers": {"Authorization": f"Bearer {token}"}})
131
+ _register_plugin(pdir)
132
+ print(f"已写入 Codex Desktop 远程 MCP:{mcp_file}(token 明文,注意文件权限)")
133
+ return mcp_file
134
+
135
+
136
+ def uninstall() -> None:
137
+ """摘市场条目 + 删插件目录(只动自己的,不删宿主原生目录)。"""
138
+ mp_path = marketplace_path()
139
+ if mp_path.exists():
140
+ try:
141
+ mp = _read_json(mp_path)
142
+ except RuntimeError as e:
143
+ print(f"skip({e})")
144
+ return
145
+ plugins = [p for p in (mp.get("plugins") or [])
146
+ if not (isinstance(p, dict) and p.get("name") == NAME)]
147
+ mp["plugins"] = plugins
148
+ _write_json(mp_path, mp)
149
+ print(f"removed marketplace entry: {mp_path}")
150
+ pdir = plugin_dir()
151
+ if pdir.exists():
152
+ shutil.rmtree(pdir)
153
+ print("removed:", pdir)
@@ -4,6 +4,7 @@
4
4
  路径字面量);新增 Hermes 特定逻辑只改本模块。
5
5
  """
6
6
  import json
7
+ import shutil
7
8
  import subprocess
8
9
  import sys
9
10
  from pathlib import Path
@@ -21,6 +22,49 @@ def skills_dir(args):
21
22
  return Path(_SPEC["skillsDir"])
22
23
 
23
24
 
25
+ PLUGIN_NAME = "vod-feedback-router"
26
+
27
+
28
+ def _enabled_plugins() -> list:
29
+ """读 hermes 配置里的 plugins.enabled(CLI 输出是 "- name" 行)。"""
30
+ r = subprocess.run(["hermes", "config", "get", "plugins.enabled"],
31
+ capture_output=True, text=True, timeout=60)
32
+ if r.returncode != 0:
33
+ return []
34
+ out = []
35
+ for line in (r.stdout or "").splitlines():
36
+ line = line.strip()
37
+ if line.startswith("- "):
38
+ out.append(line[2:].strip())
39
+ elif line.startswith("-"):
40
+ out.append(line[1:].strip())
41
+ return [x for x in out if x]
42
+
43
+
44
+ def enable_plugin(name: str = PLUGIN_NAME) -> str:
45
+ """把路由插件加进 plugins.enabled(幂等)。返回 created / unchanged / skipped。
46
+
47
+ 只追加一个名字:读现有名单 → 追加 → `hermes config set plugins.enabled '[...]'`。
48
+ 不整文件改 config.yaml(用户可能手改过格式/注释),失败只提示不动。
49
+ """
50
+ import json as _json
51
+ if not shutil.which("hermes"):
52
+ print("提示:未找到 hermes CLI,路由插件需手动在 plugins.enabled 中加入 "
53
+ f"{name} 后生效")
54
+ return "skipped"
55
+ cur = _enabled_plugins()
56
+ if name in cur:
57
+ return "unchanged"
58
+ merged = cur + [name]
59
+ r = subprocess.run(["hermes", "config", "set", "plugins.enabled",
60
+ _json.dumps(merged)], capture_output=True, text=True, timeout=60)
61
+ if r.returncode != 0:
62
+ print("提示:自动启用路由插件失败(" + (r.stderr or r.stdout).strip()[:120]
63
+ + ");请手动把 " + name + " 加入 plugins.enabled")
64
+ return "skipped"
65
+ return "created"
66
+
67
+
24
68
  def install(args, packs: str) -> Path:
25
69
  """Hermes:官方途径 hermes mcp add(config.yaml mcp_servers)。"""
26
70
  conf = _MCP_DIR / "vod-devkit.json"
@@ -37,16 +81,17 @@ def install(args, packs: str) -> Path:
37
81
  *["--env"] + env_args, "--args", server_entry()],
38
82
  input="y\ny\n", capture_output=True, text=True)
39
83
  # D-hook-1:强制评估路由插件(pre_llm_call 确定性意图路由,业界 forced-eval 模式)
40
- import shutil as _sh
41
84
  plug_src = ROOT / "hermes-plugin" / "vod-feedback-router"
42
- plug_dst = Path.home() / ".hermes" / "plugins" / "vod-feedback-router"
85
+ plug_dst = Path.home() / ".hermes" / "plugins" / PLUGIN_NAME
43
86
  if plug_src.is_dir():
44
87
  if plug_dst.exists():
45
- _sh.rmtree(plug_dst)
46
- _sh.copytree(plug_src, plug_dst)
47
- print("已安装 vod-feedback-router 路由插件(~/.hermes/plugins/);"
48
- "需在 plugins.enabled 加入该名单后生效"
49
- "(hermes config set plugins.enabled ...,重启会话生效)")
88
+ shutil.rmtree(plug_dst)
89
+ shutil.copytree(plug_src, plug_dst)
90
+ state = enable_plugin()
91
+ verb = {"created": "已自动加入 plugins.enabled",
92
+ "unchanged": "已在 plugins.enabled 中",
93
+ "skipped": "未自动启用(见上方提示)"}[state]
94
+ print(f"已安装 {PLUGIN_NAME} 路由插件(~/.hermes/plugins/,{verb};重启会话生效)")
50
95
  if r.returncode == 0:
51
96
  print("已注册 Hermes MCP(hermes mcp list 可见;重启会话生效)")
52
97
  else:
@@ -0,0 +1,47 @@
1
+ """WorkBuddy 宿主适配(mcpServers.<name> 形态)。
2
+
3
+ 形态来源:huaweicloud-devkit targets.ts / agents/workbuddy.ts —— 用户级
4
+ `~/.workbuddy/mcp.json` 的 mcpServers 里一条,技能落 `~/.workbuddy/skills`。
5
+
6
+ 纪律:
7
+ - 只写 mcpServers.vod-devkit 一个键,宿主其它 server/用户键原样保留,首改落 .bak。
8
+ - 配置文件不是合法 JSON → 报错退出、字节不动(宁可不装不可装错)。
9
+ - 本机未装该宿主:配置形态按对表实现,doctor 会标「未真机验证」。
10
+ """
11
+ import sys
12
+ from pathlib import Path
13
+
14
+ from vod_mcp import hosts as host_specs
15
+ from vod_mcp.host_adapters.base import server_env, server_entry
16
+ from vod_mcp.host_adapters.generic import merge_mcp_servers
17
+
18
+ HOST = "workbuddy"
19
+ SUPPORTS_REMOTE = True
20
+
21
+ _VERB = {"created": "写入", "updated": "更新", "unchanged": "跳过(已一致)"}
22
+
23
+
24
+ def _spec() -> dict:
25
+ return host_specs.load(HOST)
26
+
27
+
28
+ def skills_dir(args):
29
+ d = _spec().get("skillsDir")
30
+ return Path(d) if d else None
31
+
32
+
33
+ def install(args, packs):
34
+ conf = Path(_spec()["configPath"])
35
+ entry = {"command": sys.executable, "args": [server_entry()],
36
+ "env": server_env(args, packs)}
37
+ action = merge_mcp_servers(conf, entry)
38
+ print(f"已{_VERB[action]} WorkBuddy 配置:{conf}(重启 WorkBuddy 会话生效)")
39
+ return conf
40
+
41
+
42
+ def install_remote(args, url, token):
43
+ conf = Path(_spec()["configPath"])
44
+ entry = {"url": url, "headers": {"Authorization": f"Bearer {token}"}}
45
+ action = merge_mcp_servers(conf, entry)
46
+ print(f"已{_VERB[action]} WorkBuddy 远程 MCP:{conf}(token 明文,注意文件权限)")
47
+ return conf
package/vod_mcp/tools.py CHANGED
@@ -266,17 +266,19 @@ def search_products(params: dict) -> dict:
266
266
  continue
267
267
  seen.add(pid)
268
268
  cands.append({"id": pid, "name": h["product"],
269
- "score": round(min(1.0, len(h["alias"]) / max(len(query), 1)), 2)})
269
+ "score": round(min(1.0, len(h["alias"]) / max(len(query), 1)), 2),
270
+ "matchReason": f"alias:{h['alias']}"})
270
271
  if not cands: # 别名没命中:退回名字子串(用户可能打错/只说一半)
271
272
  q = query.lower()
272
273
  for item in catalog:
273
274
  name = str(item.get("name") or "")
274
275
  if q and (q in name.lower() or name.lower() in q):
275
- cands.append({"id": str(item.get("id")), "name": name, "score": 0.5})
276
+ cands.append({"id": str(item.get("id")), "name": name, "score": 0.5,
277
+ "matchReason": "name-substring"})
276
278
  if not cands: # 完全无关联词:给名录前 N 个当"可选项"(问用户用)
277
279
  for item in catalog[:limit]:
278
280
  cands.append({"id": str(item.get("id")), "name": str(item.get("name") or ""),
279
- "score": 0.0})
281
+ "score": 0.0, "matchReason": "catalog-default"})
280
282
  cands.sort(key=lambda c: (c["score"], len(c["name"])), reverse=True)
281
283
  return {"candidates": cands[:limit], "total": len(catalog)}
282
284
 
@@ -357,25 +359,35 @@ def _attribute_product(items: list, params: dict, client_info: dict | None = Non
357
359
  "ignored": None}
358
360
 
359
361
 
360
- def _require_product_or_ask(attr: dict, items: list) -> None:
362
+ def _require_product_or_ask(attr: dict, items: list, client_info: dict | None = None) -> None:
361
363
  """缺产品且用户没说不知道 → 可执行错误:先问一次(D-product-ask-1)。
362
364
 
363
365
  错误里带候选(来自原话关键词),模型照着问一句就能补齐;不是"参考文档"。
364
366
  """
365
367
  if attr.get("product"):
366
368
  return
369
+ # 追问轮次上限(2026-11-12 评审采纳):同一会话最多追问 2 次,之后明确终止——
370
+ # 避免"用户连续给两个都查不到的名字"时模型无限重问。
371
+ mem = _memory_get(client_info)
372
+ fails = int(mem.get("ask_failures") or 0) + 1
373
+ _memory_put(client_info, ask_failures=fails)
374
+ stop = fails > 2
375
+ tail = "(已追问 2 次仍未确认:别再问了,直接告诉用户这条反馈因为没有产品归属而不提交)"
376
+
367
377
  if attr.get("unmatched_answer"):
368
378
  cands = attr.get("candidates") or []
369
379
  hint = "、".join(f"{c['name']}({c['id']})" for c in cands) or "(名录为空)"
370
380
  raise ToolError(
371
381
  f"用户说的产品「{attr['rawText']}」不在产品名录里,不能按它提交。"
372
- f"请按名录再确认一次是哪一个:{hint};用户仍说不出来就说明这条先不提交。",
382
+ f"请按名录再确认一次是哪一个:{hint};用户仍说不出来就说明这条先不提交。"
383
+ + (tail if stop else ""),
373
384
  code=_UNRESOLVED_CODE)
374
385
  if attr.get("not_specified"):
375
386
  raise ToolError(
376
387
  "用户没有提供产品,这条反馈**不能提交**:请告诉用户「没有产品归属的反馈我不提交,"
377
388
  "因为不知道要转给哪个产品团队」,并请他补充是哪个产品;他仍不想说就说明这条先不提交。"
378
- f"可选候选:{'、'.join(c['name'] + '(' + str(c['id']) + ')' for c in search_products({'query': '\n'.join(x[2] for x in items), 'limit': 5})['candidates'])}",
389
+ f"可选候选:{'、'.join(c['name'] + '(' + str(c['id']) + ')' for c in search_products({'query': '\n'.join(x[2] for x in items), 'limit': 5})['candidates'])}"
390
+ + (tail if stop else ""),
379
391
  code=_UNRESOLVED_CODE)
380
392
  if os.environ.get("VOD_ALLOW_UNKNOWN_PRODUCT") == "1":
381
393
  # 旧客户端兼容(业界口径:可选字段 + 明确默认值,不做破坏性变更):
@@ -431,6 +443,8 @@ def _remember_attribution(result: dict, client_info: dict | None = None) -> None
431
443
  """
432
444
  # 会话记忆(D-product-ask-1):只记「有证据/用户明确回答/用户说不知道」三种
433
445
  src = result.get("source")
446
+ if result.get("product"):
447
+ _memory_put(client_info, ask_failures=0)
434
448
  if src in ("user_input", "user_answer"):
435
449
  _memory_put(client_info, product=result.get("product"),
436
450
  productName=result.get("productName"),
@@ -756,7 +770,7 @@ def submit_voices(params: dict, client_info: dict | None = None,
756
770
  code=-32012)
757
771
 
758
772
  # 缺产品且用户没说不知道 → 可执行错误(先问一次),不许裸提交 UNKNOWN
759
- _require_product_or_ask(attr, items)
773
+ _require_product_or_ask(attr, items, client_info)
760
774
  # ---- 主路径:囤积端点批式提交 ----
761
775
  # 分类白名单按产品取(引擎 ?productId= 下发);product 非数字 id 时取不到→不过滤
762
776
  allowed_tags = _allowed_tags(product)