vod-devkit 0.5.5 → 0.5.8
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 +32 -0
- package/QUICKSTART.md +47 -23
- package/README.en.md +7 -2
- package/README.md +6 -2
- package/bin/vod-devkit +12 -1164
- package/contract/tools.schema.json +1 -1
- package/package.json +8 -2
- package/plugins/vod-devkit/.codex-plugin/plugin.json +1 -1
- package/plugins/vod-devkit/build-info.json +3 -3
- package/plugins/vod-devkit/contract/tools.schema.json +446 -0
- package/plugins/vod-devkit/safety/policy.json +48 -0
- package/plugins/vod-devkit/vod_mcp/__init__.py +1 -1
- package/plugins/vod-devkit/vod_mcp/__pycache__/__init__.cpython-314.pyc +0 -0
- package/plugins/vod-devkit/vod_mcp/__pycache__/attribution.cpython-314.pyc +0 -0
- package/plugins/vod-devkit/vod_mcp/__pycache__/net.cpython-314.pyc +0 -0
- package/plugins/vod-devkit/vod_mcp/__pycache__/paths.cpython-314.pyc +0 -0
- package/plugins/vod-devkit/vod_mcp/__pycache__/policy.cpython-314.pyc +0 -0
- package/plugins/vod-devkit/vod_mcp/__pycache__/provenance.cpython-314.pyc +0 -0
- package/plugins/vod-devkit/vod_mcp/__pycache__/runtime_state.cpython-314.pyc +0 -0
- package/plugins/vod-devkit/vod_mcp/__pycache__/skills_registry.cpython-314.pyc +0 -0
- package/plugins/vod-devkit/vod_mcp/__pycache__/tools.cpython-314.pyc +0 -0
- package/plugins/vod-devkit/vod_mcp/host_adapters/base.py +3 -1
- package/plugins/vod-devkit/vod_mcp/host_adapters/hermes.py +88 -11
- package/plugins/vod-devkit/vod_mcp/hosts.py +3 -1
- package/plugins/vod-devkit/vod_mcp/net.py +251 -0
- package/plugins/vod-devkit/vod_mcp/packs/__pycache__/__init__.cpython-314.pyc +0 -0
- package/plugins/vod-devkit/vod_mcp/packs/__pycache__/collect.cpython-314.pyc +0 -0
- package/plugins/vod-devkit/vod_mcp/packs/__pycache__/core.cpython-314.pyc +0 -0
- package/plugins/vod-devkit/vod_mcp/packs/__pycache__/knowledge.cpython-314.pyc +0 -0
- package/plugins/vod-devkit/vod_mcp/packs/collect.py +684 -0
- package/plugins/vod-devkit/vod_mcp/packs/core.py +80 -0
- package/plugins/vod-devkit/vod_mcp/packs/knowledge.py +17 -0
- package/plugins/vod-devkit/vod_mcp/paths.py +38 -0
- package/plugins/vod-devkit/vod_mcp/payload.py +3 -1
- package/plugins/vod-devkit/vod_mcp/policy.py +3 -2
- package/plugins/vod-devkit/vod_mcp/provenance.py +3 -2
- package/plugins/vod-devkit/vod_mcp/runtime_state.py +324 -0
- package/plugins/vod-devkit/vod_mcp/server.py +10 -7
- package/plugins/vod-devkit/vod_mcp/skills_registry.py +5 -4
- package/plugins/vod-devkit/vod_mcp/tools.py +23 -1298
- package/plugins/vod-devkit/vod_mcp/transport_remote.py +21 -9
- package/plugins/vod-devkit/vod_mcp/update_check.py +1 -1
- package/vod_mcp/__init__.py +1 -1
- package/vod_mcp/host_adapters/__pycache__/__init__.cpython-39.pyc +0 -0
- package/vod_mcp/host_adapters/__pycache__/atomcode.cpython-39.pyc +0 -0
- package/vod_mcp/host_adapters/__pycache__/base.cpython-314.pyc +0 -0
- package/vod_mcp/host_adapters/__pycache__/base.cpython-39.pyc +0 -0
- package/vod_mcp/host_adapters/__pycache__/codearts.cpython-39.pyc +0 -0
- package/vod_mcp/host_adapters/__pycache__/codeartswork.cpython-39.pyc +0 -0
- package/vod_mcp/host_adapters/__pycache__/codex.cpython-39.pyc +0 -0
- package/vod_mcp/host_adapters/__pycache__/codex_desktop.cpython-39.pyc +0 -0
- package/vod_mcp/host_adapters/__pycache__/dsh.cpython-39.pyc +0 -0
- package/vod_mcp/host_adapters/__pycache__/generic.cpython-39.pyc +0 -0
- package/vod_mcp/host_adapters/__pycache__/hermes.cpython-314.pyc +0 -0
- package/vod_mcp/host_adapters/__pycache__/hermes.cpython-39.pyc +0 -0
- package/vod_mcp/host_adapters/__pycache__/opencode.cpython-39.pyc +0 -0
- package/vod_mcp/host_adapters/__pycache__/workbuddy.cpython-39.pyc +0 -0
- package/vod_mcp/host_adapters/base.py +3 -1
- package/vod_mcp/host_adapters/hermes.py +88 -11
- package/vod_mcp/hosts.py +3 -1
- package/vod_mcp/net.py +251 -0
- package/vod_mcp/packs/__pycache__/__init__.cpython-314.pyc +0 -0
- package/vod_mcp/packs/__pycache__/__init__.cpython-39.pyc +0 -0
- package/vod_mcp/packs/__pycache__/collect.cpython-314.pyc +0 -0
- package/vod_mcp/packs/__pycache__/collect.cpython-39.pyc +0 -0
- package/vod_mcp/packs/__pycache__/core.cpython-314.pyc +0 -0
- package/vod_mcp/packs/__pycache__/core.cpython-39.pyc +0 -0
- package/vod_mcp/packs/__pycache__/knowledge.cpython-314.pyc +0 -0
- package/vod_mcp/packs/__pycache__/knowledge.cpython-39.pyc +0 -0
- package/vod_mcp/packs/collect.py +684 -0
- package/vod_mcp/packs/core.py +80 -0
- package/vod_mcp/packs/knowledge.py +17 -0
- package/vod_mcp/paths.py +38 -0
- package/vod_mcp/payload.py +3 -1
- package/vod_mcp/policy.py +3 -2
- package/vod_mcp/provenance.py +3 -2
- package/vod_mcp/runtime_state.py +324 -0
- package/vod_mcp/server.py +10 -7
- package/vod_mcp/skills_registry.py +5 -4
- package/vod_mcp/tools.py +23 -1298
- package/vod_mcp/transport_remote.py +21 -9
- package/vod_mcp/update_check.py +1 -1
- package/vodkit_cli/__init__.py +10 -0
- package/vodkit_cli/__pycache__/__init__.cpython-314.pyc +0 -0
- package/vodkit_cli/__pycache__/__init__.cpython-39.pyc +0 -0
- package/vodkit_cli/__pycache__/cli.cpython-314.pyc +0 -0
- package/vodkit_cli/__pycache__/cli.cpython-39.pyc +0 -0
- package/vodkit_cli/__pycache__/common.cpython-314.pyc +0 -0
- package/vodkit_cli/__pycache__/common.cpython-39.pyc +0 -0
- package/vodkit_cli/__pycache__/doctor.cpython-314.pyc +0 -0
- package/vodkit_cli/__pycache__/doctor.cpython-39.pyc +0 -0
- package/vodkit_cli/__pycache__/install.cpython-314.pyc +0 -0
- package/vodkit_cli/__pycache__/install.cpython-39.pyc +0 -0
- package/vodkit_cli/__pycache__/remote.cpython-314.pyc +0 -0
- package/vodkit_cli/__pycache__/remote.cpython-39.pyc +0 -0
- package/vodkit_cli/__pycache__/uninstall.cpython-314.pyc +0 -0
- package/vodkit_cli/__pycache__/uninstall.cpython-39.pyc +0 -0
- package/vodkit_cli/__pycache__/update.cpython-314.pyc +0 -0
- package/vodkit_cli/__pycache__/update.cpython-39.pyc +0 -0
- package/vodkit_cli/cli.py +86 -0
- package/vodkit_cli/common.py +254 -0
- package/vodkit_cli/doctor.py +269 -0
- package/vodkit_cli/install.py +260 -0
- package/vodkit_cli/remote.py +200 -0
- package/vodkit_cli/uninstall.py +161 -0
- package/vodkit_cli/update.py +45 -0
- /package/plugins/vod-devkit/vod_mcp/{packs.py → packs/__init__.py} +0 -0
- /package/vod_mcp/{packs.py → packs/__init__.py} +0 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"""远程面探活与安装期校验(远程 attach / 产品名录硬校验)。"""
|
|
2
|
+
import json
|
|
3
|
+
import os
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
from vodkit_cli import common
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def _expected_remote_tools() -> set:
|
|
10
|
+
"""远程面应当暴露的工具集 = 契约全集 - REMOTE_WITHHELD(写面本机工具不进远程)。"""
|
|
11
|
+
from vod_mcp import packs as _packs
|
|
12
|
+
contract = json.loads((common.ROOT / "contract" / "tools.schema.json").read_text(encoding="utf-8"))
|
|
13
|
+
return set(contract["tools"]) - set(_packs.REMOTE_WITHHELD)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _probe_remote(url: str, token: str, timeout: int = 15,
|
|
17
|
+
verify_token: bool = True) -> list:
|
|
18
|
+
"""远程 MCP 端点探活:initialize + tools/list,返回工具名清单(失败抛 RuntimeError)。
|
|
19
|
+
|
|
20
|
+
走 stdlib urllib(安装器零第三方依赖红线);Accept 双类型,兼容 SSE 单事件响应。
|
|
21
|
+
探活在**写入任何配置之前**执行——装不上就不留半成品。
|
|
22
|
+
|
|
23
|
+
B2(2026-11-13 真机实锤):握手+工具面是连接级,token 有效性没验——坏 key
|
|
24
|
+
照样装上,用户首次提交才发现 401。与"--product fail fast(归因错误比报错
|
|
25
|
+
糟)"纪律不对称。verify_token=True 时追加第 3 步:经远程面真调一次
|
|
26
|
+
vod_auth_status(远程面把请求头 Bearer 透传引擎做 keyCheck 探针),引擎判
|
|
27
|
+
无效(探针回 rejected)→ RuntimeError 拒装;探针不可达(引擎/网络问题)→
|
|
28
|
+
放行(网络问题不是 key 问题,不许误伤断网环境安装)。doctor 的旧调用途
|
|
29
|
+
(用户可能没配 token)与安装期不同,verify_token=False 保持旧连接级语义。
|
|
30
|
+
"""
|
|
31
|
+
import urllib.request
|
|
32
|
+
|
|
33
|
+
def _post(payload: dict) -> dict:
|
|
34
|
+
req = urllib.request.Request(
|
|
35
|
+
url, data=json.dumps(payload).encode(), method="POST",
|
|
36
|
+
headers={"content-type": "application/json",
|
|
37
|
+
"accept": "application/json, text/event-stream",
|
|
38
|
+
**({"Authorization": f"Bearer {token}"} if token else {})})
|
|
39
|
+
with urllib.request.urlopen(req, timeout=timeout) as resp:
|
|
40
|
+
body = resp.read().decode("utf-8", "replace")
|
|
41
|
+
if body.startswith("event:") or body.startswith("data:"):
|
|
42
|
+
for line in body.splitlines():
|
|
43
|
+
if line.startswith("data:"):
|
|
44
|
+
body = line[5:].strip()
|
|
45
|
+
break
|
|
46
|
+
data = json.loads(body or "{}")
|
|
47
|
+
if isinstance(data, dict) and data.get("error"):
|
|
48
|
+
raise RuntimeError(f"JSON-RPC 错误:{data['error']}")
|
|
49
|
+
return data
|
|
50
|
+
|
|
51
|
+
_post({"jsonrpc": "2.0", "id": 1, "method": "initialize",
|
|
52
|
+
"params": {"protocolVersion": "2025-06-18",
|
|
53
|
+
"clientInfo": {"name": "vod-devkit-installer", "version": "1"},
|
|
54
|
+
"capabilities": {}}})
|
|
55
|
+
_post({"jsonrpc": "2.0", "method": "notifications/initialized"})
|
|
56
|
+
listed = _post({"jsonrpc": "2.0", "id": 2, "method": "tools/list"})
|
|
57
|
+
names = [t.get("name") for t in (listed.get("result") or {}).get("tools") or []]
|
|
58
|
+
if not names:
|
|
59
|
+
raise RuntimeError("tools/list 返回空——端点可能不是 Streamable HTTP MCP")
|
|
60
|
+
if verify_token and token and "vod_auth_status" in names:
|
|
61
|
+
_probe_remote_token(url, token, timeout)
|
|
62
|
+
return names
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def _probe_remote_token(url: str, token: str, timeout: int) -> None:
|
|
66
|
+
"""B2 第 3 步:经远程面真调 vod_auth_status 验 token(引擎是唯一权威)。
|
|
67
|
+
|
|
68
|
+
远程面把请求头 Bearer 透传给 keyCheck 探针打引擎 GET /external/meta:
|
|
69
|
+
- keyCheck.ok=True(verified)→ 通过
|
|
70
|
+
- keyCheck.reason=rejected → RuntimeError(坏 key 拒装,零副作用)
|
|
71
|
+
- reason ∈ {no-key, unreachable, expired-anonymous, device-mismatch} 或
|
|
72
|
+
keyCheck 缺失/探针不可用 → 放行(无法验证≠无效;三态判定语义与
|
|
73
|
+
tools.probe_key 一致——device-mismatch 是匿名令牌设备锚点漂移的正常
|
|
74
|
+
场景:token 有效只是本机不是签发设备,提交时会自动重领)
|
|
75
|
+
"""
|
|
76
|
+
import urllib.request
|
|
77
|
+
import urllib.error
|
|
78
|
+
|
|
79
|
+
def _post(payload: dict) -> dict:
|
|
80
|
+
req = urllib.request.Request(
|
|
81
|
+
url, data=json.dumps(payload).encode(), method="POST",
|
|
82
|
+
headers={"content-type": "application/json",
|
|
83
|
+
"accept": "application/json, text/event-stream",
|
|
84
|
+
"Authorization": f"Bearer {token}"})
|
|
85
|
+
with urllib.request.urlopen(req, timeout=timeout) as resp:
|
|
86
|
+
body = resp.read().decode("utf-8", "replace")
|
|
87
|
+
if body.startswith("event:") or body.startswith("data:"):
|
|
88
|
+
for line in body.splitlines():
|
|
89
|
+
if line.startswith("data:"):
|
|
90
|
+
body = line[5:].strip()
|
|
91
|
+
break
|
|
92
|
+
data = json.loads(body or "{}")
|
|
93
|
+
if isinstance(data, dict) and data.get("error"):
|
|
94
|
+
raise RuntimeError(f"JSON-RPC 错误:{data['error']}")
|
|
95
|
+
return data
|
|
96
|
+
|
|
97
|
+
_post({"jsonrpc": "2.0", "id": 10, "method": "initialize",
|
|
98
|
+
"params": {"protocolVersion": "2025-06-18",
|
|
99
|
+
"clientInfo": {"name": "vod-devkit-installer", "version": "1"},
|
|
100
|
+
"capabilities": {}}})
|
|
101
|
+
_post({"jsonrpc": "2.0", "method": "notifications/initialized"})
|
|
102
|
+
called = _post({"jsonrpc": "2.0", "id": 11, "method": "tools/call",
|
|
103
|
+
"params": {"name": "vod_auth_status", "arguments": {}}})
|
|
104
|
+
content = ((called.get("result") or {}).get("content") or [{}])[0]
|
|
105
|
+
try:
|
|
106
|
+
status = json.loads(content.get("text") or "{}")
|
|
107
|
+
except ValueError:
|
|
108
|
+
return # 回执异常(旧版远程面等):无法验证≠无效,放行
|
|
109
|
+
check = status.get("keyCheck")
|
|
110
|
+
if not isinstance(check, dict):
|
|
111
|
+
return # 远程面未透传 keyCheck(旧版):连接级已过,放行
|
|
112
|
+
if check.get("reason") == "rejected":
|
|
113
|
+
fp = check.get("fingerprint")
|
|
114
|
+
raise RuntimeError(
|
|
115
|
+
f"token 无效(引擎判定 rejected,指纹 {fp})——"
|
|
116
|
+
"请确认 VOD 平台签发的 key;探活先于写入,未装任何配置")
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def _remote_reachable(url: str, timeout: int = 6) -> bool:
|
|
120
|
+
"""端点是否可达:GET 得到任何 HTTP 响应(405 是远程面契约的正常应答)即算通。"""
|
|
121
|
+
import urllib.error
|
|
122
|
+
import urllib.request
|
|
123
|
+
try:
|
|
124
|
+
with urllib.request.urlopen(url, timeout=timeout):
|
|
125
|
+
return True
|
|
126
|
+
except urllib.error.HTTPError:
|
|
127
|
+
return True # 405/401/406 都证明端点活着
|
|
128
|
+
except Exception:
|
|
129
|
+
return False
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def _validate_product_or_exit(product: str, base: str) -> bool:
|
|
133
|
+
"""D-product-id-2:安装期产品硬校验(B 案,2026-11-05 拍板)。
|
|
134
|
+
--product 命中 meta productCatalog(名字大小写不敏感或 id 精确)才放行;
|
|
135
|
+
未命中/目录不可达一律拒绝安装并给可执行引导(宁可不装不可装错)。"""
|
|
136
|
+
import urllib.request
|
|
137
|
+
import urllib.error
|
|
138
|
+
import uuid
|
|
139
|
+
api_prefix = "/rest/developer/manager/hdvodmngservice/v1"
|
|
140
|
+
key = os.environ.get("VOD_JAVA_API_KEY", "")
|
|
141
|
+
token = ""
|
|
142
|
+
# 全程一致的设备锚点(S1 设备绑定:token 与后续请求必须同 device/UA,
|
|
143
|
+
# 否则 meta 401 设备不匹配;每次装机一个新锚点,一次校验只耗一枚令牌)
|
|
144
|
+
device = uuid.uuid4().hex[:32]
|
|
145
|
+
ua = "vod-devkit-installer/1"
|
|
146
|
+
|
|
147
|
+
def _get(url: str):
|
|
148
|
+
auth = key or token
|
|
149
|
+
req = urllib.request.Request(url, headers={
|
|
150
|
+
"content-type": "application/json",
|
|
151
|
+
"X-Vod-Device-Id": device,
|
|
152
|
+
"User-Agent": ua,
|
|
153
|
+
**({"authorization": f"Bearer {auth}"} if auth else {}),
|
|
154
|
+
})
|
|
155
|
+
with urllib.request.urlopen(req, timeout=10) as resp:
|
|
156
|
+
return resp.status, resp.read().decode("utf-8", "replace")
|
|
157
|
+
|
|
158
|
+
try:
|
|
159
|
+
if not key:
|
|
160
|
+
req = urllib.request.Request( # 零字段匿名令牌(方案 C 同链)
|
|
161
|
+
f"{base}{api_prefix}/external/token", data=b"{}",
|
|
162
|
+
headers={"content-type": "application/json", "X-Vod-Device-Id": device,
|
|
163
|
+
"User-Agent": ua}, method="POST")
|
|
164
|
+
with urllib.request.urlopen(req, timeout=10) as resp:
|
|
165
|
+
body = json.loads(resp.read().decode("utf-8", "replace") or "{}")
|
|
166
|
+
token = (body.get("data") or {}).get("token") or body.get("token") or ""
|
|
167
|
+
catalog = None
|
|
168
|
+
status, text = _get(f"{base}{api_prefix}/external/meta")
|
|
169
|
+
data = (json.loads(text) or {}).get("data") or {}
|
|
170
|
+
catalog = data.get("productCatalog")
|
|
171
|
+
if not catalog and token: # 老引擎 meta 无目录 → 退 /external/products
|
|
172
|
+
status, text = _get(f"{base}{api_prefix}/external/products") if not key else (None, None)
|
|
173
|
+
if text:
|
|
174
|
+
data = (json.loads(text) or {}).get("data") or []
|
|
175
|
+
catalog = data
|
|
176
|
+
if not catalog:
|
|
177
|
+
print("[vod-devkit] 产品校验失败:引擎 meta 无 productCatalog 且 /external/products 不可用。\n"
|
|
178
|
+
" 不执行安装(宁可不装不可装错)。请核对 --java-api-base 指向的引擎是否已部署 T7i 版本。",
|
|
179
|
+
file=sys.stderr)
|
|
180
|
+
sys.exit(2)
|
|
181
|
+
p = product.strip()
|
|
182
|
+
hit = any(
|
|
183
|
+
(str(x.get("name") or "").lower() == p.lower())
|
|
184
|
+
or (str(x.get("id")) == p)
|
|
185
|
+
for x in catalog if isinstance(x, dict))
|
|
186
|
+
if not hit:
|
|
187
|
+
sample = " / ".join(str(x.get("name")) for x in catalog[:8] if isinstance(x, dict))
|
|
188
|
+
print(f"[vod-devkit] --product '{product}' 不在产品名录(t_vod_product),拒绝安装。\n"
|
|
189
|
+
" 归因前提无效=内置采集技能/分类/透传全部空转且用户无感知(归因错误比报错更糟)。\n"
|
|
190
|
+
f" 权威名单:GET {api_prefix}/external/products(共 {len(catalog)} 项),示例:{sample} …",
|
|
191
|
+
file=sys.stderr)
|
|
192
|
+
sys.exit(2)
|
|
193
|
+
return True
|
|
194
|
+
except SystemExit:
|
|
195
|
+
raise
|
|
196
|
+
except Exception as e:
|
|
197
|
+
print(f"[vod-devkit] 产品校验不可达({e.__class__.__name__}),拒绝安装(宁可不装不可装错)。\n"
|
|
198
|
+
" 请核对网络与 --java-api-base;确需离线安装请联系 VOD 运营。",
|
|
199
|
+
file=sys.stderr)
|
|
200
|
+
sys.exit(2)
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"""uninstall 子命令:按 manifest 名册逐宿主摘除(共享配置只摘条目)。"""
|
|
2
|
+
import json
|
|
3
|
+
import shutil
|
|
4
|
+
import subprocess
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
from vod_mcp import hosts as host_specs
|
|
8
|
+
from vodkit_cli import common
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
_SHARED_CONFIG_NAMES = {"config.toml", "config.yaml", "config.yml",
|
|
12
|
+
"opencode.json", "opencode.jsonc"}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _remove_managed_mcp_entry(target: str, path: Path) -> None:
|
|
16
|
+
"""从宿主共享配置里摘掉 vod-devkit 条目(保留其它键/其它 server)。"""
|
|
17
|
+
section = {"opencode": "mcp", "codeartsdoer": "mcp", "codeartswork": "mcp",
|
|
18
|
+
"generic": "mcpServers", "workbuddy": "mcpServers",
|
|
19
|
+
"atomcode": "mcpServers"}.get(target)
|
|
20
|
+
if section:
|
|
21
|
+
if not path.exists():
|
|
22
|
+
return
|
|
23
|
+
try:
|
|
24
|
+
cfg = json.loads(path.read_text(encoding="utf-8"))
|
|
25
|
+
except Exception:
|
|
26
|
+
print(f"skip({path} 不是合法 JSON,未改动)")
|
|
27
|
+
return
|
|
28
|
+
block = cfg.get(section) or {}
|
|
29
|
+
if "vod-devkit" not in block:
|
|
30
|
+
return
|
|
31
|
+
block.pop("vod-devkit")
|
|
32
|
+
if not block:
|
|
33
|
+
cfg.pop(section, None)
|
|
34
|
+
else:
|
|
35
|
+
cfg[section] = block
|
|
36
|
+
path.write_text(json.dumps(cfg, ensure_ascii=False, indent=2), encoding="utf-8")
|
|
37
|
+
print(f"removed {section}.vod-devkit: {path}")
|
|
38
|
+
return
|
|
39
|
+
cli: str | None = None
|
|
40
|
+
args: list[str] = []
|
|
41
|
+
if target == "hermes" and shutil.which("hermes"):
|
|
42
|
+
cli, args = "hermes", ["mcp", "remove", "vod-devkit"]
|
|
43
|
+
elif target == "codex" and shutil.which("codex"):
|
|
44
|
+
cli, args = "codex", ["mcp", "remove", "vod-devkit"]
|
|
45
|
+
if cli:
|
|
46
|
+
r = subprocess.run([cli, *args], capture_output=True, text=True, timeout=120)
|
|
47
|
+
print(f"{cli} mcp remove:", "OK" if r.returncode == 0
|
|
48
|
+
else (r.stderr or r.stdout).strip()[-120:])
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def _remove_managed_skills(mf: dict, path: Path, target: str) -> None:
|
|
52
|
+
"""技能摘除:hermes 目录是专属的(整目录删);其它宿主技能目录是**共享**的
|
|
53
|
+
(opencode ~/.config/opencode/skills 等),只摘本插件改名下的技能。
|
|
54
|
+
2026-11-11 与 uninstall 共享配置收口同批修:整目录删会连带删掉用户的其它技能。"""
|
|
55
|
+
if target == "hermes":
|
|
56
|
+
if path.exists():
|
|
57
|
+
shutil.rmtree(path)
|
|
58
|
+
print("removed:", path)
|
|
59
|
+
return
|
|
60
|
+
names = {rel.split("/")[0] for rel in (mf.get("skillHashes") or {})}
|
|
61
|
+
removed = []
|
|
62
|
+
for n in sorted(names):
|
|
63
|
+
d = path / n
|
|
64
|
+
if d.is_dir():
|
|
65
|
+
shutil.rmtree(d)
|
|
66
|
+
removed.append(n)
|
|
67
|
+
print(f"removed skills: {removed}(共享目录保留):{path}") if removed \
|
|
68
|
+
else print(f"skip(无需摘除的技能):{path}")
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def _cleanup_install_row(row: dict, skill_hashes: dict | None = None) -> None:
|
|
72
|
+
"""按一条安装记录清理:MCP 条目 / 技能落点 / 宿主专属产物。
|
|
73
|
+
|
|
74
|
+
技能名清单来自 manifest 顶层 skillHashes(各安装行共用同一份技能集合)。
|
|
75
|
+
"""
|
|
76
|
+
target = str(row.get("target") or "") # 名册老条目可能缺 target:按空串走"未知宿主"分支
|
|
77
|
+
# codex-desktop:mcpConfig 指向共享的 marketplace.json,绝不能走"整文件删"分支
|
|
78
|
+
# (那会删掉用户/其它插件的市场登记)。交给适配器只摘自己那一条 + 删插件目录。
|
|
79
|
+
if target == "codex-desktop":
|
|
80
|
+
from vod_mcp.host_adapters import codex_desktop as _cd
|
|
81
|
+
_cd.uninstall()
|
|
82
|
+
return
|
|
83
|
+
mf = dict(row)
|
|
84
|
+
mf["skillHashes"] = skill_hashes or {}
|
|
85
|
+
for key in ("mcpConfig", "skillsDir"):
|
|
86
|
+
path_s = row.get(key)
|
|
87
|
+
if not path_s:
|
|
88
|
+
continue # codex 等宿主 mcpConfig 可为 None(P0-3:无托管配置文件)
|
|
89
|
+
if key == "skillsDir":
|
|
90
|
+
_remove_managed_skills(mf, Path(path_s), target)
|
|
91
|
+
continue
|
|
92
|
+
path = Path(path_s)
|
|
93
|
+
# 深审 P0-3(破坏性路径一票否决):共享用户配置永不整文件删除
|
|
94
|
+
#(config.toml/opencode.json/codearts_cli.json/.claude.json 里有用户自己的
|
|
95
|
+
# provider、其它 server)。JSON 合并型宿主一律走"摘条目",与文件名无关——
|
|
96
|
+
# codearts_cli.json 第一版没进 _SHARED_CONFIG_NAMES,卸载把整份配置删了(实锤)。
|
|
97
|
+
if target in ("opencode", "codeartsdoer", "codeartswork", "generic",
|
|
98
|
+
"workbuddy", "atomcode") or path.name in _SHARED_CONFIG_NAMES:
|
|
99
|
+
print(f"skip(用户配置文件,uninstall 只摘托管条目):{path}")
|
|
100
|
+
_remove_managed_mcp_entry(target, path)
|
|
101
|
+
continue
|
|
102
|
+
if path.exists():
|
|
103
|
+
shutil.rmtree(path) if path.is_dir() else path.unlink()
|
|
104
|
+
print("removed:", path)
|
|
105
|
+
# codex 摘除:remote 形态摘 MCP 条目;stdio 形态摘原生插件(best-effort)
|
|
106
|
+
if target == "codex":
|
|
107
|
+
codex = shutil.which("codex")
|
|
108
|
+
if codex and (row.get("transport") or "stdio") == "remote":
|
|
109
|
+
_remove_managed_mcp_entry("codex", Path.home() / ".codex" / "config.toml")
|
|
110
|
+
elif codex:
|
|
111
|
+
r = subprocess.run([codex, "plugin", "remove", "vod-devkit@vod-local"],
|
|
112
|
+
capture_output=True, text=True, timeout=120)
|
|
113
|
+
print("codex plugin remove:",
|
|
114
|
+
"OK" if r.returncode == 0 else (r.stderr or r.stdout).strip()[-120:])
|
|
115
|
+
# opencode 随装生成物(/vod-doctor 命令)
|
|
116
|
+
if target == "opencode":
|
|
117
|
+
for g in host_specs.load("opencode")["generated"]:
|
|
118
|
+
gen = Path(g["dest"])
|
|
119
|
+
if gen.exists():
|
|
120
|
+
gen.unlink()
|
|
121
|
+
print("removed:", gen)
|
|
122
|
+
# dsh 壳(D-dsh-install-1):摘插件 + 从 profile patch 移除 config 段
|
|
123
|
+
if target == "dsh":
|
|
124
|
+
dsh = shutil.which("dsh")
|
|
125
|
+
prof = (row.get("dshProfile") or "").strip()
|
|
126
|
+
if dsh and prof:
|
|
127
|
+
subprocess.run([dsh, "plugin", "--profile", prof, "remove",
|
|
128
|
+
"dsh-vod-devkit"], capture_output=True, text=True)
|
|
129
|
+
if prof: # 无 profile 记录=没写过 patch,无需(也无法)摘除
|
|
130
|
+
patch_path = Path(host_specs.load("dsh", prof)["configPath"])
|
|
131
|
+
from vod_mcp.host_adapters import dsh as dsh_adapter
|
|
132
|
+
if dsh_adapter.remove_patch_block(patch_path):
|
|
133
|
+
print("removed vod-devkit config block:", patch_path)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def cmd_uninstall(_args):
|
|
137
|
+
p = common.manifest_path()
|
|
138
|
+
if not p.exists():
|
|
139
|
+
print("未安装")
|
|
140
|
+
return
|
|
141
|
+
mf = json.loads(p.read_text(encoding="utf-8"))
|
|
142
|
+
rows = mf.get("installs") or [mf] # 老 manifest(无 installs[])退化为单条
|
|
143
|
+
for row in rows:
|
|
144
|
+
_cleanup_install_row(row, mf.get("skillHashes"))
|
|
145
|
+
# 载荷清理(D-payload-1):所有安装记录共用的副本,逐目录去重后删,再删 marker
|
|
146
|
+
from vod_mcp import payload as _payload
|
|
147
|
+
seen = set()
|
|
148
|
+
for row in rows:
|
|
149
|
+
pd = row.get("payloadDir")
|
|
150
|
+
if not pd or pd in seen:
|
|
151
|
+
continue
|
|
152
|
+
seen.add(pd)
|
|
153
|
+
if Path(pd).is_dir():
|
|
154
|
+
shutil.rmtree(pd, ignore_errors=True)
|
|
155
|
+
print("removed payload:", pd)
|
|
156
|
+
try:
|
|
157
|
+
_payload.marker_path().unlink(missing_ok=True)
|
|
158
|
+
except Exception:
|
|
159
|
+
pass
|
|
160
|
+
p.unlink()
|
|
161
|
+
print("removed:", p)
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""update 子命令:git fetch/ff 拉取 + build-info 重烧 + 版本跳过状态。"""
|
|
2
|
+
import subprocess
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
from vodkit_cli import common
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def cmd_update(args=None):
|
|
9
|
+
"""更新:git fetch 比较 origin/main,落后则 ff 拉取并重烧 build-info。
|
|
10
|
+
|
|
11
|
+
--skip / --clear-skip(D-devtoolchain-7,对齐 devkit update-skip 裁剪版):
|
|
12
|
+
只维护「跳过某个版本提醒」的运行时状态,不动代码——所以放在 git 拉取之前返回。
|
|
13
|
+
"""
|
|
14
|
+
if getattr(args, "skip", False) or getattr(args, "clear_skip", False):
|
|
15
|
+
from vod_mcp import update_check as uc
|
|
16
|
+
out = uc.check({"clearSkip": True} if getattr(args, "clear_skip", False)
|
|
17
|
+
else {"skip": True})
|
|
18
|
+
print(out.get("note") or "")
|
|
19
|
+
if out.get("latestVersion"):
|
|
20
|
+
print(f"latest = {out['latestVersion']}(clearSkip=true 可撤销)")
|
|
21
|
+
return
|
|
22
|
+
if common._distribution() == "preset":
|
|
23
|
+
# D-key-guard-3②:产品分发形态插件版本随 agent 发版管理,客户机禁止自更新
|
|
24
|
+
#(绕过产品版本管理=未测试代码进客户现场)
|
|
25
|
+
print("产品分发形态(preset)不支持自更新:插件版本随 agent 发版管理。"
|
|
26
|
+
"如需升级请联系产品提供方发布新版本。")
|
|
27
|
+
return
|
|
28
|
+
subprocess.run(["git", "fetch", "origin", "--tags"], cwd=common.ROOT, capture_output=True)
|
|
29
|
+
local = subprocess.run(["git", "rev-parse", "HEAD"], cwd=common.ROOT,
|
|
30
|
+
capture_output=True, text=True).stdout.strip()
|
|
31
|
+
remote = subprocess.run(["git", "rev-parse", "origin/main"], cwd=common.ROOT,
|
|
32
|
+
capture_output=True, text=True).stdout.strip()
|
|
33
|
+
if local == remote:
|
|
34
|
+
print(f"已是最新({local[:12]})")
|
|
35
|
+
return
|
|
36
|
+
r = subprocess.run(["git", "pull", "--ff-only"], cwd=common.ROOT,
|
|
37
|
+
capture_output=True, text=True)
|
|
38
|
+
if r.returncode != 0:
|
|
39
|
+
print("更新失败(有本地改动阻挡 ff?):", r.stderr.strip()[:200])
|
|
40
|
+
sys.exit(1)
|
|
41
|
+
print(f"已更新 {local[:12]} → {remote[:12]}")
|
|
42
|
+
common.write_build_info(strict=False)
|
|
43
|
+
print("build-info 已重烧;如需重新安装执行:")
|
|
44
|
+
print(f" {sys.argv[0]} install --target hermes --preset collect --product <产品名>")
|
|
45
|
+
print(" 并重启 agent 会话")
|
|
File without changes
|
|
File without changes
|