vod-devkit 0.5.9 → 0.5.11
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 +58 -0
- package/QUICKSTART.md +6 -2
- package/README.en.md +23 -2
- package/README.md +204 -16
- package/{contract → assets/contract}/tools.schema.json +127 -1
- package/{skills → assets/skills}/vod-core/SKILL.md +32 -1
- package/bin/vod-devkit +21 -1
- package/integrations/hermes/hooks/vod_guard.py +127 -0
- package/integrations/hermes/hooks/vod_router.py +89 -0
- package/integrations/hermes/host.json +4 -1
- package/npm/cli.js +6 -1
- package/package.json +37 -34
- package/packages/dsh/README.md +60 -0
- package/packages/dsh/package.json +52 -0
- package/plugins/vod-devkit/.codex-plugin/plugin.json +1 -1
- package/plugins/vod-devkit/.mcp.json +2 -0
- package/plugins/vod-devkit/build-info.json +3 -3
- package/plugins/vod-devkit/contract/tools.schema.json +127 -1
- package/plugins/vod-devkit/hooks/vod_guard.py +127 -0
- package/plugins/vod-devkit/hooks/vod_router.py +89 -0
- package/plugins/vod-devkit/skills/vod-core/SKILL.md +32 -1
- package/plugins/vod-devkit/vod_mcp/__init__.py +1 -1
- package/plugins/vod-devkit/vod_mcp/attribution.py +21 -2
- package/plugins/vod-devkit/vod_mcp/config_forms.py +22 -6
- package/plugins/vod-devkit/vod_mcp/diagnose.py +4 -2
- package/plugins/vod-devkit/vod_mcp/host_adapters/base.py +4 -1
- package/plugins/vod-devkit/vod_mcp/host_adapters/codex.py +154 -34
- package/plugins/vod-devkit/vod_mcp/host_adapters/dsh.py +133 -22
- package/plugins/vod-devkit/vod_mcp/host_adapters/hermes.py +216 -59
- package/plugins/vod-devkit/vod_mcp/host_adapters/opencode.py +10 -4
- package/plugins/vod-devkit/vod_mcp/hosts.py +4 -0
- package/plugins/vod-devkit/vod_mcp/net.py +78 -18
- package/plugins/vod-devkit/vod_mcp/packs/__init__.py +97 -22
- package/plugins/vod-devkit/vod_mcp/packs/collect.py +50 -42
- package/plugins/vod-devkit/vod_mcp/packs/core.py +138 -2
- package/plugins/vod-devkit/vod_mcp/paths.py +200 -30
- package/plugins/vod-devkit/vod_mcp/payload.py +10 -5
- package/plugins/vod-devkit/vod_mcp/provenance.py +1 -1
- package/plugins/vod-devkit/vod_mcp/remote_app.py +4 -4
- package/plugins/vod-devkit/vod_mcp/runtime_state.py +151 -28
- package/plugins/vod-devkit/vod_mcp/server.py +52 -7
- package/plugins/vod-devkit/vod_mcp/skills_registry.py +29 -8
- package/plugins/vod-devkit/vod_mcp/tools.py +21 -3
- package/plugins/vod-devkit/vod_mcp/transport_remote.py +22 -3
- package/{vod_mcp → src/vod_mcp}/__init__.py +1 -1
- package/{vod_mcp → src/vod_mcp}/attribution.py +21 -2
- package/{vod_mcp → src/vod_mcp}/config_forms.py +22 -6
- package/{vod_mcp → src/vod_mcp}/diagnose.py +4 -2
- package/{vod_mcp → src/vod_mcp}/host_adapters/base.py +4 -1
- package/{vod_mcp → src/vod_mcp}/host_adapters/codex.py +154 -34
- package/{vod_mcp → src/vod_mcp}/host_adapters/dsh.py +133 -22
- package/src/vod_mcp/host_adapters/hermes.py +361 -0
- package/{vod_mcp → src/vod_mcp}/host_adapters/opencode.py +10 -4
- package/{vod_mcp → src/vod_mcp}/hosts.py +4 -0
- package/{vod_mcp → src/vod_mcp}/net.py +78 -18
- package/src/vod_mcp/packs/__init__.py +142 -0
- package/{vod_mcp → src/vod_mcp}/packs/collect.py +50 -42
- package/src/vod_mcp/packs/core.py +216 -0
- package/src/vod_mcp/paths.py +208 -0
- package/{vod_mcp → src/vod_mcp}/payload.py +10 -5
- package/{vod_mcp → src/vod_mcp}/provenance.py +1 -1
- package/{vod_mcp → src/vod_mcp}/remote_app.py +4 -4
- package/{vod_mcp → src/vod_mcp}/runtime_state.py +151 -28
- package/{vod_mcp → src/vod_mcp}/server.py +52 -7
- package/{vod_mcp → src/vod_mcp}/skills_registry.py +29 -8
- package/{vod_mcp → src/vod_mcp}/tools.py +21 -3
- package/{vod_mcp → src/vod_mcp}/transport_remote.py +22 -3
- package/src/vodkit_cli/auth_cmd.py +81 -0
- package/{vodkit_cli → src/vodkit_cli}/cli.py +38 -8
- package/{vodkit_cli → src/vodkit_cli}/common.py +14 -3
- package/{vodkit_cli → src/vodkit_cli}/doctor.py +147 -9
- package/{vodkit_cli → src/vodkit_cli}/install.py +148 -33
- package/src/vodkit_cli/packs_cmd.py +329 -0
- package/{vodkit_cli → src/vodkit_cli}/remote.py +3 -3
- package/src/vodkit_cli/uninstall.py +315 -0
- package/vod_mcp/host_adapters/__pycache__/__init__.cpython-314.pyc +0 -0
- package/vod_mcp/host_adapters/__pycache__/__init__.cpython-39.pyc +0 -0
- package/vod_mcp/host_adapters/__pycache__/atomcode.cpython-314.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-314.pyc +0 -0
- package/vod_mcp/host_adapters/__pycache__/codearts.cpython-39.pyc +0 -0
- package/vod_mcp/host_adapters/__pycache__/codeartswork.cpython-314.pyc +0 -0
- package/vod_mcp/host_adapters/__pycache__/codeartswork.cpython-39.pyc +0 -0
- package/vod_mcp/host_adapters/__pycache__/codex.cpython-314.pyc +0 -0
- package/vod_mcp/host_adapters/__pycache__/codex.cpython-39.pyc +0 -0
- package/vod_mcp/host_adapters/__pycache__/codex_desktop.cpython-314.pyc +0 -0
- package/vod_mcp/host_adapters/__pycache__/codex_desktop.cpython-39.pyc +0 -0
- package/vod_mcp/host_adapters/__pycache__/dsh.cpython-314.pyc +0 -0
- package/vod_mcp/host_adapters/__pycache__/dsh.cpython-39.pyc +0 -0
- package/vod_mcp/host_adapters/__pycache__/generic.cpython-314.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-314.pyc +0 -0
- package/vod_mcp/host_adapters/__pycache__/opencode.cpython-39.pyc +0 -0
- package/vod_mcp/host_adapters/__pycache__/workbuddy.cpython-314.pyc +0 -0
- package/vod_mcp/host_adapters/__pycache__/workbuddy.cpython-39.pyc +0 -0
- package/vod_mcp/host_adapters/hermes.py +0 -204
- package/vod_mcp/packs/__init__.py +0 -67
- 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/core.py +0 -80
- package/vod_mcp/paths.py +0 -38
- 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/uninstall.py +0 -161
- /package/{safety → assets/safety}/policy.json +0 -0
- /package/{skills → assets/skills}/vod-core/references/acceptance-criteria.md +0 -0
- /package/{skills → assets/skills}/vod-core/references/verification-method.md +0 -0
- /package/{skills → assets/skills}/vod-feedback-collect/SKILL.md +0 -0
- /package/{skills → assets/skills}/vod-feedback-collect/references/acceptance-criteria.md +0 -0
- /package/{skills → assets/skills}/vod-feedback-collect/references/verification-method.md +0 -0
- /package/{skills → assets/skills}/vod-problem-classification-rules/SKILL.md +0 -0
- /package/{skills → assets/skills}/vod-scoring-rules/SKILL.md +0 -0
- /package/{vod_mcp → src/vod_mcp}/detect_framework.py +0 -0
- /package/{vod_mcp → src/vod_mcp}/guardrails.py +0 -0
- /package/{vod_mcp → src/vod_mcp}/host_adapters/__init__.py +0 -0
- /package/{vod_mcp → src/vod_mcp}/host_adapters/atomcode.py +0 -0
- /package/{vod_mcp → src/vod_mcp}/host_adapters/codearts.py +0 -0
- /package/{vod_mcp → src/vod_mcp}/host_adapters/codeartswork.py +0 -0
- /package/{vod_mcp → src/vod_mcp}/host_adapters/codex_desktop.py +0 -0
- /package/{vod_mcp → src/vod_mcp}/host_adapters/generic.py +0 -0
- /package/{vod_mcp → src/vod_mcp}/host_adapters/workbuddy.py +0 -0
- /package/{vod_mcp → src/vod_mcp}/packs/knowledge.py +0 -0
- /package/{vod_mcp → src/vod_mcp}/pending.py +0 -0
- /package/{vod_mcp → src/vod_mcp}/policy.py +0 -0
- /package/{vod_mcp → src/vod_mcp}/runtime.example.json +0 -0
- /package/{vod_mcp → src/vod_mcp}/update_check.py +0 -0
- /package/{vodkit_cli → src/vodkit_cli}/__init__.py +0 -0
- /package/{vodkit_cli → src/vodkit_cli}/update.py +0 -0
|
@@ -3,7 +3,7 @@ import argparse
|
|
|
3
3
|
import os
|
|
4
4
|
import sys
|
|
5
5
|
|
|
6
|
-
from vodkit_cli import common, doctor, install, uninstall, update
|
|
6
|
+
from vodkit_cli import auth_cmd, common, doctor, install, packs_cmd, uninstall, update
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
def main():
|
|
@@ -12,14 +12,19 @@ def main():
|
|
|
12
12
|
if len(sys.argv) > 1 and sys.argv[1] == "serve":
|
|
13
13
|
# 显式声明这份副本的根(paths.py 读 VOD_DEVKIT_ROOT):插件/载荷根
|
|
14
14
|
# 不总是"CLI 所在包根",隐式相对深度正是此前副本装载失败的原因。
|
|
15
|
+
from vod_mcp import paths as _paths
|
|
15
16
|
os.execve(sys.executable,
|
|
16
|
-
[sys.executable, str(
|
|
17
|
-
{**os.environ,
|
|
17
|
+
[sys.executable, str(_paths.SRC_ROOT / "vod_mcp" / "server.py"), *sys.argv[2:]],
|
|
18
|
+
{**os.environ,
|
|
19
|
+
"VOD_DEVKIT_SRC_ROOT": str(_paths.SRC_ROOT),
|
|
20
|
+
"VOD_DEVKIT_DIST_ROOT": str(_paths.DIST_ROOT),
|
|
21
|
+
"VOD_DEVKIT_ROOT": str(_paths.DIST_ROOT)})
|
|
18
22
|
ap = argparse.ArgumentParser(prog="vod-devkit")
|
|
19
23
|
sub = ap.add_subparsers(dest="cmd", required=True)
|
|
20
24
|
sp = sub.add_parser("install")
|
|
21
25
|
sp.add_argument("--target", default="auto",
|
|
22
|
-
help="hermes|opencode|codeartsdoer|codeartswork|codex|codex-desktop|dsh|workbuddy|atomcode|generic|auto
|
|
26
|
+
help="hermes|opencode|codeartsdoer|codeartswork|codex|codex-desktop|dsh|workbuddy|atomcode|generic|all|auto"
|
|
27
|
+
"(all=所有探测到的宿主,缺 CLI 的跳过;默认探测)")
|
|
23
28
|
sp.add_argument("--preset", default="collect", choices=list(common.PRESETS),
|
|
24
29
|
help="collect=对外默认(采集者);full=内部全量")
|
|
25
30
|
sp.add_argument("--api-base", default="http://127.0.0.1:8000")
|
|
@@ -37,10 +42,10 @@ def main():
|
|
|
37
42
|
help="dsh 专用:profile 名(--target dsh 时必填)")
|
|
38
43
|
sp.add_argument("--mcp-url", default="",
|
|
39
44
|
help="远程 attach 模式:宿主 MCP 配置指向该 Streamable HTTP 端点"
|
|
40
|
-
"(hermes/opencode/codex 支持;dsh
|
|
45
|
+
"(hermes/opencode/codex 支持;dsh 本轮只支持本地形态:工具面走 MCP stdio,远程 attach 待开)")
|
|
41
46
|
sp.add_argument("--mcp-token", default="",
|
|
42
|
-
help="远程 attach 的身份(也可用 env VOD_MCP_TOKEN
|
|
43
|
-
"
|
|
47
|
+
help="远程 attach 的身份(也可用 env VOD_MCP_TOKEN):默认可选——"
|
|
48
|
+
"给了就用请求头 Bearer,不给则走远程 server 侧机器级匿名令牌")
|
|
44
49
|
sp.add_argument("--mcp-config", default="",
|
|
45
50
|
help="通用宿主(--target generic)的 MCP 配置文件路径;不给则只打印可粘贴片段")
|
|
46
51
|
sp.add_argument("--skills-only", action="store_true",
|
|
@@ -52,12 +57,21 @@ def main():
|
|
|
52
57
|
("verify", doctor.cmd_verify), ("update", update.cmd_update),
|
|
53
58
|
("uninstall", uninstall.cmd_uninstall),
|
|
54
59
|
("explain", doctor.cmd_explain),
|
|
55
|
-
("detect", doctor.cmd_detect)
|
|
60
|
+
("detect", doctor.cmd_detect),
|
|
61
|
+
("version", packs_cmd.cmd_version)):
|
|
56
62
|
s = sub.add_parser(name)
|
|
57
63
|
if name == "explain":
|
|
58
64
|
s.add_argument("text", nargs="+", help="错误文案或错误码(-32010 等)")
|
|
59
65
|
if name == "detect":
|
|
60
66
|
s.add_argument("--path", default="", help="要识别的项目目录(默认当前目录)")
|
|
67
|
+
if name in ("status", "doctor", "uninstall"):
|
|
68
|
+
# 多宿主账本(installs[])里挑一个宿主看/摘;缺省=全部行
|
|
69
|
+
s.add_argument("--target", default="",
|
|
70
|
+
help="只看该宿主的安装行(缺省=全部)")
|
|
71
|
+
if name == "uninstall":
|
|
72
|
+
s.add_argument("--clean-global", action="store_true",
|
|
73
|
+
dest="clean_global",
|
|
74
|
+
help="一并清载荷残留与 npx 缓存里的旧副本(逐条打印,只删认得的)")
|
|
61
75
|
if name == "update":
|
|
62
76
|
s.add_argument("--skip", action="store_true",
|
|
63
77
|
help="跳过当前 registry latest 的提醒(只压这一个版本,"
|
|
@@ -65,6 +79,22 @@ def main():
|
|
|
65
79
|
s.add_argument("--clear-skip", action="store_true",
|
|
66
80
|
help="撤销版本跳过设置,恢复正常提醒")
|
|
67
81
|
s.set_defaults(fn=fn)
|
|
82
|
+
sp_packs = sub.add_parser("packs", help="能力包启用面:status | enable | disable | all")
|
|
83
|
+
sp_packs.add_argument("packs_action", nargs="?", default="status",
|
|
84
|
+
choices=["status", "enable", "disable", "all"])
|
|
85
|
+
sp_packs.add_argument("ids", nargs="?", default="",
|
|
86
|
+
help="enable/disable 的包 id(逗号分隔,如 core,collect)")
|
|
87
|
+
sp_packs.add_argument("--target", default="", help="只作用于该宿主(缺省=全部)")
|
|
88
|
+
sp_packs.add_argument("--apply", action="store_true",
|
|
89
|
+
help="真正写盘(缺省只报告将改什么;core 强制包含)")
|
|
90
|
+
sp_packs.set_defaults(fn=packs_cmd.cmd_packs)
|
|
91
|
+
sp_auth = sub.add_parser("auth", help="凭据:status | init(写 runtime.json 的唯一入口)")
|
|
92
|
+
sp_auth.add_argument("auth_action", nargs="?", default="status",
|
|
93
|
+
choices=["status", "init"])
|
|
94
|
+
sp_auth.add_argument("--key", default="", help="引擎签发的 key(也可用 env VOD_JAVA_API_KEY)")
|
|
95
|
+
sp_auth.add_argument("--apply", action="store_true",
|
|
96
|
+
help="真正写盘(缺省只校验并显示指纹)")
|
|
97
|
+
sp_auth.set_defaults(fn=auth_cmd.cmd_auth)
|
|
68
98
|
sub.add_parser("build-info").set_defaults(fn=lambda a: common.write_build_info(strict=False))
|
|
69
99
|
|
|
70
100
|
def _serve(a):
|
|
@@ -7,12 +7,17 @@ import json
|
|
|
7
7
|
import os
|
|
8
8
|
import subprocess
|
|
9
9
|
import sys
|
|
10
|
+
|
|
11
|
+
from vod_mcp import paths
|
|
10
12
|
from pathlib import Path
|
|
11
13
|
|
|
12
14
|
from vod_mcp import hosts as host_specs
|
|
13
15
|
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
# 分发根(manifest / build-info / 载荷入口相对它);包根在 src/,由 paths 负责
|
|
18
|
+
from vod_mcp import paths as _paths
|
|
19
|
+
|
|
20
|
+
ROOT = _paths.DIST_ROOT
|
|
16
21
|
|
|
17
22
|
|
|
18
23
|
_HERMES_SPEC = host_specs.load("hermes")
|
|
@@ -129,7 +134,7 @@ def _skill_hashes() -> dict:
|
|
|
129
134
|
——拷贝件与安装产物漂移可检(vendor 规则漂移实锤的针对性防线)。"""
|
|
130
135
|
import hashlib
|
|
131
136
|
out = {}
|
|
132
|
-
for entry in sorted((
|
|
137
|
+
for entry in sorted((paths.ASSETS / "skills").iterdir()):
|
|
133
138
|
if entry.is_dir():
|
|
134
139
|
for f in sorted(entry.rglob("*")):
|
|
135
140
|
if f.is_file():
|
|
@@ -233,7 +238,13 @@ def _write_install_manifest(args, target, packs, bound_product, mcp_conf,
|
|
|
233
238
|
|
|
234
239
|
|
|
235
240
|
def _runtime_cfg_read() -> dict:
|
|
236
|
-
|
|
241
|
+
"""运行期状态现读(D-token-machine-1:单源在 paths.runtime_json_path())。
|
|
242
|
+
|
|
243
|
+
旧实现硬读 ROOT/vod_mcp/runtime.json——那是机器级改造前的落点,继续读会让
|
|
244
|
+
"装机写 state、doctor/装机种读旧位"分叉(同一份状态两套读法,skill 明令禁止)。
|
|
245
|
+
"""
|
|
246
|
+
from vod_mcp import paths as _paths
|
|
247
|
+
p = _paths.runtime_json_path()
|
|
237
248
|
if p.exists():
|
|
238
249
|
try:
|
|
239
250
|
return json.loads(p.read_text(encoding="utf-8"))
|
|
@@ -8,14 +8,26 @@ import sys
|
|
|
8
8
|
from pathlib import Path
|
|
9
9
|
|
|
10
10
|
from vod_mcp import hosts as host_specs
|
|
11
|
+
from vod_mcp import paths as paths_mod
|
|
11
12
|
from vodkit_cli import common, remote
|
|
12
13
|
|
|
13
14
|
|
|
14
|
-
def cmd_status(
|
|
15
|
+
def cmd_status(args=None):
|
|
16
|
+
target = (getattr(args, "target", "") or "") if args else ""
|
|
15
17
|
p = common.manifest_path()
|
|
16
18
|
if not p.exists():
|
|
17
19
|
print("未安装(无 install-manifest)")
|
|
18
20
|
sys.exit(1)
|
|
21
|
+
if target:
|
|
22
|
+
mf = json.loads(p.read_text(encoding="utf-8"))
|
|
23
|
+
rows = mf.get("installs") or ([mf] if mf.get("target") else [])
|
|
24
|
+
hit = next((r for r in rows if r.get("target") == target), None)
|
|
25
|
+
if hit is None:
|
|
26
|
+
print(f"没有该宿主的安装记录:{target}"
|
|
27
|
+
f"(现有:{', '.join(r.get('target','?') for r in rows) or '无'})")
|
|
28
|
+
sys.exit(1)
|
|
29
|
+
print(json.dumps(hit, ensure_ascii=False, indent=2))
|
|
30
|
+
return
|
|
19
31
|
# golden 稳定性:apiBase 含安装期动态值(本地验证实例端口),归一化后输出
|
|
20
32
|
text = p.read_text(encoding="utf-8")
|
|
21
33
|
text = re.sub(r'"apiBase": "http://127\.0\.0\.1:\d+"',
|
|
@@ -87,6 +99,59 @@ def _render_problems(problems) -> str:
|
|
|
87
99
|
return diagnose.render_problems(problems)
|
|
88
100
|
|
|
89
101
|
|
|
102
|
+
# ── 出站面(P2,对表 devkit 的 proxy / regional awareness 两节) ──────
|
|
103
|
+
#
|
|
104
|
+
# 两条都只**报告**,不新建配置、不改路由、不 FAIL:
|
|
105
|
+
# - 代理:尊重既有 HTTP 约定(env 优先),devkit 也是"env 高于文件";我们不建
|
|
106
|
+
# proxy.json(没有第二种真相就不会有"我改了为什么不生效")。代理 URL 可能含
|
|
107
|
+
# 口令,一律掩码后再打印。
|
|
108
|
+
# - 引擎可达:无 key 时此前完全没有网络结论(key 探针只在有 key 时跑)。这里
|
|
109
|
+
# 无条件探一次 meta 端点:401/403 也算**可达**(鉴权问题不等于网络问题);
|
|
110
|
+
# 不可达只 warn——离线装机 doctor 必须还能用。
|
|
111
|
+
|
|
112
|
+
_PROXY_KEYS = ("HTTPS_PROXY", "HTTP_PROXY", "ALL_PROXY", "NO_PROXY",
|
|
113
|
+
"https_proxy", "http_proxy", "no_proxy")
|
|
114
|
+
_PROXY_CRED = re.compile(r"(://)[^/@]*:[^@]*@")
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def _mask_proxy(url: str) -> str:
|
|
118
|
+
return _PROXY_CRED.sub(r"\1***:***@", url)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def _proxy_summary() -> str:
|
|
122
|
+
parts = [f"{k}={_mask_proxy(os.environ[k])}" for k in _PROXY_KEYS
|
|
123
|
+
if os.environ.get(k)]
|
|
124
|
+
return ";".join(parts) if parts else "未设(出站直连;urllib 会读 env,无需另配)"
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def _probe_engine(base: str, timeout: float = 4.0) -> tuple:
|
|
128
|
+
"""(state, detail);state ∈ ok / auth / unreachable。零依赖、不重试、不带 key。"""
|
|
129
|
+
import urllib.error
|
|
130
|
+
import urllib.request
|
|
131
|
+
url = base.rstrip("/") + "/rest/developer/manager/hdvodmngservice/v1/external/meta"
|
|
132
|
+
try:
|
|
133
|
+
with urllib.request.urlopen(url, timeout=timeout) as r:
|
|
134
|
+
return ("ok", f"HTTP {r.status} {url}")
|
|
135
|
+
except urllib.error.HTTPError as e:
|
|
136
|
+
return ("auth", f"HTTP {e.code}(可达;鉴权/路径响应){url}")
|
|
137
|
+
except Exception as e: # noqa: BLE001 网络类异常一律只报告
|
|
138
|
+
return ("unreachable", f"{type(e).__name__}: {e}({url})")
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def _report_egress(api_base: str) -> None:
|
|
142
|
+
print(f"[doctor] 出站代理:{_proxy_summary()}")
|
|
143
|
+
if not api_base:
|
|
144
|
+
print("[doctor] 引擎可达:未配置 apiBase(install 未写入?)")
|
|
145
|
+
return
|
|
146
|
+
state, detail = _probe_engine(api_base)
|
|
147
|
+
if state == "ok":
|
|
148
|
+
print(f"[doctor] 引擎可达:{detail}")
|
|
149
|
+
elif state == "auth":
|
|
150
|
+
print(f"[doctor] 引擎可达:{detail}")
|
|
151
|
+
else:
|
|
152
|
+
print(f"warn: 引擎不可达(离线环境可忽略;提交会失败):{detail}")
|
|
153
|
+
|
|
154
|
+
|
|
90
155
|
def cmd_explain(args):
|
|
91
156
|
"""解释一条失败文案/错误码(-32010 等):给层 + 原因 + 动作。"""
|
|
92
157
|
from vod_mcp import diagnose
|
|
@@ -117,13 +182,29 @@ def cmd_detect(args):
|
|
|
117
182
|
print("摘要:" + detect_framework.summary_line(info))
|
|
118
183
|
|
|
119
184
|
|
|
120
|
-
def cmd_doctor(
|
|
185
|
+
def cmd_doctor(args=None):
|
|
186
|
+
target = (getattr(args, "target", "") or "") if args else ""
|
|
121
187
|
problems = []
|
|
122
188
|
p = common.manifest_path()
|
|
123
189
|
if not p.exists():
|
|
124
190
|
problems.append("无 install-manifest.json(未 install?)")
|
|
125
191
|
else:
|
|
126
192
|
mf = json.loads(p.read_text(encoding="utf-8"))
|
|
193
|
+
rows = mf.get("installs") or ([mf] if mf.get("target") else [])
|
|
194
|
+
if rows:
|
|
195
|
+
row_names = ", ".join(r.get("target", "?") for r in rows)
|
|
196
|
+
if target:
|
|
197
|
+
hit = next((r for r in rows if r.get("target") == target), None)
|
|
198
|
+
if hit is None:
|
|
199
|
+
problems.append(f"没有该宿主的安装记录:{target}(现有:{row_names})")
|
|
200
|
+
else:
|
|
201
|
+
# --target:把该行的字段覆盖到视图上,检查按这一行走
|
|
202
|
+
mf = {**mf, **{k: v for k, v in hit.items() if v is not None}}
|
|
203
|
+
print(f"[doctor] 检查安装行:{target}")
|
|
204
|
+
elif len(rows) > 1:
|
|
205
|
+
# 缺省视图=最近一次安装(顶层字段即最后一次写入);多行只在末尾列出,
|
|
206
|
+
# 要看单个宿主用 --target(避免在多宿主上把"某一行的问题"说成全局)
|
|
207
|
+
print(f"[doctor] 安装行: {row_names}(--target <agent> 选择单个)")
|
|
127
208
|
# dsh patch 块自愈(S58/A 止血,2026-11-06 真机实锤):dsh 运行时
|
|
128
209
|
# 序列化会冲掉 profile patch 里的 vod 块(配置树不含手工块)——
|
|
129
210
|
# doctor 检测缺失/打平后按 manifest 的 product/apiBase 重建嵌套块
|
|
@@ -137,6 +218,17 @@ def cmd_doctor(_args):
|
|
|
137
218
|
problems.append("install-manifest 与 build-info 的 commitSHA 不一致")
|
|
138
219
|
if mf.get("mcpConfig") and not Path(mf["mcpConfig"]).exists():
|
|
139
220
|
problems.append("MCP 配置文件缺失")
|
|
221
|
+
# D-token-machine-1(R4):state 与旧位并存 = "静默不迁"要可见。
|
|
222
|
+
# 非破坏(迁移只在 target 不存在时做),但旧账本/锚点没并进来,排障时得知道。
|
|
223
|
+
try:
|
|
224
|
+
from vod_mcp import paths as _paths
|
|
225
|
+
st = _paths.machine_state_home() / "runtime.json"
|
|
226
|
+
lg = _paths.legacy_runtime_json()
|
|
227
|
+
if st.exists() and lg.exists():
|
|
228
|
+
print(f"[doctor] 注意:机器级 state 与旧位并存(旧位 {lg} 已不再写入、"
|
|
229
|
+
"未并入 state;确认无用后可手工清理)")
|
|
230
|
+
except Exception: # noqa: BLE001 诊断不应因该项失败而中断
|
|
231
|
+
pass
|
|
140
232
|
if mf.get("transport") == "remote" and mf.get("mcpUrl"):
|
|
141
233
|
url = mf["mcpUrl"]
|
|
142
234
|
token = (os.environ.get("VOD_MCP_TOKEN")
|
|
@@ -200,13 +292,51 @@ def cmd_doctor(_args):
|
|
|
200
292
|
encoding="utf-8"):
|
|
201
293
|
problems.append(f"AGENTS.md 仍含旧一代注入(教模型跳过同意):{legacy_agents}"
|
|
202
294
|
"——重跑 install --target codex 自动清理")
|
|
203
|
-
#
|
|
204
|
-
#
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
295
|
+
# 预采集 hook(D-hook-unify-1):hermes 侧靠 config.yaml 的 hooks.pre_llm_call
|
|
296
|
+
# 登记我们的脚本;脚本在载荷里(改口径随载荷更新,不再有"装机副本是旧的")。
|
|
297
|
+
if mf.get("target") == "hermes":
|
|
298
|
+
from vod_mcp.host_adapters import hermes as _hermes
|
|
299
|
+
cfg = Path(_hermes._profile_config())
|
|
300
|
+
text = cfg.read_text(encoding="utf-8") if cfg.exists() else ""
|
|
301
|
+
if _hermes.HOOK_MARK not in text:
|
|
302
|
+
problems.append(f"预采集 hook 未注册({cfg} 的 hooks.pre_llm_call)"
|
|
303
|
+
"——重跑 install --target hermes")
|
|
304
|
+
if _hermes.GUARD_MARK not in text:
|
|
305
|
+
problems.append(f"读 Key 拦截 hook 未注册({cfg} 的 hooks.pre_tool_call)"
|
|
306
|
+
"——重跑 install --target hermes(技能里的"
|
|
307
|
+
"「只引指纹」靠它兜住 cat runtime.json)")
|
|
308
|
+
if not _hermes._hook_script().exists():
|
|
309
|
+
problems.append(f"hook 脚本缺失:{_hermes._hook_script()}"
|
|
310
|
+
"(载荷不含 hooks/ 的旧版本?重跑 install)")
|
|
311
|
+
if not paths_mod.guard_script().exists():
|
|
312
|
+
problems.append(f"读 Key 拦截脚本缺失:{paths_mod.guard_script()}"
|
|
313
|
+
"——重跑 install(或升级载荷)")
|
|
314
|
+
if (Path.home() / ".hermes" / "plugins" / _hermes.LEGACY_PLUGIN).exists():
|
|
315
|
+
problems.append("旧插件形态仍在(~/.hermes/plugins/vod-feedback-router)"
|
|
316
|
+
"= 与 hook 双份注入——重跑 install --target hermes 清理")
|
|
317
|
+
# codex 插件 MCP 形态(D-mcp-manifest-a3-1):静态清单只能是 CLI 形态
|
|
318
|
+
# (codex 0.167 实测不展开 ${PLUGIN_ROOT}、cwd 也不是插件根),运行时正确性
|
|
319
|
+
# 全靠安装器改写。所以 doctor 必须回答"现在实际跑的是哪一种",不留猜测空间。
|
|
320
|
+
if mf.get("target") == "codex":
|
|
321
|
+
from vod_mcp.host_adapters import codex as _codex
|
|
322
|
+
mp = _codex.locate_plugin_mcp(None)
|
|
323
|
+
if mp is None:
|
|
324
|
+
problems.append("未定位到 codex 插件 .mcp.json(插件未装上/缓存被清)"
|
|
325
|
+
"——重跑 install --target codex")
|
|
326
|
+
else:
|
|
327
|
+
kind, srv = _codex.plugin_mcp_form(mp)
|
|
328
|
+
if kind == "payload":
|
|
329
|
+
print(f"[doctor] codex 插件 MCP 形态:载荷({srv['command']} + "
|
|
330
|
+
f"{srv.get('args')})")
|
|
331
|
+
elif kind == "cli":
|
|
332
|
+
problems.append(f"插件 MCP 仍是 CLI 形态({mp}):跑的是 PATH 上那份 CLI,"
|
|
333
|
+
"版本可能不是本插件——重跑 install --target codex")
|
|
334
|
+
elif kind == "placeholder":
|
|
335
|
+
problems.append(f"插件 MCP 含未展开占位符({mp}):宿主收到字面量,起不来"
|
|
336
|
+
"——重跑 install --target codex")
|
|
337
|
+
else:
|
|
338
|
+
problems.append(f"插件 .mcp.json 读不出 mcpServers.vod-devkit({mp})"
|
|
339
|
+
"——重跑 install --target codex")
|
|
210
340
|
# CodeArts Agent 冒烟:官方 CLI 在就 list 一次(实测通道=codearts_cli.json 的 mcp 段)
|
|
211
341
|
if mf.get("target") == "codeartsdoer" and shutil.which("codearts"):
|
|
212
342
|
r = subprocess.run(["codearts", "mcp", "list"], capture_output=True,
|
|
@@ -219,6 +349,14 @@ def cmd_doctor(_args):
|
|
|
219
349
|
if problems:
|
|
220
350
|
print(_render_problems(problems))
|
|
221
351
|
sys.exit(1)
|
|
352
|
+
# 出站面:代理生效值(掩码)+ 引擎可达(无 key 也回答"这个 apiBase 通不通")
|
|
353
|
+
api_base = ""
|
|
354
|
+
if p.exists():
|
|
355
|
+
try:
|
|
356
|
+
api_base = json.loads(p.read_text(encoding="utf-8")).get("apiBase") or ""
|
|
357
|
+
except (OSError, json.JSONDecodeError):
|
|
358
|
+
api_base = ""
|
|
359
|
+
_report_egress(api_base)
|
|
222
360
|
# key 探针(最佳努力):配置了 key 就问一次引擎,无效当场报;网络不可达只提示不 FAIL
|
|
223
361
|
#(离线环境 doctor 必须可用——网络问题不是 key 问题)
|
|
224
362
|
from vod_mcp.runtime_state import _runtime_cfg
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""install 子命令:探测 → 门禁 → 载荷固化 → 宿主写入 → 技能拷贝 → manifest。"""
|
|
2
|
+
import argparse
|
|
2
3
|
import datetime
|
|
3
4
|
import json
|
|
4
5
|
import os
|
|
@@ -7,10 +8,77 @@ import sys
|
|
|
7
8
|
from pathlib import Path
|
|
8
9
|
|
|
9
10
|
from vod_mcp import hosts as host_specs
|
|
11
|
+
from vod_mcp import packs as packs_mod
|
|
10
12
|
from vod_mcp.host_adapters import REGISTRY as HOST_ADAPTERS
|
|
11
13
|
from vod_mcp.host_adapters import generic as generic_host
|
|
14
|
+
from vod_mcp import paths
|
|
12
15
|
from vodkit_cli import common, remote
|
|
13
16
|
|
|
17
|
+
# 可显式指定(含 generic)的目标清单:交互输入按它校验,不随 HOST_ADAPTERS 的
|
|
18
|
+
# 运行期替换而变(测试与"适配器被裁剪"场景都不该让提示变成骗人的选项)
|
|
19
|
+
KNOWN_TARGETS = tuple(sorted(HOST_ADAPTERS)) + ("generic",)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _is_tty() -> bool:
|
|
23
|
+
"""交互判定:stdin 与 stdout 都是终端才问(重定向/CI 一律不猜)。"""
|
|
24
|
+
try:
|
|
25
|
+
return bool(sys.stdin.isatty() and sys.stdout.isatty())
|
|
26
|
+
except (AttributeError, ValueError):
|
|
27
|
+
return False
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _ask(prompt: str) -> str:
|
|
31
|
+
print(prompt, end="", flush=True)
|
|
32
|
+
return sys.stdin.readline().strip()
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _interactive_choose(found: list) -> list | None:
|
|
36
|
+
"""检测到多个时的多选(对齐 devkit)。返回选中 targets;取消/无输入返回 None。
|
|
37
|
+
|
|
38
|
+
输入约定固定(可测):编号逗号分隔,或 all;回车=取消。非法输入不猜,重问一次。
|
|
39
|
+
"""
|
|
40
|
+
for i, t in enumerate(found, 1):
|
|
41
|
+
print(f" {i}) {t}")
|
|
42
|
+
for attempt in range(2):
|
|
43
|
+
raw = _ask("选择要安装的宿主(编号逗号分隔 / all / 回车取消):")
|
|
44
|
+
if not raw:
|
|
45
|
+
return None
|
|
46
|
+
if raw.lower() == "all":
|
|
47
|
+
return list(found)
|
|
48
|
+
picked: list[str] = []
|
|
49
|
+
for part in raw.replace(",", ",").split(","):
|
|
50
|
+
part = part.strip()
|
|
51
|
+
if not part.isdigit() or not (1 <= int(part) <= len(found)):
|
|
52
|
+
picked = []
|
|
53
|
+
break
|
|
54
|
+
picked.append(found[int(part) - 1])
|
|
55
|
+
if picked:
|
|
56
|
+
return list(dict.fromkeys(picked))
|
|
57
|
+
print("输入不合法(示例:1 或 1,3 或 all)", file=sys.stderr)
|
|
58
|
+
return None
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def _install_many(targets: list, args) -> None:
|
|
62
|
+
"""对多个宿主逐个安装(--target all 与交互多选共用这一条实现)。
|
|
63
|
+
|
|
64
|
+
缺落点的宿主跳过并说清(dsh 需 --profile),单个失败不阻塞其它——
|
|
65
|
+
但每条失败都打出来,不静默吞。
|
|
66
|
+
"""
|
|
67
|
+
for t in targets:
|
|
68
|
+
if t == "dsh" and not (getattr(args, "dsh_profile", "") or "").strip():
|
|
69
|
+
print("[vod-devkit] 跳过 dsh:需 --profile <name>"
|
|
70
|
+
"(--target dsh --profile web ...)", file=sys.stderr)
|
|
71
|
+
continue
|
|
72
|
+
ns = argparse.Namespace(**vars(args))
|
|
73
|
+
ns.target = t
|
|
74
|
+
print(f"== install --target {t}")
|
|
75
|
+
try:
|
|
76
|
+
cmd_install(ns)
|
|
77
|
+
except SystemExit as e:
|
|
78
|
+
if e.code:
|
|
79
|
+
print(f"[vod-devkit] {t} 安装未完成(exit {e.code}),继续下一个",
|
|
80
|
+
file=sys.stderr)
|
|
81
|
+
|
|
14
82
|
|
|
15
83
|
def detect_targets() -> list:
|
|
16
84
|
"""0/1/N 探测:按 host.json 的 detect 段判断宿主是否在场(CLI 或配置目录)。"""
|
|
@@ -32,11 +100,26 @@ def cmd_install(args):
|
|
|
32
100
|
args.java_api_base = os.environ.get("VOD_JAVA_API_BASE") or DEFAULT_JAVA_BASE
|
|
33
101
|
common.write_build_info(strict=False)
|
|
34
102
|
target = args.target
|
|
103
|
+
if target == "all":
|
|
104
|
+
# 一步全量(对齐 devkit `--target all`):只装探测到的专属宿主;
|
|
105
|
+
# 缺 CLI 的跳过并说明(不猜、不代装宿主)。generic 不参与 all——
|
|
106
|
+
# 它是"手给配置文件"的兜底,不是可探测的专属宿主。
|
|
107
|
+
found = detect_targets()
|
|
108
|
+
if not found:
|
|
109
|
+
print("未探测到可自动安装的宿主;--target all 无可装宿主"
|
|
110
|
+
"(可 --target <agent> 显式指定)", file=sys.stderr)
|
|
111
|
+
sys.exit(2)
|
|
112
|
+
only = getattr(args, "_only", None) or None
|
|
113
|
+
if only:
|
|
114
|
+
found = [t for t in found if t in only]
|
|
115
|
+
_install_many(found, args)
|
|
116
|
+
return
|
|
35
117
|
if target == "auto":
|
|
36
118
|
found = detect_targets()
|
|
37
119
|
generic_found = generic_host.detect_known()
|
|
38
120
|
if len(found) == 1:
|
|
39
121
|
target = found[0]
|
|
122
|
+
print(f"探测到宿主: {target}")
|
|
40
123
|
elif not found and len(generic_found) == 1:
|
|
41
124
|
# A 层兜底:没有专属模块但有已知通用 MCP 宿主 → 走通用写入
|
|
42
125
|
#(探到唯一一个才自动写,多个/零个都要人选定,不许猜)
|
|
@@ -47,15 +130,38 @@ def cmd_install(args):
|
|
|
47
130
|
f"({args.mcp_config})")
|
|
48
131
|
elif not found:
|
|
49
132
|
known = "、".join(h["label"] + "(" + h["config"] + ")" for h in generic_found)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
133
|
+
hint = ("未探测到可自动安装的宿主;用 --target "
|
|
134
|
+
"hermes|opencode|codeartsdoer|codeartswork|codex|codex-desktop|"
|
|
135
|
+
"dsh|workbuddy|atomcode 显式指定"
|
|
136
|
+
+ (f",或通用写入:--target generic --mcp-config <配置>(探测到 {known})"
|
|
137
|
+
if generic_found else ""))
|
|
138
|
+
picked_name: str | None = None
|
|
139
|
+
if _is_tty():
|
|
140
|
+
# 交互终端:给一次机会(输入 target 名),非交互一律报错不猜
|
|
141
|
+
print(hint)
|
|
142
|
+
ans = _ask("输入 target 名(如 hermes;回车取消):").strip().lower()
|
|
143
|
+
if ans in KNOWN_TARGETS:
|
|
144
|
+
picked_name = ans
|
|
145
|
+
if not picked_name:
|
|
146
|
+
print(hint, file=sys.stderr)
|
|
147
|
+
sys.exit(2)
|
|
148
|
+
target = picked_name
|
|
149
|
+
print(f"探测到宿主: {target}")
|
|
54
150
|
else:
|
|
55
|
-
print(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
151
|
+
print("探测到多个宿主: " + ", ".join(found + [h["id"] for h in generic_found]))
|
|
152
|
+
picked_list = _interactive_choose(found) if _is_tty() else None
|
|
153
|
+
if not picked_list:
|
|
154
|
+
print("非交互环境不猜:请用 --target <agent> 或 --target all 显式指定",
|
|
155
|
+
file=sys.stderr)
|
|
156
|
+
sys.exit(2)
|
|
157
|
+
if len(picked_list) == 1:
|
|
158
|
+
target = picked_list[0]
|
|
159
|
+
print(f"探测到宿主: {target}")
|
|
160
|
+
else:
|
|
161
|
+
# 多选 = 对选中的那几个跑同一套 all 循环(语义只有一处实现)
|
|
162
|
+
print(f"探测到宿主: {', '.join(picked_list)}")
|
|
163
|
+
_install_many(picked_list, args)
|
|
164
|
+
return
|
|
59
165
|
adapter = HOST_ADAPTERS.get(target)
|
|
60
166
|
if adapter is None:
|
|
61
167
|
g = [(h["id"], h["config"]) for h in generic_host.detect_known()]
|
|
@@ -66,6 +172,13 @@ def cmd_install(args):
|
|
|
66
172
|
file=sys.stderr)
|
|
67
173
|
sys.exit(2)
|
|
68
174
|
packs = args.packs or common.PRESETS.get(args.preset, "")
|
|
175
|
+
# 未知包 id 在安装口就拒(D-packs-config-1):与运行期启动检查同一套解析,
|
|
176
|
+
# 免得"装的时候通过、跑起来报错",也免得把拼写错写进九份宿主配置。
|
|
177
|
+
try:
|
|
178
|
+
packs_mod.parse_packs(packs)
|
|
179
|
+
except packs_mod.UnknownPack as e:
|
|
180
|
+
print(f"[vod-devkit] {e}", file=sys.stderr)
|
|
181
|
+
sys.exit(2)
|
|
69
182
|
# 恢复门禁(D-codex-circuit-breaker-1,2026-11-06 负责人确认):
|
|
70
183
|
# 熔断标记存在(~/.codex/vod-collect-suspended.json)时,codex 装 collect
|
|
71
184
|
# 被拒——恢复采集的前置=token 化上线并过回归,不是改回 packs 一个动作;
|
|
@@ -110,7 +223,11 @@ def cmd_install(args):
|
|
|
110
223
|
if distribution == "preset" and os.environ.pop("VOD_JAVA_API_KEY", None):
|
|
111
224
|
print("[vod-devkit] warn: preset 形态下 VOD_JAVA_API_KEY 已忽略且不写入宿主配置"
|
|
112
225
|
"(key 落在哪台机器哪台就是信任边界;客户机走匿名令牌)", file=sys.stderr)
|
|
113
|
-
|
|
226
|
+
# 运行期状态单源(D-token-machine-1):装机写的是**机器级 state**,
|
|
227
|
+
# 不再是 "仓根/vod_mcp/runtime.json"——后者在改造后只有 server 的首启迁移会读,
|
|
228
|
+
# 写在那里等于 product/java_base 绑定在运行期读不到(这是路径统一时必须同步的点)。
|
|
229
|
+
from vod_mcp import paths as _paths
|
|
230
|
+
rt = _paths.runtime_json_path()
|
|
114
231
|
cfg = {}
|
|
115
232
|
if rt.exists():
|
|
116
233
|
try:
|
|
@@ -126,17 +243,27 @@ def cmd_install(args):
|
|
|
126
243
|
# 宿主产品(host_default)已删除(2026-11-12 复评):宿主产品也是一次推断,
|
|
127
244
|
# 错归会进引擎幂等/判重域。候选只走 vod_search_products,这里不再写 host_product。
|
|
128
245
|
cfg["java_base"] = args.java_api_base
|
|
246
|
+
rt.parent.mkdir(parents=True, exist_ok=True)
|
|
129
247
|
rt.write_text(json.dumps(cfg, ensure_ascii=False, indent=2), encoding="utf-8")
|
|
248
|
+
try: # 含 key/锚点:立刻收紧(与运行期写盘同口径)
|
|
249
|
+
os.chmod(rt, 0o600)
|
|
250
|
+
except OSError:
|
|
251
|
+
pass
|
|
130
252
|
|
|
131
253
|
# ── 远程 attach / skills-only(D-attach-1)───────────────────────────
|
|
132
254
|
# 形态:MCP 单独部署一个远程端点,宿主只把 MCP 配置指向它(+ 本地技能)。
|
|
133
|
-
#
|
|
134
|
-
#
|
|
255
|
+
# 约束(2026-11-16 D-token-machine-1 修订):远程面与本地同一套身份语义——
|
|
256
|
+
# 带 token 就用请求头身份(并验有效);不带 token 时由**服务端**领/复用机器级
|
|
257
|
+
# 匿名令牌(同机部署的默认形态)。所以 token 从"必填"改为"可选":
|
|
258
|
+
# · 有 token → verify_token=True(坏 key 拒装,零副作用)
|
|
259
|
+
# · 无 token → 只做连接级探活(不注入 Authorization,提交走匿名链)
|
|
260
|
+
# 探活一律先于写入,失败零副作用。dsh 壳不走 MCP,这两种模式对 dsh 无意义(显式拒绝)。
|
|
135
261
|
remote_url = (getattr(args, "mcp_url", "") or "").strip()
|
|
136
262
|
skills_only = bool(getattr(args, "skills_only", False))
|
|
137
263
|
if remote_url or skills_only:
|
|
138
264
|
if not getattr(adapter, "SUPPORTS_REMOTE", False):
|
|
139
|
-
what = "dsh
|
|
265
|
+
what = ("dsh 本轮只支持本地形态(远程 attach 待开)" if target == "dsh"
|
|
266
|
+
else f"{target} 不走 MCP")
|
|
140
267
|
print(f"[vod-devkit] {what},不支持 --mcp-url / --skills-only\n"
|
|
141
268
|
f" {target} 请用本地形态:install --target {target} "
|
|
142
269
|
+ ("--profile <name>" if target == "dsh" else ""),
|
|
@@ -144,13 +271,8 @@ def cmd_install(args):
|
|
|
144
271
|
sys.exit(2)
|
|
145
272
|
token = (getattr(args, "mcp_token", "") or os.environ.get("VOD_MCP_TOKEN") or "").strip()
|
|
146
273
|
if remote_url:
|
|
147
|
-
if not token:
|
|
148
|
-
print("[vod-devkit] 远程 attach 必须提供 --mcp-token 或 env VOD_MCP_TOKEN:\n"
|
|
149
|
-
" 远程面不代签匿名令牌(身份只从请求头来),无 token 装上也提交不了",
|
|
150
|
-
file=sys.stderr)
|
|
151
|
-
sys.exit(2)
|
|
152
274
|
try:
|
|
153
|
-
names = remote._probe_remote(remote_url, token)
|
|
275
|
+
names = remote._probe_remote(remote_url, token, verify_token=bool(token))
|
|
154
276
|
except Exception as e: # noqa: BLE001
|
|
155
277
|
print(f"[vod-devkit] 远程 MCP 探活失败(未写入任何配置):{e}", file=sys.stderr)
|
|
156
278
|
sys.exit(2)
|
|
@@ -163,6 +285,10 @@ def cmd_install(args):
|
|
|
163
285
|
file=sys.stderr)
|
|
164
286
|
sys.exit(2)
|
|
165
287
|
print(f"远程面探活通过:{len(names)} 个工具({', '.join(sorted(names))})")
|
|
288
|
+
if not token:
|
|
289
|
+
# 评审 B 半(P0-2):必须说清"没给 token = 共享本机身份"
|
|
290
|
+
print("[vod-devkit] 未提供 token:本机所有 agent 将共享同一枚机器级匿名令牌"
|
|
291
|
+
"(同一设备锚点、额度共用;要按 agent 隔离请带 --mcp-token)")
|
|
166
292
|
mcp_conf = None if skills_only else adapter.install_remote(args, remote_url, token)
|
|
167
293
|
extra_dirs = _install_skills(target, packs, args,
|
|
168
294
|
(getattr(args, "dsh_profile", "") or "").strip() or None)
|
|
@@ -203,20 +329,9 @@ def _stage_payload():
|
|
|
203
329
|
from vod_mcp import payload as _payload
|
|
204
330
|
from vod_mcp.host_adapters import base as _base
|
|
205
331
|
dest = _payload.stage()
|
|
206
|
-
#
|
|
207
|
-
#
|
|
208
|
-
|
|
209
|
-
if k in ("product", "host_product", "java_base", "local_ledger")}
|
|
210
|
-
if seeded:
|
|
211
|
-
rt = dest / "vod_mcp" / "runtime.json"
|
|
212
|
-
cur = {}
|
|
213
|
-
if rt.exists():
|
|
214
|
-
try:
|
|
215
|
-
cur = json.loads(rt.read_text(encoding="utf-8"))
|
|
216
|
-
except Exception:
|
|
217
|
-
cur = {}
|
|
218
|
-
cur.update(seeded)
|
|
219
|
-
rt.write_text(json.dumps(cur, ensure_ascii=False, indent=2), encoding="utf-8")
|
|
332
|
+
# 种运行配置到载荷副本的旧做法已删除(D-token-machine-1):运行期状态单源在
|
|
333
|
+
# 机器级 state(paths.runtime_json_path()),server 不再读 '<载荷>/vod_mcp/runtime.json'。
|
|
334
|
+
# 继续种会在已迁移机器上成为"死写",并让装机读侧/服务读侧看起来有两个落点。
|
|
220
335
|
_base.set_payload_dir(dest)
|
|
221
336
|
return dest
|
|
222
337
|
|
|
@@ -240,7 +355,7 @@ def _install_skills(target: str, packs: str, args, profile: str | None = None):
|
|
|
240
355
|
dst.mkdir(parents=True, exist_ok=True)
|
|
241
356
|
extra_dirs.append((target, dst))
|
|
242
357
|
pack_set = set(p for p in packs.split(",") if p)
|
|
243
|
-
for entry in sorted((
|
|
358
|
+
for entry in sorted((paths.ASSETS / "skills").iterdir()):
|
|
244
359
|
if entry.is_dir(): # vod-core / vod-feedback-collect
|
|
245
360
|
skill = entry.name
|
|
246
361
|
if skill == "vod-core" and "core" not in pack_set:
|