vod-devkit 0.5.0 → 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.
- package/CHANGELOG.md +27 -0
- package/QUICKSTART.md +1 -1
- package/README.en.md +190 -57
- package/README.md +194 -75
- package/bin/vod-devkit +436 -426
- package/contract/tools.schema.json +78 -8
- package/integrations/codeartsdoer/host.json +11 -0
- package/package.json +4 -1
- package/plugins/vod-devkit/.codex-plugin/plugin.json +1 -1
- package/plugins/vod-devkit/build-info.json +3 -3
- package/plugins/vod-devkit/skills/vod-core/SKILL.md +12 -4
- package/plugins/vod-devkit/skills/vod-core/references/acceptance-criteria.md +9 -0
- package/plugins/vod-devkit/skills/vod-core/references/verification-method.md +29 -0
- package/plugins/vod-devkit/skills/vod-feedback-collect/SKILL.md +57 -11
- package/plugins/vod-devkit/skills/vod-feedback-collect/references/acceptance-criteria.md +28 -0
- package/plugins/vod-devkit/skills/vod-feedback-collect/references/verification-method.md +31 -0
- package/plugins/vod-devkit/skills/vod-problem-classification-rules/SKILL.md +3 -1
- package/plugins/vod-devkit/skills/vod-scoring-rules/SKILL.md +22 -1
- package/plugins/vod-devkit/vod_mcp/__init__.py +1 -1
- package/plugins/vod-devkit/vod_mcp/attribution.py +378 -0
- package/plugins/vod-devkit/vod_mcp/host_adapters/__init__.py +26 -0
- package/plugins/vod-devkit/vod_mcp/host_adapters/base.py +73 -0
- package/plugins/vod-devkit/vod_mcp/host_adapters/codearts.py +57 -0
- package/plugins/vod-devkit/vod_mcp/host_adapters/codex.py +209 -0
- package/plugins/vod-devkit/vod_mcp/host_adapters/dsh.py +176 -0
- package/plugins/vod-devkit/vod_mcp/host_adapters/generic.py +132 -0
- package/plugins/vod-devkit/vod_mcp/host_adapters/hermes.py +76 -0
- package/plugins/vod-devkit/vod_mcp/host_adapters/opencode.py +52 -0
- package/plugins/vod-devkit/vod_mcp/hosts.py +20 -0
- package/plugins/vod-devkit/vod_mcp/packs.py +3 -1
- package/plugins/vod-devkit/vod_mcp/payload.py +174 -0
- package/plugins/vod-devkit/vod_mcp/server.py +13 -1
- package/plugins/vod-devkit/vod_mcp/tools.py +385 -46
- package/plugins/vod-devkit/vod_mcp/update_check.py +31 -3
- package/skills/vod-core/SKILL.md +12 -4
- package/skills/vod-core/references/acceptance-criteria.md +9 -0
- package/skills/vod-core/references/verification-method.md +29 -0
- package/skills/vod-feedback-collect/SKILL.md +57 -11
- package/skills/vod-feedback-collect/references/acceptance-criteria.md +28 -0
- package/skills/vod-feedback-collect/references/verification-method.md +31 -0
- package/skills/vod-problem-classification-rules/SKILL.md +3 -1
- package/skills/vod-scoring-rules/SKILL.md +22 -1
- package/vod_mcp/__init__.py +1 -1
- package/vod_mcp/attribution.py +378 -0
- package/vod_mcp/host_adapters/__init__.py +26 -0
- package/vod_mcp/host_adapters/__pycache__/__init__.cpython-314.pyc +0 -0
- package/vod_mcp/host_adapters/__pycache__/base.cpython-314.pyc +0 -0
- package/vod_mcp/host_adapters/__pycache__/codearts.cpython-314.pyc +0 -0
- package/vod_mcp/host_adapters/__pycache__/codex.cpython-314.pyc +0 -0
- package/vod_mcp/host_adapters/__pycache__/dsh.cpython-314.pyc +0 -0
- package/vod_mcp/host_adapters/__pycache__/generic.cpython-314.pyc +0 -0
- package/vod_mcp/host_adapters/__pycache__/hermes.cpython-314.pyc +0 -0
- package/vod_mcp/host_adapters/__pycache__/opencode.cpython-314.pyc +0 -0
- package/vod_mcp/host_adapters/base.py +73 -0
- package/vod_mcp/host_adapters/codearts.py +57 -0
- package/vod_mcp/host_adapters/codex.py +209 -0
- package/vod_mcp/host_adapters/dsh.py +176 -0
- package/vod_mcp/host_adapters/generic.py +132 -0
- package/vod_mcp/host_adapters/hermes.py +76 -0
- package/vod_mcp/host_adapters/opencode.py +52 -0
- package/vod_mcp/hosts.py +20 -0
- package/vod_mcp/packs.py +3 -1
- package/vod_mcp/payload.py +174 -0
- package/vod_mcp/server.py +13 -1
- package/vod_mcp/tools.py +385 -46
- package/vod_mcp/update_check.py +31 -3
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
"""Codex 宿主适配(D-codex-agents-1 终态):原生插件路径 + 历史遗留清理。"""
|
|
2
|
+
import json
|
|
3
|
+
import shutil
|
|
4
|
+
import subprocess
|
|
5
|
+
import sys
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
from vod_mcp import hosts as host_specs
|
|
9
|
+
from vod_mcp.host_adapters.base import ROOT
|
|
10
|
+
|
|
11
|
+
HOST = "codex"
|
|
12
|
+
SUPPORTS_REMOTE = True
|
|
13
|
+
_AGENTS_MARKER_BEGIN = "<!-- vod-devkit:feedback-skill BEGIN -->"
|
|
14
|
+
# 更早一代注入(2026-11-05 之前):AGENTS.md 里教模型"立即提交 confirmed=true、
|
|
15
|
+
# 不要追问、归因由安装绑定"——与现行红线(先征得同意、归因从原话解析)矛盾,
|
|
16
|
+
# 且 1705 个历史会话带着它跑(实测)。清理逻辑必须认这个标记,否则残留继续生效。
|
|
17
|
+
_LEGACY_ONE_LINER = "<!-- vod-submit-one-liner -->"
|
|
18
|
+
_AGENTS_MARKER_END = "<!-- vod-devkit:feedback-skill END -->"
|
|
19
|
+
_SPEC = host_specs.load("codex")
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def skills_dir(args):
|
|
23
|
+
d = _SPEC.get("skillsDir")
|
|
24
|
+
return Path(d) if d else None
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def strip_codex_vod_blocks(text: str) -> str:
|
|
28
|
+
"""幂等剥离:删除 [mcp_servers.vod-devkit] **及其全部子表**。
|
|
29
|
+
|
|
30
|
+
不能用行内正则截断式剥离——args = ["…"] 行内的 '[' 会让正则提前断块。
|
|
31
|
+
也不能只删父表(旧实现):留下 [mcp_servers.vod-devkit.env] 在 TOML
|
|
32
|
+
语义里会重建父表,装出一个没有 command 的假 server。扫描/删除语义
|
|
33
|
+
统一在 vod_mcp/config_forms.py(单一实现),形态不受支持时抛
|
|
34
|
+
RuntimeError——调用方必须原样放弃修改。
|
|
35
|
+
"""
|
|
36
|
+
from vod_mcp import config_forms as cf
|
|
37
|
+
try:
|
|
38
|
+
verdict, reason = cf.classify_codex_toml(text)
|
|
39
|
+
except cf.Refused as e:
|
|
40
|
+
raise RuntimeError(f"codex config.toml 形态不受支持:{e}") from e
|
|
41
|
+
if verdict == "refuse":
|
|
42
|
+
raise RuntimeError(f"codex config.toml 形态不受支持:{reason}")
|
|
43
|
+
cleaned, _removed = cf.strip_managed_toml(text)
|
|
44
|
+
return cleaned
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def strip_legacy_one_liner(text: str) -> tuple:
|
|
48
|
+
"""剥离旧一代 one-liner 注入块 → (new_text, changed)。
|
|
49
|
+
|
|
50
|
+
边界取法(宁可少删不可误删):从标记行删到下一个 `<!--` 标记 / 一级标题 `# ` /
|
|
51
|
+
`---` 分隔线;都没有则删到 EOF。绝不动用户的其它 markdown 段。
|
|
52
|
+
"""
|
|
53
|
+
lines = text.splitlines()
|
|
54
|
+
idx = next((i for i, ln in enumerate(lines) if ln.strip() == _LEGACY_ONE_LINER), None)
|
|
55
|
+
if idx is None:
|
|
56
|
+
return text, False
|
|
57
|
+
end = len(lines)
|
|
58
|
+
for j in range(idx + 1, len(lines)):
|
|
59
|
+
s = lines[j].strip()
|
|
60
|
+
if s.startswith("<!--") or s.startswith("# ") or s == "---":
|
|
61
|
+
end = j
|
|
62
|
+
break
|
|
63
|
+
out = lines[:idx] + lines[end:]
|
|
64
|
+
return "\n".join(out).rstrip() + ("\n" if out else ""), True
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def strip_agents_vod_block(text: str) -> str:
|
|
68
|
+
"""幂等剥离 AGENTS.md 中带标记的 vod-devkit 技能块(历史方案清理)。
|
|
69
|
+
|
|
70
|
+
P2(深审 2026-11-06):只有 BEGIN 没有 END 时不得静默吞掉文件剩余
|
|
71
|
+
全部内容——抛错拒绝(调用方 exit 2 不落盘),宁可装不上不可删用户文件。
|
|
72
|
+
"""
|
|
73
|
+
lines, skipping, out = text.splitlines(), False, []
|
|
74
|
+
for line in lines:
|
|
75
|
+
if line.strip() == _AGENTS_MARKER_BEGIN:
|
|
76
|
+
skipping = True
|
|
77
|
+
continue
|
|
78
|
+
if line.strip() == _AGENTS_MARKER_END:
|
|
79
|
+
skipping = False
|
|
80
|
+
continue
|
|
81
|
+
if not skipping:
|
|
82
|
+
out.append(line)
|
|
83
|
+
if skipping:
|
|
84
|
+
raise RuntimeError(
|
|
85
|
+
"AGENTS.md 存在 vod-devkit BEGIN 标记但缺失 END 标记"
|
|
86
|
+
"(文件可能被手动截断)——拒绝自动清理,请手动检查该文件")
|
|
87
|
+
return "\n".join(out).rstrip()
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def install(args, packs: str) -> Path:
|
|
91
|
+
"""Codex(D-codex-agents-1 终态):原生插件路径——
|
|
92
|
+
codex plugin marketplace add <仓>/plugins + plugin add vod-devkit@vod-local,
|
|
93
|
+
打包 skills(渐进式按需加载的采集工作流)+ .mcp.json(vod-devkit serve)。
|
|
94
|
+
历史遗留清理:旧 config.toml [mcp_servers.vod-devkit] 段与 AGENTS.md 技能块
|
|
95
|
+
一并移除(与原生插件同名会双注册;AGENTS.md 方案被原生 skill 取代)。
|
|
96
|
+
前置:codex CLI 与 vod-devkit 命令在 PATH(npm i -g vod-devkit ≥0.1.12)。"""
|
|
97
|
+
codex = shutil.which("codex")
|
|
98
|
+
if not codex:
|
|
99
|
+
print("[vod-devkit] 未找到 codex CLI,无法走原生插件安装", file=sys.stderr)
|
|
100
|
+
sys.exit(2)
|
|
101
|
+
spec = host_specs.load("codex")
|
|
102
|
+
conf = Path(spec["configPath"])
|
|
103
|
+
if conf.exists(): # 历史遗留:config.toml MCP 段与插件同名=双注册,移除
|
|
104
|
+
text = conf.read_text(encoding="utf-8")
|
|
105
|
+
try:
|
|
106
|
+
cleaned = strip_codex_vod_blocks(text)
|
|
107
|
+
except RuntimeError as e:
|
|
108
|
+
# 形态守卫:非已知形态宁可不装——改坏用户整份 codex 配置的代价
|
|
109
|
+
# 远高于装不上(字节未动)
|
|
110
|
+
print(f"[vod-devkit] {e}。安装中止,未改动该文件。", file=sys.stderr)
|
|
111
|
+
sys.exit(2)
|
|
112
|
+
if cleaned != text.rstrip():
|
|
113
|
+
conf.write_text(cleaned + "\n", encoding="utf-8")
|
|
114
|
+
print(f"已移除旧 config.toml MCP 段(原生插件取代):{conf}")
|
|
115
|
+
agents = Path.home() / ".codex" / "AGENTS.md"
|
|
116
|
+
if agents.exists(): # 历史遗留:AGENTS.md 技能块已被原生 skill 取代
|
|
117
|
+
text = agents.read_text(encoding="utf-8")
|
|
118
|
+
cleaned = text
|
|
119
|
+
if _LEGACY_ONE_LINER in cleaned:
|
|
120
|
+
# 旧一代 one-liner("立即提交/不要追问/归因由安装绑定")必须清掉:
|
|
121
|
+
# 它是 consent 红线的真实破口(实测 1705 个历史会话带着它跑)
|
|
122
|
+
import datetime as _dt
|
|
123
|
+
bak = agents.with_name(f"AGENTS.md.bak-{_dt.datetime.now():%Y%m%d%H%M%S}")
|
|
124
|
+
bak.write_text(text, encoding="utf-8")
|
|
125
|
+
cleaned, _ = strip_legacy_one_liner(cleaned)
|
|
126
|
+
print(f"已移除旧 AGENTS.md one-liner 注入(备份 {bak.name}):{agents}")
|
|
127
|
+
try:
|
|
128
|
+
cleaned = strip_agents_vod_block(cleaned)
|
|
129
|
+
except RuntimeError as e:
|
|
130
|
+
print(f"[vod-devkit] {e}", file=sys.stderr)
|
|
131
|
+
sys.exit(2)
|
|
132
|
+
if cleaned.strip() == "":
|
|
133
|
+
agents.unlink() # 整份都是我们的注入 → 文件本身也不留
|
|
134
|
+
print(f"已删除空的 AGENTS.md(内容全为旧注入):{agents}")
|
|
135
|
+
elif cleaned != text.rstrip():
|
|
136
|
+
agents.write_text(cleaned + "\n", encoding="utf-8")
|
|
137
|
+
print(f"已移除旧 AGENTS.md 技能块(原生 skill 取代):{agents}")
|
|
138
|
+
mp_root = ROOT / "plugins"
|
|
139
|
+
|
|
140
|
+
def _run(cmd):
|
|
141
|
+
r = subprocess.run(cmd, capture_output=True, text=True, timeout=120)
|
|
142
|
+
if r.returncode != 0:
|
|
143
|
+
raise RuntimeError(f"{' '.join(cmd)} → {r.stderr.strip() or r.stdout.strip()}")
|
|
144
|
+
return r.stdout
|
|
145
|
+
|
|
146
|
+
mp_name = "vod-local"
|
|
147
|
+
# devkit 卫生实践:stale cache 先清——codex 插件缓存不自动失效,不清则
|
|
148
|
+
# 重装/升级后旧版本残留(marketplace 指向与 cache 内容漂移)
|
|
149
|
+
for stale in (Path.home() / ".codex" / "plugins" / "marketplaces" / mp_name,
|
|
150
|
+
Path.home() / ".codex" / "plugins" / "cache" / mp_name):
|
|
151
|
+
if stale.exists():
|
|
152
|
+
shutil.rmtree(stale)
|
|
153
|
+
print(f"已清理 stale 插件缓存:{stale}")
|
|
154
|
+
ml = subprocess.run([codex, "plugin", "marketplace", "list"], capture_output=True, text=True, timeout=120).stdout
|
|
155
|
+
if mp_name not in ml:
|
|
156
|
+
_run([codex, "plugin", "marketplace", "add", str(mp_root)])
|
|
157
|
+
print(f"已注册本地 marketplace:{mp_root}")
|
|
158
|
+
_run([codex, "plugin", "add", f"vod-devkit@{mp_name}"])
|
|
159
|
+
print("已安装 codex 原生插件 vod-devkit(skills + MCP,重启 Codex 会话生效)")
|
|
160
|
+
# P1-5(深审 2026-11-06):插件自带的 .mcp.json 硬编码 env.VOD_PACKS=
|
|
161
|
+
# core,collect——--packs 对 codex 半失效(运行期仍注册 collect 工具)。
|
|
162
|
+
# plugin add 后把缓存内 .mcp.json 的 packs 对齐本次安装值。
|
|
163
|
+
import glob as _glob
|
|
164
|
+
mcp_jsons = sorted(
|
|
165
|
+
_glob.glob(str(Path.home() / ".codex" / "plugins" / "cache"
|
|
166
|
+
/ mp_name / "vod-devkit" / "*" / ".mcp.json")),
|
|
167
|
+
key=lambda p: Path(p).stat().st_mtime, reverse=True)
|
|
168
|
+
if mcp_jsons:
|
|
169
|
+
try:
|
|
170
|
+
mj = json.loads(Path(mcp_jsons[0]).read_text(encoding="utf-8"))
|
|
171
|
+
srv = mj.get("mcpServers", {}).get("vod-devkit")
|
|
172
|
+
if srv is not None:
|
|
173
|
+
srv.setdefault("env", {})["VOD_PACKS"] = packs
|
|
174
|
+
Path(mcp_jsons[0]).write_text(
|
|
175
|
+
json.dumps(mj, ensure_ascii=False, indent=2) + "\n",
|
|
176
|
+
encoding="utf-8")
|
|
177
|
+
print(f"已对齐插件 MCP packs:{mcp_jsons[0]}(VOD_PACKS={packs})")
|
|
178
|
+
except Exception as e:
|
|
179
|
+
print(f"[vod-devkit] warn: 插件 .mcp.json packs 对齐失败({e})——"
|
|
180
|
+
"运行期熔断门禁仍会兜底", file=sys.stderr)
|
|
181
|
+
return Path(mcp_jsons[0])
|
|
182
|
+
# 深审 P0-3:绝不再返回 ~/.codex/config.toml——它是用户整份 codex 配置,
|
|
183
|
+
# uninstall 对 mcpConfig 是删除语义,指向它=卸载删光用户配置(破坏性)
|
|
184
|
+
print("[vod-devkit] warn: 未定位到插件 .mcp.json(uninstall 将跳过 MCP 清理,"
|
|
185
|
+
"可手动删除插件缓存目录)", file=sys.stderr)
|
|
186
|
+
return None
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def install_remote(args, url, token):
|
|
190
|
+
"""codex mcp add --url + --bearer-token-env-var(token 由用户环境提供)。"""
|
|
191
|
+
codex = shutil.which("codex")
|
|
192
|
+
if not codex:
|
|
193
|
+
print("[vod-devkit] 未找到 codex CLI,无法走远程注册", file=sys.stderr)
|
|
194
|
+
sys.exit(2)
|
|
195
|
+
r = subprocess.run([codex, "mcp", "add", "vod-devkit", "--url", url,
|
|
196
|
+
"--bearer-token-env-var", "VOD_MCP_TOKEN"],
|
|
197
|
+
capture_output=True, text=True, timeout=180)
|
|
198
|
+
if r.returncode != 0:
|
|
199
|
+
print(f"[vod-devkit] codex mcp add(remote)失败:{(r.stderr or r.stdout).strip()[-200:]}",
|
|
200
|
+
file=sys.stderr)
|
|
201
|
+
sys.exit(1)
|
|
202
|
+
stale = Path.home() / ".codex" / "plugins"
|
|
203
|
+
if stale.exists():
|
|
204
|
+
print("提示:codex 若曾用插件形态安装过 vod-devkit,请先 "
|
|
205
|
+
"`codex plugin remove vod-devkit@vod-local` 避免双注册(stdio 插件 .mcp.json "
|
|
206
|
+
"与本次 remote 配置同名)", file=sys.stderr)
|
|
207
|
+
print(f"已注册 Codex 远程 MCP({url})。token 由环境变量 VOD_MCP_TOKEN 提供:\n"
|
|
208
|
+
f" export VOD_MCP_TOKEN=<你的 key>(写入 shell 配置或宿主 env)")
|
|
209
|
+
return None
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"""DeepSeek Harness (dsh) 宿主适配:壳包 dsh-vod-devkit + profile patch upsert。
|
|
2
|
+
|
|
3
|
+
dsh 壳不走 MCP(工具/UI 都由壳进程提供)→ SUPPORTS_REMOTE=False。
|
|
4
|
+
"""
|
|
5
|
+
import shutil
|
|
6
|
+
import subprocess
|
|
7
|
+
import sys
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
from vod_mcp import hosts as host_specs
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
HOST = "dsh"
|
|
14
|
+
SUPPORTS_REMOTE = False
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def skills_dir(args):
|
|
18
|
+
prof = (getattr(args, "dsh_profile", "") or "").strip()
|
|
19
|
+
if not prof:
|
|
20
|
+
return None
|
|
21
|
+
d = host_specs.load("dsh", prof).get("skillsDir")
|
|
22
|
+
return Path(d) if d else None
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def install(args, packs: str) -> Path:
|
|
26
|
+
"""dsh 工具壳(D-dsh-install-1,2026-11-06 用户拍板 A):三壳口径统一——
|
|
27
|
+
--product 安装期硬校验(cmd_install 已先行,到达此处必已过)+ 校验先于
|
|
28
|
+
add + 幂等写 profile cordis.patch.yml config override。
|
|
29
|
+
生效通道真机实测(2026-11-06,dsh 0.2.1-rc.5):profile cordis.patch.yml
|
|
30
|
+
的 id-targeted config override 是工具壳读取 product/apiBase/uiBase/
|
|
31
|
+
confirmWrites 的唯一运行时通道(启动 banner + 桩引擎提交链实证)。
|
|
32
|
+
uiBase(D-uiBase-direct):浏览器半(反馈按钮)直连引擎——apiBase 是
|
|
33
|
+
server 半(Node)自用,浏览器同源策略下用不上;缺 uiBase 时 UI 提交
|
|
34
|
+
发往 dsh 同源(404→本地暂存),嵌入方真机实锤。dsh plugin add 会自建
|
|
35
|
+
profile,无需前置。"""
|
|
36
|
+
dsh = shutil.which("dsh")
|
|
37
|
+
profile = (getattr(args, "dsh_profile", "") or "").strip()
|
|
38
|
+
if not profile:
|
|
39
|
+
# argparse 进入安装前校验(cmd_install 已兜底,直调防御)
|
|
40
|
+
print("[vod-devkit] --profile 必填:dsh 按 profile 组织插件与配置"
|
|
41
|
+
"(--profile <name>)", file=sys.stderr)
|
|
42
|
+
sys.exit(2)
|
|
43
|
+
if not dsh:
|
|
44
|
+
print("[vod-devkit] 未找到 dsh CLI(PATH),拒绝安装(宁可不装不可装错)。"
|
|
45
|
+
"前置:npm i -g @deepseek-ai/dsh(需 pnpm)", file=sys.stderr)
|
|
46
|
+
sys.exit(2)
|
|
47
|
+
r = subprocess.run([dsh, "plugin", "--profile", profile,
|
|
48
|
+
"add", "dsh-vod-devkit"],
|
|
49
|
+
capture_output=True, text=True, timeout=300)
|
|
50
|
+
if r.returncode != 0:
|
|
51
|
+
print(f"[vod-devkit] dsh plugin add 失败:{(r.stderr or r.stdout).strip()[-300:]}",
|
|
52
|
+
file=sys.stderr)
|
|
53
|
+
sys.exit(1)
|
|
54
|
+
print(f"已安装 dsh 插件 dsh-vod-devkit(profile={profile},dsh plugin list 可见)")
|
|
55
|
+
|
|
56
|
+
patch = Path(host_specs.load("dsh", profile)["configPath"])
|
|
57
|
+
# name 行必须保留:cordis.patch.yml 的 insert 块靠 name 绑定 client 半
|
|
58
|
+
# (反馈按钮)——只写 id+config 会在重装幂等替换时把 name 吞掉,UI 静默
|
|
59
|
+
# 失激活(2026-11-06 真机实锤:重装后入口消失)
|
|
60
|
+
# 嵌套铁律(2026-11-10 真机实锤):块必须缩进在 `- insert:` 之下——平铺
|
|
61
|
+
# 形态被 dsh 组合层丢弃,插件掉出组合树(banner/工具/UI 全消失)。
|
|
62
|
+
# 归因先验(D-attrib-B):--product 可选;空值时写 '' 而非空值
|
|
63
|
+
# (dsh 壳 config schema 是 z.string().default(''),YAML null 会校验失败)
|
|
64
|
+
prod_yaml = args.product or "''"
|
|
65
|
+
block = ("- insert:\n"
|
|
66
|
+
" - id: vod-devkit\n"
|
|
67
|
+
" name: dsh-vod-devkit\n"
|
|
68
|
+
" config:\n"
|
|
69
|
+
f" product: {prod_yaml}\n"
|
|
70
|
+
f" apiBase: {args.java_api_base}\n"
|
|
71
|
+
f" uiBase: {args.java_api_base}\n" # D-uiBase-direct:浏览器半直连引擎
|
|
72
|
+
" # headless 无审批通道:原生 ask 门禁会永久阻断写工具(四宿主实测实锤:\n"
|
|
73
|
+
" # requires approval, but no approval channel)。同意确认由 SKILL 话术层\n"
|
|
74
|
+
" # 承担(draft→用户确认→commit / 明确指令直发),web 端如需硬门禁按\n"
|
|
75
|
+
" # profile 覆盖回 true。\n"
|
|
76
|
+
" confirmWrites: false\n")
|
|
77
|
+
try:
|
|
78
|
+
written = upsert_patch(patch, block)
|
|
79
|
+
except Exception as e:
|
|
80
|
+
# 回滚/修复指引:插件已装但配置未写 = 半成品,给明确的手动修复格式。
|
|
81
|
+
# 区分两类失败:形态守卫拒绝(文件合法但不在已知形态内,字节未动)
|
|
82
|
+
# 与真实 IO 失败——两者的处置动作不同,文案必须能分辨。
|
|
83
|
+
print(f"[vod-devkit] 插件已装入 profile={profile},但配置写入失败"
|
|
84
|
+
f"({e.__class__.__name__}: {e};该文件未被改动)。请手动把下段并入 {patch}"
|
|
85
|
+
f"(顶层 YAML 数组元素,已有 - id: vod-devkit 段则原位替换):\n"
|
|
86
|
+
f"{block}", file=sys.stderr)
|
|
87
|
+
sys.exit(1)
|
|
88
|
+
if written:
|
|
89
|
+
print(f"已写入归因/引擎配置(幂等 upsert):{patch}")
|
|
90
|
+
else:
|
|
91
|
+
print(f"配置未变化(幂等跳过):{patch}")
|
|
92
|
+
return patch
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def find_dsh_block(lines):
|
|
96
|
+
"""定位 cordis.patch.yml 中 vod-devkit 块的 (start, end)。
|
|
97
|
+
|
|
98
|
+
扫描/边界语义统一在 vod_mcp/config_forms.find_dsh_block(单一实现,
|
|
99
|
+
install 的幂等 upsert、uninstall 摘除、doctor 自愈三处共用——两处扫描
|
|
100
|
+
规则漂移在本仓 dsh 壳上实锤过)。本函数只保留名字兼容调用点。
|
|
101
|
+
"""
|
|
102
|
+
from vod_mcp import config_forms as cf
|
|
103
|
+
return cf.find_dsh_block(lines)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def upsert_patch(patch: Path, block: str) -> bool:
|
|
107
|
+
"""幂等写 profile cordis.patch.yml:已存在 `- id: vod-devkit` 段则原位整块
|
|
108
|
+
替换(不重复插入);无则追加。按行扫描块边界(下一行 `- ` 顶层元素或 EOF),
|
|
109
|
+
不引 YAML 依赖(本仓零第三方依赖红线)。返回是否有写入。"""
|
|
110
|
+
from vod_mcp import config_forms as cf
|
|
111
|
+
lines = patch.read_text(encoding="utf-8").splitlines() if patch.exists() else []
|
|
112
|
+
# 形态守卫(先分类后改字节):非已知形态一律拒绝——这个文件坏掉等于
|
|
113
|
+
# 整个 dsh profile 起不来(`[]` 占位实锤),比装不上代价高得多
|
|
114
|
+
try:
|
|
115
|
+
verdict, reason = cf.classify_dsh_patch(lines)
|
|
116
|
+
except cf.Refused as e:
|
|
117
|
+
raise RuntimeError(f"cordis.patch.yml 形态不受支持:{e}") from e
|
|
118
|
+
if verdict == "refuse":
|
|
119
|
+
raise RuntimeError(f"cordis.patch.yml 形态不受支持:{reason}")
|
|
120
|
+
start, end = find_dsh_block(lines)
|
|
121
|
+
if start is None:
|
|
122
|
+
# 空数组占位清除(四宿主实测实锤:dsh plugin add 自建的模板含字面量
|
|
123
|
+
# `[]` 顶层行,直接追加块 = `[]` 后跟 `- id:` 顶层元素 = 非法 YAML,
|
|
124
|
+
# 整个 profile 启动崩溃)。`[]` 语义=空数组,被块 entries 取代即删。
|
|
125
|
+
lines = [ln for ln in lines if ln.strip() != "[]"]
|
|
126
|
+
new = lines + ([""] if lines and lines[-1].strip() else []) + block.splitlines()
|
|
127
|
+
else:
|
|
128
|
+
new = lines[:start] + block.splitlines() + lines[end:]
|
|
129
|
+
new_text = "\n".join(new).rstrip("\n") + "\n"
|
|
130
|
+
# 空 `- insert:` 组头清理(损坏态自愈):孤儿组头(下一个顶层元素前无
|
|
131
|
+
# 子项)来自历史平铺替换的残留——留它在 dsh 组合层是空组,可能拖垮
|
|
132
|
+
# 整个 patch 解析。upsert 后顺手摘除(幂等,不碰正常组)。
|
|
133
|
+
cleaned = []
|
|
134
|
+
for idx, ln in enumerate(new):
|
|
135
|
+
if ln.strip() == "- insert:":
|
|
136
|
+
nxt = new[idx + 1] if idx + 1 < len(new) else ""
|
|
137
|
+
if nxt.startswith("- ") or (not nxt.strip() and idx + 2 >= len(new)):
|
|
138
|
+
continue # 孤儿组头:下一行已是新顶层元素(无子项)→ 摘除
|
|
139
|
+
cleaned.append(ln)
|
|
140
|
+
new_text = "\n".join(cleaned).rstrip("\n") + "\n"
|
|
141
|
+
old_text = patch.read_text(encoding="utf-8") if patch.exists() else ""
|
|
142
|
+
if new_text == old_text:
|
|
143
|
+
return False
|
|
144
|
+
patch.parent.mkdir(parents=True, exist_ok=True)
|
|
145
|
+
patch.write_text(new_text, encoding="utf-8")
|
|
146
|
+
return True
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def remove_patch_block(patch: Path) -> bool:
|
|
150
|
+
"""从 cordis.patch.yml 摘除 vod-devkit 块(uninstall 用)。返回是否摘除。"""
|
|
151
|
+
if not patch.exists():
|
|
152
|
+
return False
|
|
153
|
+
from vod_mcp import config_forms as cf
|
|
154
|
+
lines = patch.read_text(encoding="utf-8").splitlines()
|
|
155
|
+
try:
|
|
156
|
+
verdict, reason = cf.classify_dsh_patch(lines)
|
|
157
|
+
except cf.Refused as e:
|
|
158
|
+
verdict, reason = "refuse", str(e)
|
|
159
|
+
if verdict == "refuse":
|
|
160
|
+
# 卸载路径同样不动字节:文件已经坏了,再"尽力删"只会让故障更难定位
|
|
161
|
+
print(f"[vod-devkit] skip(cordis.patch.yml 形态不受支持,未改动):{reason}",
|
|
162
|
+
file=sys.stderr)
|
|
163
|
+
return False
|
|
164
|
+
start, end = find_dsh_block(lines)
|
|
165
|
+
if start is None:
|
|
166
|
+
return False
|
|
167
|
+
patch.write_text(
|
|
168
|
+
"\n".join(lines[:start] + lines[end:]).rstrip("\n") + "\n",
|
|
169
|
+
encoding="utf-8")
|
|
170
|
+
return True
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
def install_remote(args, url, token):
|
|
174
|
+
print("[vod-devkit] dsh 壳不走 MCP,不支持远程 attach;请用本地形态:"
|
|
175
|
+
"install --target dsh --profile <name>", file=sys.stderr)
|
|
176
|
+
sys.exit(2)
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"""通用 MCP 宿主适配(A 层兜底)。
|
|
2
|
+
|
|
3
|
+
对标 huaweicloud-devkit 的 `configureGenericMCP()`:不认识/没有专属模块的宿主
|
|
4
|
+
不该"不支持",而应"能装 + 给片段"。
|
|
5
|
+
|
|
6
|
+
两条纪律:
|
|
7
|
+
- **外科式合并**:只写 `mcpServers["vod-devkit"]` 一个键,其它 server 与用户
|
|
8
|
+
自有键原样保留;首次改动前落 `.bak`。共享配置文件永不整文件重写语义删除。
|
|
9
|
+
- **宁可不装不可装错**:现有文件不是合法 JSON / 不是对象 → 报错退出、字节不动。
|
|
10
|
+
|
|
11
|
+
探测表只收录「已知 config 形态」的宿主(JSON + mcpServers)。不在表里也能装:
|
|
12
|
+
`--mcp-config <path>` 显式给出路径即可。
|
|
13
|
+
"""
|
|
14
|
+
import json
|
|
15
|
+
import shutil
|
|
16
|
+
import sys
|
|
17
|
+
from pathlib import Path
|
|
18
|
+
|
|
19
|
+
from vod_mcp.host_adapters.base import server_env, server_entry
|
|
20
|
+
|
|
21
|
+
HOST = "generic"
|
|
22
|
+
SUPPORTS_REMOTE = True
|
|
23
|
+
|
|
24
|
+
ENTRY_NAME = "vod-devkit"
|
|
25
|
+
|
|
26
|
+
# id → 探测目录 + 默认 MCP 配置文件(相对 HOME)
|
|
27
|
+
KNOWN_HOSTS = [
|
|
28
|
+
{"id": "claude-code", "paths": ["~/.claude", "~/.claude.json"],
|
|
29
|
+
"config": "~/.claude.json", "label": "Claude Code"},
|
|
30
|
+
{"id": "cursor", "paths": ["~/.cursor"],
|
|
31
|
+
"config": "~/.cursor/mcp.json", "label": "Cursor"},
|
|
32
|
+
{"id": "windsurf", "paths": ["~/.codeium/windsurf"],
|
|
33
|
+
"config": "~/.codeium/windsurf/mcp_config.json", "label": "Windsurf"},
|
|
34
|
+
{"id": "cline", "paths": ["~/.cline"],
|
|
35
|
+
"config": "~/.cline/mcp_settings.json", "label": "Cline"},
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _expand(p: str) -> Path:
|
|
40
|
+
return Path(p).expanduser()
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def detect_known() -> list:
|
|
44
|
+
"""探测在场但没有专属适配模块的宿主(只读,不写任何文件)。"""
|
|
45
|
+
found = []
|
|
46
|
+
for h in KNOWN_HOSTS:
|
|
47
|
+
if any(_expand(p).exists() for p in h["paths"]):
|
|
48
|
+
found.append(h)
|
|
49
|
+
return found
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def snippet(packs: str = "core,collect", api_base: str = "") -> dict:
|
|
53
|
+
"""可粘贴的 stdio 片段(安装器 no-path 时打印)。"""
|
|
54
|
+
args = type("A", (), {"java_api_base": api_base})()
|
|
55
|
+
entry = {"command": sys.executable, "args": [server_entry()],
|
|
56
|
+
"env": server_env(args, packs)}
|
|
57
|
+
return {"mcpServers": {ENTRY_NAME: entry}}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def merge_mcp_servers(path: Path, entry: dict, name: str = ENTRY_NAME) -> str:
|
|
61
|
+
"""外科式合并 mcpServers 条目 → created / updated / unchanged。
|
|
62
|
+
|
|
63
|
+
现有文件非法 JSON 或不是对象时抛 RuntimeError(调用方拒绝安装,字节未动)。
|
|
64
|
+
"""
|
|
65
|
+
cfg = {}
|
|
66
|
+
existed = path.exists()
|
|
67
|
+
if existed:
|
|
68
|
+
raw = path.read_text(encoding="utf-8")
|
|
69
|
+
if raw.strip():
|
|
70
|
+
try:
|
|
71
|
+
parsed = json.loads(raw)
|
|
72
|
+
except json.JSONDecodeError as e:
|
|
73
|
+
raise RuntimeError(f"{path} 不是合法 JSON({e.msg}),拒绝改动") from e
|
|
74
|
+
if not isinstance(parsed, dict):
|
|
75
|
+
raise RuntimeError(f"{path} 顶层不是对象,拒绝改动")
|
|
76
|
+
cfg = parsed
|
|
77
|
+
servers = cfg.get("mcpServers")
|
|
78
|
+
if servers is None:
|
|
79
|
+
servers = {}
|
|
80
|
+
elif not isinstance(servers, dict):
|
|
81
|
+
raise RuntimeError(f"{path} 的 mcpServers 不是对象,拒绝改动")
|
|
82
|
+
if servers.get(name) == entry:
|
|
83
|
+
return "unchanged"
|
|
84
|
+
action = "updated" if servers.get(name) else "created"
|
|
85
|
+
if existed and action == "created":
|
|
86
|
+
shutil.copyfile(path, str(path) + ".bak")
|
|
87
|
+
servers[name] = entry
|
|
88
|
+
cfg["mcpServers"] = servers
|
|
89
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
90
|
+
path.write_text(json.dumps(cfg, ensure_ascii=False, indent=2) + "\n",
|
|
91
|
+
encoding="utf-8")
|
|
92
|
+
return action
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def install(args, packs):
|
|
96
|
+
"""无专属模块的宿主:合并到 --mcp-config 指定文件;未给路径则打印片段。"""
|
|
97
|
+
cfg_path = (getattr(args, "mcp_config", "") or "").strip()
|
|
98
|
+
detected = detect_known()
|
|
99
|
+
if not cfg_path:
|
|
100
|
+
if detected:
|
|
101
|
+
print("探测到通用 MCP 宿主:" + "、".join(h["label"] for h in detected)
|
|
102
|
+
+ "(本插件无专属适配,走通用写入)")
|
|
103
|
+
print(" 可用:--target generic --mcp-config " + detected[0]["config"])
|
|
104
|
+
print("未给 --mcp-config,不写任何文件。可粘贴片段(MCP 客户端通用):")
|
|
105
|
+
print(json.dumps(snippet(packs, args.java_api_base), ensure_ascii=False, indent=2))
|
|
106
|
+
print(" (技能目录未知,未安装技能;如需话术层请用 --target hermes|opencode|codex)")
|
|
107
|
+
return None
|
|
108
|
+
path = _expand(cfg_path)
|
|
109
|
+
entry = {"command": sys.executable, "args": [server_entry()],
|
|
110
|
+
"env": server_env(args, packs)}
|
|
111
|
+
action = merge_mcp_servers(path, entry)
|
|
112
|
+
verb = {"created": "写入", "updated": "更新", "unchanged": "跳过(已一致)"}[action]
|
|
113
|
+
print(f"已{verb} {path.name} 的 mcpServers.vod-devkit:{path}(重启宿主会话生效)")
|
|
114
|
+
return path
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def install_remote(args, url, token):
|
|
118
|
+
"""通用远程写入:headers 带 Bearer(明文,提示权限),其余键不动。"""
|
|
119
|
+
cfg_path = (getattr(args, "mcp_config", "") or "").strip()
|
|
120
|
+
if not cfg_path:
|
|
121
|
+
print("远程 attach 需要显式 --mcp-config <path>(通用宿主猜不出配置文件)",
|
|
122
|
+
file=sys.stderr)
|
|
123
|
+
sys.exit(2)
|
|
124
|
+
path = _expand(cfg_path)
|
|
125
|
+
entry = {"url": url, "headers": {"Authorization": f"Bearer {token}"}}
|
|
126
|
+
action = merge_mcp_servers(path, entry)
|
|
127
|
+
print(f"已写入通用远程 MCP 条目({action}):{path}(token 明文,注意文件权限)")
|
|
128
|
+
return path
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def skills_dir(args):
|
|
132
|
+
return None
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"""Hermes 宿主适配:官方 hermes mcp add + 路由插件部署。
|
|
2
|
+
|
|
3
|
+
落点与探测来自 integrations/hermes/host.json(数据驱动,代码里不许出现第二份
|
|
4
|
+
路径字面量);新增 Hermes 特定逻辑只改本模块。
|
|
5
|
+
"""
|
|
6
|
+
import json
|
|
7
|
+
import subprocess
|
|
8
|
+
import sys
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
from vod_mcp import hosts as host_specs
|
|
12
|
+
from vod_mcp.host_adapters.base import ROOT, server_env, server_entry
|
|
13
|
+
|
|
14
|
+
HOST = "hermes"
|
|
15
|
+
SUPPORTS_REMOTE = True
|
|
16
|
+
_SPEC = host_specs.load("hermes")
|
|
17
|
+
_MCP_DIR = Path(_SPEC["configPath"]).parent
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def skills_dir(args):
|
|
21
|
+
return Path(_SPEC["skillsDir"])
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def install(args, packs: str) -> Path:
|
|
25
|
+
"""Hermes:官方途径 hermes mcp add(config.yaml mcp_servers)。"""
|
|
26
|
+
conf = _MCP_DIR / "vod-devkit.json"
|
|
27
|
+
conf.parent.mkdir(parents=True, exist_ok=True)
|
|
28
|
+
conf.write_text(json.dumps({
|
|
29
|
+
"name": "vod-devkit", "command": sys.executable,
|
|
30
|
+
"args": [server_entry()], "env": server_env(args, packs),
|
|
31
|
+
}, ensure_ascii=False, indent=2), encoding="utf-8")
|
|
32
|
+
env_args = []
|
|
33
|
+
for k, v in server_env(args, packs).items():
|
|
34
|
+
env_args.extend([k + "=" + v])
|
|
35
|
+
r = subprocess.run(
|
|
36
|
+
["hermes", "mcp", "add", "vod-devkit", "--command", sys.executable,
|
|
37
|
+
*["--env"] + env_args, "--args", server_entry()],
|
|
38
|
+
input="y\ny\n", capture_output=True, text=True)
|
|
39
|
+
# D-hook-1:强制评估路由插件(pre_llm_call 确定性意图路由,业界 forced-eval 模式)
|
|
40
|
+
import shutil as _sh
|
|
41
|
+
plug_src = ROOT / "hermes-plugin" / "vod-feedback-router"
|
|
42
|
+
plug_dst = Path.home() / ".hermes" / "plugins" / "vod-feedback-router"
|
|
43
|
+
if plug_src.is_dir():
|
|
44
|
+
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 ...,重启会话生效)")
|
|
50
|
+
if r.returncode == 0:
|
|
51
|
+
print("已注册 Hermes MCP(hermes mcp list 可见;重启会话生效)")
|
|
52
|
+
else:
|
|
53
|
+
print(f"提示:hermes mcp add 未成功({r.stderr.strip()[:150]});"
|
|
54
|
+
f"可将 {conf} 内容并入 Hermes 配置")
|
|
55
|
+
return conf
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def install_remote(args, url, token):
|
|
59
|
+
"""hermes mcp add --url:token 经 env 注入,配置里只留 ${MCP_VOD_DEVKIT_API_KEY} 引用。"""
|
|
60
|
+
import os
|
|
61
|
+
env = os.environ.copy()
|
|
62
|
+
env["MCP_VOD_DEVKIT_API_KEY"] = token
|
|
63
|
+
r = subprocess.run(
|
|
64
|
+
["hermes", "mcp", "add", "vod-devkit", "--url", url, "--auth", "header"],
|
|
65
|
+
input="y\ny\n", capture_output=True, text=True, env=env, timeout=180)
|
|
66
|
+
if r.returncode != 0:
|
|
67
|
+
print(f"[vod-devkit] hermes mcp add(remote)失败:{(r.stderr or r.stdout).strip()[-200:]}",
|
|
68
|
+
file=sys.stderr)
|
|
69
|
+
sys.exit(1)
|
|
70
|
+
conf = _MCP_DIR / "vod-devkit.json"
|
|
71
|
+
conf.parent.mkdir(parents=True, exist_ok=True)
|
|
72
|
+
conf.write_text(json.dumps({"name": "vod-devkit", "url": url,
|
|
73
|
+
"headers": {"Authorization": "Bearer ${MCP_VOD_DEVKIT_API_KEY}"}},
|
|
74
|
+
ensure_ascii=False, indent=2), encoding="utf-8")
|
|
75
|
+
print(f"已注册 Hermes 远程 MCP({url};token 存 ~/.hermes/.env,配置内只留引用)")
|
|
76
|
+
return conf
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"""OpenCode 宿主适配:opencode.json 的 mcp 段无损合并 + 随装生成物。"""
|
|
2
|
+
import sys
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from vod_mcp import hosts as host_specs
|
|
6
|
+
from vod_mcp.host_adapters.base import merge_json_mcp, server_env, server_entry
|
|
7
|
+
|
|
8
|
+
HOST = "opencode"
|
|
9
|
+
SUPPORTS_REMOTE = True
|
|
10
|
+
_SPEC = host_specs.load("opencode")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def skills_dir(args):
|
|
14
|
+
d = _SPEC.get("skillsDir")
|
|
15
|
+
return Path(d) if d else None
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def install(args, packs: str) -> Path:
|
|
19
|
+
"""OpenCode:~/.config/opencode/opencode.json 的 mcp 段无损合并。
|
|
20
|
+
|
|
21
|
+
schema 实测要求:command=数组、enabled 必填;既有内容(provider 等)
|
|
22
|
+
原样保留(读改写,只动 mcp.vod-devkit 键)。
|
|
23
|
+
"""
|
|
24
|
+
spec = host_specs.load("opencode")
|
|
25
|
+
conf = Path(spec["configPath"])
|
|
26
|
+
entry = {
|
|
27
|
+
"type": "local",
|
|
28
|
+
"command": [sys.executable, server_entry()],
|
|
29
|
+
"enabled": True,
|
|
30
|
+
"environment": server_env(args, packs),
|
|
31
|
+
}
|
|
32
|
+
action = merge_json_mcp(conf, entry) # 公共合并件:保用户键 + 首改 .bak
|
|
33
|
+
print(f"已写入 OpenCode 配置({action}):{conf}(重启 OpenCode 会话生效)")
|
|
34
|
+
# 随装生成物走 integrations/opencode/ 的模板(单一来源——此前模板正文
|
|
35
|
+
# 硬编码在本函数里,改文案要同时改代码与文档两处)
|
|
36
|
+
for g in spec["generated"]:
|
|
37
|
+
dest = Path(g["dest"])
|
|
38
|
+
dest.parent.mkdir(parents=True, exist_ok=True)
|
|
39
|
+
dest.write_text(Path(g["template"]).read_text(encoding="utf-8"),
|
|
40
|
+
encoding="utf-8")
|
|
41
|
+
print(f"已写入 OpenCode 自检命令:/vod-doctor({dest})")
|
|
42
|
+
return conf
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def install_remote(args, url, token):
|
|
46
|
+
"""mcp.vod-devkit = {type:remote, url, enabled, headers}(headers 明文,提示权限)。"""
|
|
47
|
+
conf = Path(_SPEC["configPath"])
|
|
48
|
+
entry = {"type": "remote", "url": url, "enabled": True,
|
|
49
|
+
"headers": {"Authorization": f"Bearer {token}"}}
|
|
50
|
+
action = merge_json_mcp(conf, entry)
|
|
51
|
+
print(f"已写入 OpenCode 远程 MCP 配置({action}):{conf}(token 随配置存放,注意文件权限)")
|
|
52
|
+
return conf
|