vod-devkit 0.5.3 → 0.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +12 -0
  3. package/bin/vod-devkit +60 -10
  4. package/contract/tools.schema.json +1 -1
  5. package/integrations/atomcode/host.json +5 -3
  6. package/integrations/codeartsdoer/host.json +1 -2
  7. package/package.json +3 -1
  8. package/plugins/vod-devkit/.codex-plugin/plugin.json +1 -1
  9. package/plugins/vod-devkit/build-info.json +3 -3
  10. package/plugins/vod-devkit/skills/vod-feedback-collect/SKILL.md +13 -4
  11. package/plugins/vod-devkit/skills/vod-problem-classification-rules/SKILL.md +2 -1
  12. package/plugins/vod-devkit/skills/vod-scoring-rules/SKILL.md +2 -1
  13. package/plugins/vod-devkit/vod_mcp/__init__.py +1 -1
  14. package/plugins/vod-devkit/vod_mcp/attribution.py +8 -8
  15. package/plugins/vod-devkit/vod_mcp/detect_framework.py +160 -0
  16. package/plugins/vod-devkit/vod_mcp/diagnose.py +102 -0
  17. package/plugins/vod-devkit/vod_mcp/host_adapters/codex.py +27 -5
  18. package/plugins/vod-devkit/vod_mcp/host_adapters/hermes.py +11 -5
  19. package/plugins/vod-devkit/vod_mcp/remote_app.py +25 -0
  20. package/plugins/vod-devkit/vod_mcp/skills_registry.py +6 -5
  21. package/plugins/vod-devkit/vod_mcp/tools.py +15 -17
  22. package/plugins/vod-devkit/vod_mcp/transport_remote.py +48 -0
  23. package/skills/vod-feedback-collect/SKILL.md +13 -4
  24. package/skills/vod-problem-classification-rules/SKILL.md +2 -1
  25. package/skills/vod-scoring-rules/SKILL.md +2 -1
  26. package/vod_mcp/__init__.py +1 -1
  27. package/vod_mcp/attribution.py +8 -8
  28. package/vod_mcp/detect_framework.py +160 -0
  29. package/vod_mcp/diagnose.py +102 -0
  30. package/vod_mcp/host_adapters/__pycache__/__init__.cpython-39.pyc +0 -0
  31. package/vod_mcp/host_adapters/__pycache__/atomcode.cpython-39.pyc +0 -0
  32. package/vod_mcp/host_adapters/__pycache__/base.cpython-39.pyc +0 -0
  33. package/vod_mcp/host_adapters/__pycache__/codearts.cpython-39.pyc +0 -0
  34. package/vod_mcp/host_adapters/__pycache__/codex.cpython-314.pyc +0 -0
  35. package/vod_mcp/host_adapters/__pycache__/generic.cpython-39.pyc +0 -0
  36. package/vod_mcp/host_adapters/__pycache__/hermes.cpython-314.pyc +0 -0
  37. package/vod_mcp/host_adapters/codex.py +27 -5
  38. package/vod_mcp/host_adapters/hermes.py +11 -5
  39. package/vod_mcp/remote_app.py +25 -0
  40. package/vod_mcp/skills_registry.py +6 -5
  41. package/vod_mcp/tools.py +15 -17
  42. package/vod_mcp/transport_remote.py +48 -0
package/CHANGELOG.md CHANGED
@@ -316,3 +316,20 @@
316
316
  - ba2901b chore(发版): 提交清单补根 skills/、hermes-plugin/、docs/decisions.md、build-info.json
317
317
  - cbbaf17 docs(技能): 补齐 0.5.2 同批文案 + 发版清单修正
318
318
 
