Vai al contenuto principale
H

dsh-skill-suggest

heavenyu1982yu/dsh-skill-suggest

Injects one line of skill-relevance advice per user turn via a fail-open two-hop TypeSafe Jev gate (coarse roster rank, then top-3 check); the final decision to call a skill stays with the main model, and any Jev failure degrades to no suggestion without blocking the session.

Installazione

dsh plugin --profile web add github:heavenyu1982yu/dsh-skill-suggest

README

dsh-skill-suggest

English: A fail-open, two-hop skill-suggestion plugin for DeepSeek Harness (DSH). On each new user turn it asks TypeSafe Jev whether a skill is needed, and if so injects one line of <skill_relevance> advice into context — the roster and prefix cache stay untouched, and any Jev failure degrades to "no suggestion" instead of blocking your session.

DSH 技能目录动辄几百条、同族重名多(几十个 retail-*、双 humanizer、多 browser-*),模型只看一行截断索引就选 → 错载、无匹配硬载。本插件给会话加一道技能预选门:每轮先问 Jev「要不要技能」,要则 top-3 复核,胜者只注入一行建议,调不调仍由主模型决定。

配方出处:TypeSafe skill suggestion cookbook。

实测指标(二期,2026-09-24)

历史真实 turn 基准(60 对,seed 42)× 同代码路径离线重放(38 建议)× 同一 LLM 判官(mimo-v2.6-flash,双臂公平):

指标基线(历史实载)建议(本插件)通过线结果
错载率13.33%2.63%降 ≥40%↓80.3%
滥载率(不需要也载)30.00%7.89%降 ≥40%↓73.7%
注入 token / 轮—141-162 字符 ≈ 40-44 tok≤50✓
Jev 故障阻塞—0零✓

口径说明:B 臂度量的是建议质量(同代码路径),不是模型遵循建议的全闭环;地板非零,勿以「零错载」为验收线(cookbook 同结论)。原始数字见 phase2_metrics.json。

端到端金丝雀(真实 GUI 会话触发 turn):trace 落 plan/reason=suggested name=minimax-xlsx,会话文件出现 source.kind="skill-suggest" 注入行——wiring 闭环。

安装

# 克隆后经官方插件路径挂载到你的 profile(reconcile 自动登记 bundle)
git clone https://github.com/heavenyu1982yu/dsh-skill-suggest.git
dsh plugin --profile <你的profile> add link:<clone路径>
# 重启 dsh web 生效

dsh plugin add 的 git+/npm 直挂形式未经本仓库实测,欢迎反馈;link: 是实测路径。

配置

项说明
TYPESAFE_API_KEY环境变量,或写 ~/.dsh/.credentials.yaml 的 refs——自备 TypeSafe key(无 key = 静默 fail-open,不阻塞)
profile cordis.patch.yml → config.enabledfalse 一键速关(不动代码)
DSH_SKILL_SUGGEST_TRACE覆盖 trace 路径,默认 ~/.dsh/skill-suggest.trace.jsonl

工作原理

新用户输入 → 门序(任何一道不过 = 零 Jev 调用)
  reject → enabled → 本轮去重 → 有新用户文本(纯工具步跳过)
  → skill 工具可见 → 技能快照完整(last-good)→ 存在 model-invocable 技能
  → Jev 两跳:①全量 roster noul 粗排 + 判「本轮要不要技能」
             ②top-3 choice 复核(含「都不合适」可全否)
  → 胜者 → 注入一行 <skill_relevance>(带 "Ignore if not fit" 软化措辞)
  • 只建议,不执行:注入的是一条 user-role 提示消息(source.kind="skill-suggest"),最终调不调 skill 工具由主模型判断;你显式点名 skill 的指令永远优先。
  • fail-open-but-loud:无 key / 超时 / Jev 挂 / 任何异常 → 当轮无建议,绝不阻塞会话;同时把 reason 写进 trace。

诊断:trace 文件

每次判定都落一行 JSON(boot 标记 + 各门 reason):

{"t":"...","stage":"boot","event":"apply","config":{"enabled":true,"keys":["enabled"]}}
{"t":"...","stage":"plan","reason":"suggested","name":"minimax-xlsx"}

reason 速查:disabled / dup / no-turn / no-tool / snapshot-incomplete / no-invocable / no-fit(Jev 判无需技能)/ error(Jev 异常,fail-open)/ suggested;stage=handler, reason=fatal = 兜底防线捕获的异常。

开发

node --check plugin.mjs && node --check skill-suggest.mjs   # 语法
node --test skill-suggest.test.mjs                           # 61 条单元测试(零网络)
node preflight.mjs                                           # 不启 DSH 的双断言预检
node smoke_live.mjs                                          # 真 Jev 三场景冒烟(需 key)

⚠️ DSH 插件禁配 default 导出:cordis-plugin-loader 解析是 exports.default ?? exports,default 会把插件解包成裸函数、丢掉 name/inject → 运行期 cannot get property ... without inject。只用命名导出(name / inject / apply);回归钉测试锁死此约束。entry 级 inject: [...](cordis.patch.yml)作为第二通道双保险。

回滚

dsh plugin --profile <你的profile> remove dsh-skill-suggest   # 彻底下树
# 或 profile cordis.patch.yml 里 config.enabled: false         # 软关

边界

  • 每个新用户轮 +2 Jev 请求、+2-4s 前置延迟、+≈40-44 token 注入行;纯工具步零调用。
  • 中文技能描述下的判分精度未分场景标定;Jev 只判不生成。
  • 依赖 DSH 的 agent/pre-step waterfall、ctx.skills / ctx.tools 接口契约,DSH 升级时需复测。

致谢

License

MIT

Plugin correlati