319
+
320
+ ## v0.5.4(2026-11-12)
321
+
322
+ - c1677c2 feat(工程化): doctor 分层报告 + explain + detect + 宿主矩阵进 CI + 发版 workflow
323
+ - f9b732c fix(发版): publish_verify 不再误判 propagation 窗口(v0.5.3 实锤)
324
+
325
+
326
+ ## v0.5.5(2026-11-13)
327
+
328
+ - f3fa14d fix(归因): 产品名录单一真源=引擎接口 + 清 host_default 残留(评审收口)
329
+ - ec56497 fix(远程面): 载荷自校验不再 import host_adapters + codex 适配改惰性解析
330
+ - a1e44c6 feat(远程面): 抄 devkit 两条守卫——构造期技能树自校验 + 每请求载荷校验
331
+ - b963d84 fix(dsh壳): vod_devkit_info 的 version 改用 PKG_VERSION(写死 0.1.0 实锤)
332
+ - 9feb789 docs(验证): 宿主会话级验证手册(统一网关跑 codex/atomcode 的实测命令)
333
+ - 6c2d9a1 fix(宿主): hermes 路径改为调用期解析 + 新增 host_matrix --audit 巡检
334
+ - 0e688e3 docs(验证): 记真机可达边界 + AtomCode 真机验证结论
335
+
package/README.md CHANGED
@@ -278,3 +278,15 @@ install-manifest 名册对账(doctor 逐落点)+ 声明计数对账(对外
278
278
  ## 许可
279
279
 
280
280
  MIT(见 LICENSE.txt)。第三方素材见 NOTICE。
281
+
282
+ ## 诊断与识别(0.5.4 起)
283
+
284
+ ```bash
285
+ vod-devkit doctor # 分层报告:环境/载荷/配置/技能/网络/插件,每条给动作
286
+ vod-devkit explain -32010 # 解释一条错误码/错误文案:层 + 原因 + 动作
287
+ vod-devkit detect --path . # 只读识别项目语言/框架/构建(不写任何文件)
288
+ python3 scripts/host_matrix.py # 9 宿主安装矩阵:装→断言→拉起 server→卸→验干净
289
+ ```
290
+
291
+ `doctor` 的失败按层分组,不再平铺一列 `FAIL`;`explain` 与它共用同一张规则表
292
+ (`vod_mcp/diagnose.py`),所以"报告里出现的层/原因"和"解释出来的动作"永远一致。
package/bin/vod-devkit CHANGED
@@ -59,13 +59,24 @@ def build_info(strict: bool = False) -> dict:
59
59
 
60
60
  def write_build_info(strict: bool):
61
61
  info = build_info(strict)
62
+ # 隔离跑法(宿主矩阵/CI 用例)不许改真实仓的 build-info:它会被重烧成当前
63
+ # HEAD,而包内副本停在发版提交 → 结构门禁"根/包内不一致"假红(本轮实锤)。
64
+ if os.environ.get("VOD_DEVKIT_NO_BUILD_INFO"):
65
+ print("build-info.json: 跳过写入(VOD_DEVKIT_NO_BUILD_INFO)")
66
+ return
62
67
  (ROOT / "build-info.json").write_text(
63
68
  json.dumps(info, ensure_ascii=False, indent=2), encoding="utf-8")
64
69
  print("build-info.json:", json.dumps(info, ensure_ascii=False))
65
70
 
66
71
 
67
72
  def manifest_path() -> Path:
68
- return ROOT / "install-manifest.json"
73
+ """安装名册位置:默认仓根;VOD_DEVKIT_MANIFEST 可覆盖(多安装根/隔离测试)。
74
+
75
+ 契约上 manifest 落在"安装器所在的仓根"——npx 缓存下的仓被清掉时名册一起消失,
76
+ 所以 doctor/uninstall 只在同一个仓上下文里自洽;需要另置一份或多份时用该 env。
77
+ """
78
+ override = (os.environ.get("VOD_DEVKIT_MANIFEST") or "").strip()
79
+ return Path(override) if override else ROOT / "install-manifest.json"
69
80
 
70
81
 
71
82
  PRESETS = {
@@ -390,10 +401,8 @@ def cmd_install(args):
390
401
  cfg["local_ledger"] = False
391
402
  # base 同步落 runtime.json:宿主 env 透传不稳是实测坑,透传挂了静默落回
392
403
  # 127.0.0.1:8090;文件兑底与 env 同值不构成双真源(优先级链 env>文件)
393
- # 宿主产品(host_default 兜底用,D-product-ask-1):只有 integrations 声明了才写
394
- spec_raw = host_specs.raw(target) if target in host_specs.hosts() else {}
395
- if spec_raw.get("productDefault"):
396
- cfg["host_product"] = spec_raw["productDefault"]
404
+ # 宿主产品(host_default)已删除(2026-11-12 复评):宿主产品也是一次推断,
405
+ # 错归会进引擎幂等/判重域。候选只走 vod_search_products,这里不再写 host_product。
397
406
  cfg["java_base"] = args.java_api_base
398
407
  rt.write_text(json.dumps(cfg, ensure_ascii=False, indent=2), encoding="utf-8")
399
408
 
@@ -689,6 +698,43 @@ def _repair_dsh_patch_block(mf: dict) -> str | None:
689
698
  return str(patch)
690
699
 
691
700
 
701
+ def _render_problems(problems) -> str:
702
+ """分层报告(对表 devkit 的 doctor-report):按 环境/载荷/配置/技能/网络/插件 分组,
703
+ 每条失败给「原因」与「动作」,避免运维只看到一堆 FAIL 文案。"""
704
+ from vod_mcp import diagnose
705
+ return diagnose.render_problems(problems)
706
+
707
+
708
+ def cmd_explain(args):
709
+ """解释一条失败文案/错误码(-32010 等):给层 + 原因 + 动作。"""
710
+ from vod_mcp import diagnose
711
+ text = " ".join(args.text).strip()
712
+ if not text:
713
+ print("用法:vod-devkit explain '<错误文案或错误码>'", file=sys.stderr)
714
+ sys.exit(2)
715
+ info = diagnose.explain(text)
716
+ if not info["known"]:
717
+ print(f"未收录该问题:{text[:120]}", file=sys.stderr)
718
+ print(" 排查入口:doctor 看分层报告;仍无头绪就把这段文案连同 doctor 输出一起贴出来",
719
+ file=sys.stderr)
720
+ sys.exit(2)
721
+ print(f"层:{info['layer']}")
722
+ print(f"原因:{info['cause']}")
723
+ print(f"动作:{info['action']}")
724
+
725
+
726
+ def cmd_detect(args):
727
+ """只读识别项目语言/框架/构建(给采集端补上下文;不写任何文件)。"""
728
+ from vod_mcp import detect_framework
729
+ try:
730
+ info = detect_framework.detect(args.path or os.getcwd())
731
+ except ValueError as e:
732
+ print(str(e), file=sys.stderr)
733
+ sys.exit(2)
734
+ print(json.dumps(info, ensure_ascii=False, indent=2))
735
+ print("摘要:" + detect_framework.summary_line(info))
736
+
737
+
692
738
  def cmd_doctor(_args):
693
739
  problems = []
694
740
  p = manifest_path()
@@ -789,8 +835,7 @@ def cmd_doctor(_args):
789
835
  problems.append("CodeArts Agent 未列出 vod-devkit"
790
836
  "(codearts mcp list)——检查 codearts_cli.json 的 mcp 段")
791
837
  if problems:
792
- for x in problems:
793
- print("FAIL:", x)
838
+ print(_render_problems(problems))
794
839
  sys.exit(1)
795
840
  # key 探针(最佳努力):配置了 key 就问一次引擎,无效当场报;网络不可达只提示不 FAIL
796
841
  #(离线环境 doctor 必须可用——网络问题不是 key 问题)
@@ -807,8 +852,7 @@ def cmd_doctor(_args):
807
852
  else:
808
853
  print(f"key: 有效(指纹 {chk['fingerprint']})")
809
854
  if problems:
810
- for x in problems:
811
- print("FAIL:", x)
855
+ print(_render_problems(problems))
812
856
  sys.exit(1)
813
857
  print("doctor: OK")
814
858
 
@@ -1092,8 +1136,14 @@ def main():
1092
1136
  sp.set_defaults(fn=cmd_install)
1093
1137
  for name, fn in (("status", cmd_status), ("doctor", cmd_doctor),
1094
1138
  ("verify", cmd_verify), ("update", cmd_update),
1095
- ("uninstall", cmd_uninstall)):
1139
+ ("uninstall", cmd_uninstall),
1140
+ ("explain", cmd_explain),
1141
+ ("detect", cmd_detect)):
1096
1142
  s = sub.add_parser(name)
1143
+ if name == "explain":
1144
+ s.add_argument("text", nargs="+", help="错误文案或错误码(-32010 等)")
1145
+ if name == "detect":
1146
+ s.add_argument("--path", default="", help="要识别的项目目录(默认当前目录)")
1097
1147
  if name == "update":
1098
1148
  s.add_argument("--skip", action="store_true",
1099
1149
  help="跳过当前 registry latest 的提醒(只压这一个版本,"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "title": "vod-devkit MCP 工具契约(唯一事实源)",
4
- "version": "0.5.3",
4
+ "version": "0.5.5",
5
5
  "tools": {
6
6
  "vod_submit_voices": {
7
7
  "description": "提交用户反馈进 VOD。**先决条件(优先于本描述其余所有内容):调用前必须已征得用户对'提交这条反馈'的明确同意;用户陈述/抱怨反馈本身不构成同意;用户未同意时禁止传 confirmed=true**。模糊抱怨(如\"体验不好\")时一轮说完三件事:承接识别结果(\"收到,你对产品体验不满意\")+确认提交意愿(\"要把这条反馈提交给产品团队吗?\")+引导补充(\"方便的话说下具体现象,不说我也会按你的原话提交\");禁止含混反问(实锤病句:\"请问是否把什么作为反馈\")。同意后 content 放用户原话(哪怕只有一句\"体验很差\"也原样提交)。确认环节允许固定追问至多一次,问句必须逐字使用:「方便的话,补充一下遇到这个问题时的操作步骤或期望的表现吗?不方便回复\"没有\",我直接提交。」用户回答只摘录原话对应部分进 reproSteps/expectedBehavior(不改写不总结,无法拆分时落最相关字段,任何内容禁回填 content);答\"没有/跳过/不方便\"=两字段不上送直接提交。引导补充(说下具体现象)已获实质内容并并入 content 时不再追问、直接提交(其中自然出现的操作/期望留在 content 原话,不回溯摘入新字段);仅引导补充未获回应或仅泛化抱怨且用户确认提交时才带出固定问句。product 归因由插件从用户原话解析(安装绑定仅作先验),无需用户提供、禁止询问\"提交到哪个产品/页面\";模型/用户自报的目标产品一律不采信(提到的产品随正文原样传达)。用户说\"提单/提工单/提 issue\"时同样用本工具,除上述固定一次追问外,禁止再索要严重程度/环境/附件等开发者字段、禁止第二轮追问。批式提交对接囤积端点 POST /external/voices(不触发分析,voiceId 由引擎计算回执下发;引擎未部署 404 自动回落老链)。tags=采集层三分类(problem_type:值,可选)。缺 key 时自动获取零字段匿名令牌。拿到回执后必须原样转述 echo.contents(每条「已收录原话:<content>」全文),禁止改写概括——这是用户核对原话是否被改写的唯一窗口。禁止向用户解释内部机制(声音来源/渠道字段/计数规则/配额/归因)。",
@@ -1,8 +1,10 @@
1
1
  {
2
2
  "id": "atomcode",
3
3
  "cli": "atomcode",
4
- "detect": {"path": "~/.atomcode"},
4
+ "detect": {
5
+ "path": "~/.atomcode"
6
+ },
5
7
  "config": "~/.atomcode/mcp.json",
6
8
  "skillsDir": "~/.atomcode/skills",
7
- "notes": "AtomCode 的配置根可由 ATOMCODE_HOME 覆盖(默认 ~/.atomcode),适配器每次调用期读取该 env,不缓存。mcp.json 形态 mcpServers.<name> = command/args/env。宿主另有 hooks.json 的 pre_tool_use 遥测 hook——属华为工具的埋点,我们刻意不装(不引入遥测)。路径来源:huaweicloud-devkit targets.ts atomcodeHome/atomcodeMcpConfigFile/atomcodeSkillsDir。本机未装该宿主,未真机验证。"
8
- }
9
+ "notes": "AtomCode 的配置根可由 ATOMCODE_HOME 覆盖(默认 ~/.atomcode),适配器每次调用期读取该 env,不缓存。真机验证(2026-11-12,本机 aarch64 Linux 装 atomcode 5.2.6):`atomcode mcp add <name> <cmd>... --global` 写的正是 ~/.atomcode/mcp.json 的 mcpServers.<name>;用它的写入器追加一条后我们的条目原样保留,说明 schema 兼容、可共存。host_matrix --host atomcode → PASS(8 工具,版本=构建版本)。宿主另有 hooks.json 的 pre_tool_use 遥测 hook 与 telemetry 开关——我们刻意不装/不开启。"
10
+ }
@@ -6,6 +6,5 @@
6
6
  },
7
7
  "config": "~/.codeartsdoer/codearts_cli.json",
8
8
  "skillsDir": "~/.codeartsdoer/skills",
9
- "notes": "CodeArts Agent 是 OpenCode 分支(SCENARIO=codeartsdoer、OPENCODE_CONFIG=codearts_cli.json):mcp 段与 opencode 同 schema(type=local、command=数组、enabled)。实测 2026-11-11:写入 codearts_cli.json 的 mcp.<name> 后 `codearts mcp list` 可见;mcp_settings.json 只对项目级 .codeartsdoer/mcp/ 生效,用户级读 ~/.config/opencode/mcp/,故不要写 ~/.codeartsdoer/mcp/。",
10
- "productDefault": "CodeArts"
9
+ "notes": "CodeArts Agent 是 OpenCode 分支(SCENARIO=codeartsdoer、OPENCODE_CONFIG=codearts_cli.json):mcp 段与 opencode 同 schema(type=local、command=数组、enabled)。实测 2026-11-11:写入 codearts_cli.json 的 mcp.<name> 后 `codearts mcp list` 可见;mcp_settings.json 只对项目级 .codeartsdoer/mcp/ 生效,用户级读 ~/.config/opencode/mcp/,故不要写 ~/.codeartsdoer/mcp/。"
11
10
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vod-devkit",
3
- "version": "0.5.3",
3
+ "version": "0.5.5",
4
4
  "description": "VOD 用户声音采集插件——MCP server + 技能 + 声明式护栏,把 agent 产品的用户反馈安全送进 VOD 平台",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -35,6 +35,8 @@
35
35
  "vod_mcp/attribution.py",
36
36
  "vod_mcp/runtime.example.json",
37
37
  "vod_mcp/payload.py",
38
+ "vod_mcp/diagnose.py",
39
+ "vod_mcp/detect_framework.py",
38
40
  "vod_mcp/host_adapters/",
39
41
  "plugins/vod-devkit/.codex-plugin/plugin.json",
40
42
  "plugins/vod-devkit/.mcp.json",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vod-devkit",
3
- "version": "0.5.3",
3
+ "version": "0.5.5",
4
4
  "description": "VOD user-feedback collection: structured voice capture and submission to the VOD hoarding endpoint.",
5
5
  "keywords": [
6
6
  "feedback",
@@ -1,6 +1,6 @@
1
1
  {
2
- "version": "0.5.3",
3
- "commitSha": "e8bc9098422e3ceafacbfee817708d76b9e8d40b",
4
- "builtAt": "2026-11-12T20:10:47",
2
+ "version": "0.5.5",
3
+ "commitSha": "f3fa14da66a8f1b6ae81b413b01bb6426385dd8b",
4
+ "builtAt": "2026-11-13T01:46:16",
5
5
  "sourceRemote": "https://gitcode.com/xiaowu2119/vod-devkit.git"
6
6
  }
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: vod-feedback-collect
3
- description: '用户抱怨/体验差/太慢/报错/提单 → 采集原话进 VOD。识别到抱怨即承接并征得同意(禁止问哪个产品,禁止复现排查模式);content=原话逐字;一次抱怨一条;回执 echo 原样转述。详见正文流程与禁令。Triggers: "体验差","太难用","太慢","报错了","出bug了","有bug","反馈问题","反馈建议","提个单","报告问题","不生效","不好使","操作不方便","卡住了","崩溃了","report a problem","bug report","poor experience","feedback"'
3
+ description: '用户抱怨/体验差/太慢/报错/提单 → 采集原话进 VOD。识别到抱怨即承接并征得同意(缺产品先问一次是哪个、不猜也不提交;禁止复现排查模式);content=原话逐字;一次抱怨一条;回执 echo 原样转述。详见正文流程与禁令。Triggers: "体验差","太难用","太慢","报错了","出bug了","有bug","反馈问题","反馈建议","提个单","报告问题","不生效","不好使","操作不方便","卡住了","崩溃了","report a problem","bug report","poor experience","feedback"'
4
4
  tags: [vod, feedback, capture, consent]
5
5
  metadata:
6
6
  version: 1
@@ -180,8 +180,10 @@ metadata:
180
180
  ## 采集流程
181
181
 
182
182
  0. 产品归因(D-product-ask-1,2026-11-12 拍板:不许裸提交 UNKNOWN):
183
- 归因次序 = 用户明确回答 > 原话唯一高置信提及 > 会话记忆(30 分钟) >
184
- 安装先验 > 宿主产品(host_default,仅用户说不知道时,低置信)。
183
+ 归因次序 = 用户明确回答 > 原话唯一高置信提及 > 会话记忆(30 分钟) > 安装先验。
184
+ 四级都拿不到 → **不猜、不提交**,按下面的追问规则请用户补一句产品名
185
+ (2026-11-12 复评删除 host_default 兜底:宿主产品也是一次推断,错归会进
186
+ 引擎幂等/判重域,污染静默且难追溯)。
185
187
  - 原话里只有一个产品名、且不是对比/多产品语境 → 直接用,不再问
186
188
  - 原话有两个以上产品("CodeArts 比 MaaS 好"、"从 CodeArts 导出到 MaaS")
187
189
  → 视为**低置信**,必须问:"这条反馈是哪个产品的?可用候选:…"
@@ -217,7 +219,8 @@ metadata:
217
219
  "网页卡回复慢"被宿主改写成「网页打开,…」+「网页卡,…」两条入库建出
218
220
  两个 issue;引擎幂等按内容逐字比对,改写即绕过)。多条仅当用户明确
219
221
  分条给了多个不同反馈
220
- 4. 拿到回执 → 对用户说人话:"已收录,产品团队会看到这条反馈"——
222
+ 4. 拿到回执 → 对用户说人话:"已收录,产品团队会看到这条反馈";
223
+ (若对方是验证者且明确要编号,按第 0 条例外贴 voiceId)——
221
224
  **voiceId 不展示给终端用户**(编号噪音),仅供 agent 对账用;
222
225
  用户追问"提交了吗"时 agent 用 voiceId/taskId 核对后回答状态
223
226
  5. **无通道 fallback(D-pending-1,插件未安装/无 vod 工具时)**:
@@ -241,6 +244,12 @@ metadata:
241
244
  ## 纪律
242
245
 
243
246
  0. 回执纪律(F2,成功与失败路径同口径):给用户的话=人话
247
+
248
+ **验证/对账例外(2026-11-12 拍板)**:当对方是**验证者**(运维/研发/负责人在
249
+ 核对链路,明确说"把 voiceId 贴出来""我核对下入库")时,允许同样打印
250
+ `voiceId`、`productId`、`productSource`——那是他们的对账主键,不是给反馈提交者看的
251
+ 噪音。判据两条同时满足:①对方明确要求要编号;②对方在验证链路而不是在提交自己的
252
+ 抱怨。终端用户(提交反馈的人)问"提交了吗",仍只回答状态、不展示编号。
244
253
  (成功=已收录/产品团队会看到;失败=提交失败,反馈已暂存本机,
245
254
  稍后会自动重试)。**失败时禁止向用户复述内部诊断字段**——HTTP
246
255
  状态码、apiKeyFingerprint、tokenTier、堆栈等属于 agent 内部排障
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: vod-problem-classification-rules
3
- description: VOD 问题分类规则(引擎 v2.2 真实口径)— 六类定义、判定细节、LLM 分类流程。真源=workflow/src/n01_classify.py(VOD-Project 2bb3fc82 实测核对)。
3
+ description: VOD 问题分类规则(引擎 v2.2 真实口径)— 六类定义、判定细节、LLM 分类流程。
4
4
  tags: [vod, classification, rules]
5
5
  metadata:
6
6
  version: 2
@@ -13,6 +13,7 @@ metadata:
13
13
  > 体验优化/其他)已废弃,与引擎不符——它来自过期文档。
14
14
  > 采集定位:预分类仅作参考 hint(tags),引擎 LLM 按六类重判——
15
15
  > 预分类不是终局,别和用户言之凿凿。
16
+ > 对外复述纪律:可讲口径(六类边界/判定要点),不引用仓库路径、文件行号、提交号。
16
17
 
17
18
  ## 六类定义(引擎 DEFAULT_TYPE_DEFS 原文)
18
19
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: vod-scoring-rules
3
- description: VOD 评分规则(引擎 v2 真实公式)— 四项加法、上下限、优先级映射。真源=workflow/src/workflow_v2.py(VOD-Project 2bb3fc82 实测核对)。
3
+ description: VOD 评分规则(引擎 v2 真实公式)— 四项加法、上下限、优先级映射。
4
4
  tags: [vod, scoring, rules]
5
5
  metadata:
6
6
  version: 2
@@ -11,6 +11,7 @@ metadata:
11
11
  > 真源纪律:以 workflow_v2.py 评分函数为准,2026-11-03 逐行核对。
12
12
  > 旧版"五项维度含用户价值"口径作废——引擎是四项,且非重点问题
13
13
  > 上限不同(下方原文),旧文档没写。
14
+ > 对外复述纪律:可讲公式要点与上下限,不引用仓库路径、文件行号、提交号。
14
15
 
15
16
  ## 评分公式(引擎代码原文语义)
16
17
 
@@ -5,7 +5,7 @@
5
5
  2. 外部无 DB 直连路径(护栏 deny 兜底)
6
6
  3. 任务 ID 是唯一对账主键,写类工具返回一律携带
7
7
  """
8
- __version__ = "0.5.3"
8
+ __version__ = "0.5.5"
9
9
  # 默认上游:VOD 测试环境。外部用户本机无 VOD,回环默认值=装完即坏;
10
10
  # 生产地址定型后只改这一处(tools.py 与 bin/vod-devkit 共用本常量)。
11
11
  DEFAULT_JAVA_BASE = "https://vod-dev.topxtopx.com"
@@ -163,19 +163,19 @@ def build_alias_index(meta: dict) -> list:
163
163
 
164
164
  # ② 品牌俗称表:把无法从表名推导的口语词挂到目标产品上
165
165
  for target_name, colloquials in (BRAND_ALIASES or {}).items():
166
- slot = canon.get(str(target_name).lower())
167
- if slot is None:
166
+ brand_slot: dict | None = canon.get(str(target_name).lower())
167
+ if brand_slot is None:
168
168
  # 目标产品不在本次 catalog(引擎换库/改名):别名不落地,避免指向
169
169
  # 不存在的 id。宁可丢俗称,也不产生错归。
170
170
  continue
171
171
  for word in (colloquials or []):
172
172
  if word:
173
- slot["aliases"].add(str(word).strip())
173
+ brand_slot["aliases"].add(str(word).strip())
174
174
 
175
175
  # ③ 兼容:若引擎仍下发旧字段(回滚场景),继续采纳,避免双向改造期丢能力
176
176
  for key, aliases in (meta.get("nameAliases") or {}).items():
177
177
  aliases = [str(a) for a in (aliases or []) if a]
178
- target = canon.get(str(key).lower())
178
+ target: dict | None = canon.get(str(key).lower())
179
179
  if target is None:
180
180
  for a in aliases:
181
181
  if a.lower() in canon:
@@ -187,10 +187,10 @@ def build_alias_index(meta: dict) -> list:
187
187
  target["aliases"].add(a)
188
188
  target["aliases"].add(str(key))
189
189
  for key, target_name in (meta.get("aliases") or {}).items():
190
- slot = canon.get(str(target_name).lower())
191
- if slot is None: # 目录/展示名都没有该目标:按别名目标建槽,别丢别名
192
- slot = _slot(target_name, False)
193
- slot["aliases"].add(str(key))
190
+ alias_slot: dict | None = canon.get(str(target_name).lower())
191
+ if alias_slot is None: # 目录/展示名都没有该目标:按别名目标建槽,别丢别名
192
+ alias_slot = _slot(target_name, False)
193
+ alias_slot["aliases"].add(str(key))
194
194
 
195
195
  for slot in canon.values(): # 名字/别名任一命中 catalog → 拿 id
196
196
  for alias in list(slot["aliases"]) + [slot["label"]]:
@@ -0,0 +1,160 @@
1
+ """只读项目识别:语言构成 + 框架/构建工具线索。
2
+
3
+ 对标 huaweicloud-devkit 的 detect-framework*(513 行):它做的推论比我们多
4
+ (框架 → 推荐能力),我们只需要"这是哪个语言/框架的项目"给采集端补上下文,
5
+ 所以刻意只做**确定性证据**:
6
+
7
+ - 语言:按扩展名统计文件数(跳过 vendor 目录 / node_modules / .git / 大二进制),
8
+ 取前 N 个;不做"猜测比例"。
9
+ - 框架/构建:只认标记文件与清单里的显式依赖(package.json 的 dependencies、
10
+ requirements.txt、pyproject.toml、pom.xml、go.mod、Cargo.toml、build.gradle),
11
+ 不做字符串模糊匹配——误报比不报更糟(会把运维带偏)。
12
+
13
+ 只读:本模块不写任何文件、不发网络请求。
14
+ """
15
+ import json
16
+ import os
17
+ from pathlib import Path
18
+
19
+ SKIP_DIRS = {".git", "node_modules", "vendor", "dist", "build", ".venv", "venv",
20
+ "__pycache__", ".mypy_cache", ".pytest_cache", "target", ".idea"}
21
+ MAX_FILES = 20000 # 扫描上限:大仓不做全量遍历(41s 索引卡死过 UI)
22
+ MAX_DEPTH = 12
23
+
24
+ LANG_EXT = {
25
+ ".py": "Python", ".js": "JavaScript", ".mjs": "JavaScript", ".cjs": "JavaScript",
26
+ ".ts": "TypeScript", ".tsx": "TypeScript", ".jsx": "JavaScript",
27
+ ".java": "Java", ".kt": "Kotlin", ".go": "Go", ".rs": "Rust",
28
+ ".rb": "Ruby", ".php": "PHP", ".cs": "C#", ".c": "C", ".cc": "C++",
29
+ ".cpp": "C++", ".h": "C/C++ header", ".swift": "Swift", ".scala": "Scala",
30
+ ".sh": "Shell", ".sql": "SQL", ".vue": "Vue", ".md": "Markdown",
31
+ }
32
+
33
+ # 标记文件 → (种类, 名称)
34
+ MARKERS = {
35
+ "package.json": ("node", "npm/node"),
36
+ "pnpm-lock.yaml": ("node", "pnpm"),
37
+ "yarn.lock": ("node", "yarn"),
38
+ "requirements.txt": ("python", "pip"),
39
+ "pyproject.toml": ("python", "pyproject"),
40
+ "setup.py": ("python", "setuptools"),
41
+ "Pipfile": ("python", "pipenv"),
42
+ "pom.xml": ("java", "Maven"),
43
+ "build.gradle": ("java", "Gradle"),
44
+ "build.gradle.kts": ("java", "Gradle"),
45
+ "go.mod": ("go", "Go modules"),
46
+ "Cargo.toml": ("rust", "Cargo"),
47
+ "Gemfile": ("ruby", "Bundler"),
48
+ "composer.json": ("php", "Composer"),
49
+ "Dockerfile": ("infra", "Docker"),
50
+ "docker-compose.yml": ("infra", "Docker Compose"),
51
+ "Makefile": ("infra", "Make"),
52
+ }
53
+
54
+ # 依赖名 → 框架名(只认清单里的显式依赖)
55
+ JS_FRAMEWORKS = {
56
+ "react": "React", "vue": "Vue", "next": "Next.js", "nuxt": "Nuxt",
57
+ "express": "Express", "fastify": "Fastify", "koa": "Koa", "@nestjs/core": "NestJS",
58
+ "vite": "Vite", "webpack": "Webpack", "electron": "Electron",
59
+ }
60
+ PY_FRAMEWORKS = {
61
+ "django": "Django", "flask": "Flask", "fastapi": "FastAPI",
62
+ "torch": "PyTorch", "tensorflow": "TensorFlow", "pytest": "pytest",
63
+ "sqlalchemy": "SQLAlchemy", "pydantic": "Pydantic",
64
+ }
65
+
66
+
67
+ def _iter_files(root: Path):
68
+ seen = 0
69
+ root_s = str(root)
70
+ for dirpath, dirnames, filenames in os.walk(root_s):
71
+ dirnames[:] = [d for d in dirnames if d not in SKIP_DIRS]
72
+ rel = os.path.relpath(dirpath, root_s)
73
+ depth = 0 if rel == "." else rel.count(os.sep) + 1
74
+ if depth > MAX_DEPTH:
75
+ dirnames[:] = []
76
+ continue
77
+ for name in filenames:
78
+ yield Path(dirpath) / name
79
+ seen += 1
80
+ if seen >= MAX_FILES:
81
+ return
82
+
83
+
84
+ def _read_json(path: Path) -> dict:
85
+ try:
86
+ return json.loads(path.read_text(encoding="utf-8", errors="replace"))
87
+ except Exception:
88
+ return {}
89
+
90
+
91
+ def _js_frameworks(path: Path) -> list:
92
+ data = _read_json(path)
93
+ names = set()
94
+ for section in ("dependencies", "devDependencies", "peerDependencies"):
95
+ for dep in (data.get(section) or {}):
96
+ if dep in JS_FRAMEWORKS:
97
+ names.add(JS_FRAMEWORKS[dep])
98
+ return sorted(names)
99
+
100
+
101
+ def _py_frameworks(root: Path) -> list:
102
+ names = set()
103
+ req = root / "requirements.txt"
104
+ if req.exists():
105
+ for line in req.read_text(encoding="utf-8", errors="replace").splitlines():
106
+ token = line.strip().split("==")[0].split(">=")[0].split("[")[0].lower()
107
+ if token in PY_FRAMEWORKS:
108
+ names.add(PY_FRAMEWORKS[token])
109
+ pyproj = root / "pyproject.toml"
110
+ if pyproj.exists():
111
+ text = pyproj.read_text(encoding="utf-8", errors="replace").lower()
112
+ for dep, label in PY_FRAMEWORKS.items():
113
+ if f'"{dep}"' in text or f"'{dep}'" in text:
114
+ names.add(label)
115
+ return sorted(names)
116
+
117
+
118
+ def detect(path=".") -> dict:
119
+ """返回 {root, languages[{name,files,share}], markers, frameworks, truncated}。"""
120
+ root = Path(path).expanduser().resolve()
121
+ if not root.is_dir():
122
+ raise ValueError(f"{root} 不是目录")
123
+ counts = {}
124
+ truncated = False
125
+ scanned = 0
126
+ for f in _iter_files(root):
127
+ scanned += 1
128
+ ext = f.suffix.lower()
129
+ lang = LANG_EXT.get(ext)
130
+ if lang:
131
+ counts[lang] = counts.get(lang, 0) + 1
132
+ if scanned >= MAX_FILES:
133
+ truncated = True
134
+ break
135
+ total = sum(counts.values()) or 1
136
+ languages = [{"name": n, "files": c, "share": round(c / total, 3)}
137
+ for n, c in sorted(counts.items(), key=lambda x: (-x[1], x[0]))[:8]]
138
+ markers = []
139
+ for name, (kind, label) in MARKERS.items():
140
+ if (root / name).exists():
141
+ markers.append({"file": name, "kind": kind, "label": label})
142
+ frameworks = []
143
+ pkg = root / "package.json"
144
+ if pkg.exists():
145
+ frameworks += _js_frameworks(pkg)
146
+ frameworks += _py_frameworks(root)
147
+ return {"root": str(root), "scanned": scanned, "truncated": truncated,
148
+ "languages": languages,
149
+ "markers": sorted(markers, key=lambda m: m["file"]),
150
+ "frameworks": sorted(set(frameworks))}
151
+
152
+
153
+ def summary_line(info: dict) -> str:
154
+ top = "、".join(f"{l['name']} {int(l['share'] * 100)}%" for l in info["languages"][:3])
155
+ parts = [f"主语言 {top}"] if top else ["未识别到源码文件"]
156
+ if info["frameworks"]:
157
+ parts.append("框架 " + "、".join(info["frameworks"][:4]))
158
+ if info["markers"]:
159
+ parts.append("构建 " + "、".join(m["label"] for m in info["markers"][:3]))
160
+ return ";".join(parts)
@@ -0,0 +1,102 @@
1
+ """诊断分层与错误解释(doctor 报告 + `explain` 子命令共用一张表)。
2
+
3
+ 动机(对表 huaweicloud-devkit 的 doctor-report / explain-error):我们原来的
4
+ doctor 是一条条 FAIL 平铺打印,"哪里坏了"和"下一步做什么"全靠读文案猜;
5
+ 运维在现场只会记住一句话——"doctor 报错了"。这里把**分类**和**动作**外置成数据:
6
+
7
+ - 每条检查/错误按关键词归到一个层(环境/载荷/配置/技能/网络/插件),
8
+ 输出时按层分组,一眼看出是"机器环境问题"还是"我们自己的安装问题";
9
+ - 同一张表提供 explain():给错误码或错误片段,返回 层 / 原因 / 动作。
10
+
11
+ 纪律:
12
+ - 表只描述"已知失败形态",不猜未知错误(未知就如实报"未收录"并给出排查入口)。
13
+ - 归层只按关键词匹配(确定性),不做语义推断——误归层会把运维带偏。
14
+ """
15
+ import fnmatch
16
+ import re
17
+
18
+ LAYERS = ["环境", "载荷", "配置", "技能", "网络", "插件"]
19
+
20
+ # (关键词/正则, 层, 原因, 动作)
21
+ RULES = [
22
+ (r"无 install-manifest|未 install",
23
+ "环境", "还没装(或 manifest 被删)", "运行 install --target <宿主>"),
24
+ (r"commitSHA 不一致|commitSha",
25
+ "载荷", "安装记录与当前包不是同一份构建(升版后未重装)", "重跑 install"),
26
+ (r"载荷目录缺失|载荷被改动|载荷残留",
27
+ "载荷", "MCP 入口指向的副本不在/被改", "重跑 install 重建副本"),
28
+ (r"MCP 配置文件缺失|mcpConfig",
29
+ "配置", "宿主配置文件被删或挪了位置", "重跑 install --target <宿主>"),
30
+ (r"未列出 vod-devkit|mcp list",
31
+ "配置", "宿主没读到我们的 MCP 条目", "检查宿主配置文件里的 mcp 段后重装"),
32
+ (r"skills 目录缺失|技能文件缺失|技能文件漂移|技能原生副本缺失|技能拷贝件",
33
+ "技能", "技能副本缺失或与安装指纹不符", "重跑 install 恢复"),
34
+ (r"路由插件副本落后|vod-feedback-router",
35
+ "插件", "仓内话术已更新但装机副本是旧的", "重跑 install --target hermes"),
36
+ (r"AGENTS\.md 仍含旧一代注入|vod-submit-one-liner",
37
+ "插件", "旧注入教模型跳过征询(红线失效)", "重跑 install --target codex 自动清理"),
38
+ (r"远程面|远程 MCP|探活|不可达|401",
39
+ "网络", "远程端点不可达或工具面不符", "检查网络/端点版本;设 VOD_MCP_TOKEN 再验"),
40
+ (r"key 无效|401 拒绝|指纹",
41
+ "网络", "引擎拒绝了 key", "核对/续期 key,或移除 key 走匿名档"),
42
+ (r"引擎不可达|ProbeError|timed out|Connection",
43
+ "网络", "引擎/网络不可达(不是 key 问题)", "查网络出口与引擎健康;离线可继续工作"),
44
+ (r"-32010|产品", "配置", "缺产品归属,拒绝提交", "先问用户是哪个产品,再带 product 提交"),
45
+ (r"python|node|版本", "环境", "运行时版本不满足", "按 README 的版本要求升级"),
46
+ ]
47
+
48
+ _EXPLAIN_EXTRA = {
49
+ "-32010": ("配置",
50
+ "缺少产品归属(用户没说、也追问不到),服务端拒绝写引擎",
51
+ "先用 vod_search_products 给候选问用户;用户说不清楚就不提交"),
52
+ "-32011": ("配置", "产品不在名录里", "按名录候选再确认一次;仍对不上则不提交"),
53
+ }
54
+
55
+
56
+ def classify(message: str) -> tuple:
57
+ """把一条失败/警告文案归到 (层, 原因, 动作)。未收录 → ("未分类", "", "")。"""
58
+ for pat, layer, cause, action in RULES:
59
+ if re.search(pat, message):
60
+ return layer, cause, action
61
+ return "未分类", "", ""
62
+
63
+
64
+ def explain(text: str) -> dict:
65
+ """给错误码或错误片段,返回 {layer, cause, action, known}。"""
66
+ for code, (layer, cause, action) in _EXPLAIN_EXTRA.items():
67
+ if code in text:
68
+ return {"layer": layer, "cause": cause, "action": action, "known": True}
69
+ layer, cause, action = classify(text)
70
+ return {"layer": layer, "cause": cause, "action": action,
71
+ "known": layer != "未分类"}
72
+
73
+
74
+ def group(problems: list) -> dict:
75
+ """按层分组(保持 LAYERS 顺序,未分类排最后)。"""
76
+ buckets = {l: [] for l in LAYERS}
77
+ buckets["未分类"] = []
78
+ for msg in problems:
79
+ layer, cause, action = classify(msg)
80
+ buckets[layer].append((msg, cause, action))
81
+ return {k: v for k, v in buckets.items() if v}
82
+
83
+
84
+ def render_problems(problems: list) -> str:
85
+ """把失败清单渲染成分层报告(供 doctor 输出)。"""
86
+ if not problems:
87
+ return ""
88
+ out = []
89
+ for layer, items in group(problems).items():
90
+ out.append(f"[{layer}]")
91
+ for msg, cause, action in items:
92
+ out.append(f"FAIL: {msg}")
93
+ if cause:
94
+ out.append(f" 原因:{cause}")
95
+ if action:
96
+ out.append(f" 动作:{action}")
97
+ return "\n".join(out)
98
+
99
+
100
+ def matches(message: str, pattern: str) -> bool:
101
+ """给运维手输片段做粗匹配(大小写不敏感,支持 * 通配)。"""
102
+ return fnmatch.fnmatch(message.lower(), pattern.lower())