TACONailoong/dsh-plugin-smart-config ↗★ 1

dsh-plugin-smart-config

DeepSeek Harness plugin for model smart configuration & capability adaptation, ported from ZCode 适合需要按模型、协议和供应商自动匹配配置,并适配工具调用与思考参数的用户。

패키지
dsh-plugin-smart-config
호환성
미검증
버전
1.0.6
라이선스
MIT
최근 업데이트
2026. 9. 25.

설치

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:TACONailoong/dsh-plugin-smart-config

dsh-plugin-smart-config (DeepSeek Harness 智能配置插件)

English | 简体中文

npm version npm downloads GitHub release license

本项目逆向并移植了 ZCode 的大模型“智能配置”(Follow Recommended Config / 推荐配置引擎),将其封装为适用于 DeepSeek Harness (dsh) 的标准 Cordis 插件。


🌟 核心功能

  1. 五层级联推荐匹配引擎:

    • L1 全局兜底规则 (modelRules: .*):提供安全的缺省上限与上下文底座。
    • L2 模型名正则规则 (modelRules):精确匹配模型族(如 GLM-5 系列、DeepSeek、Claude、Kimi 等)的原生参数。
    • L3 API 协议特化规则 (modelApiRules):区分 anthropic-messages、openai-chat-completions、openai-responses 间的特性支持差异。
    • L4 站点/代理特化规则 (providerSiteRules):根据 baseUrl 与 apiType 识别特定供应商或中转站(如 OpenCode、阿里云百炼、智谱等)的个性化映射。
    • L5 模板/供应商直配 (templateModelRules / exactModelRules):官方供应商模板专属配置。
  2. 字段级智能差分继承 (Field-level Overlay):

    • 开启智能配置时:用户未修改的字段自动跟随云端/官方推荐规则实时迭代;
    • 用户手动调整某项参数时,仅该项被固化为覆写,不影响其余参数的动态继承。
  3. 模型能力守卫与请求自适应映射 (Request Adapter & Guard):

    • 工具调用守卫:若模型不支持 Tool Calling,自动拦截并剔除 tools 参数,防止 400 报错。
    • 多模态/识图守卫:校验模型是否支持图像/视频/PDF,给出能力提示。
    • 深度思考与推理参数转译:根据模型规格,自动将通用的 reasoning_effort 映射为对应的请求体结构(如 Claude 的 thinking.type + output_config.effort、DeepSeek 的 enable_thinking、OpenAI 的 reasoning_effort 等)。
  4. 离线高可用 + 云端热更新同步 (Remote Synchronizer):

    • 内置完整 Revision 30 本地离线规则库(涵盖 20+ 模板、84+ 模型规则、72+ 协议规则、52+ 站点规则);
    • 支持后台轮询服务端配置接口,通过租约机制无感拉取最新规则。
  5. DSH 系统配置主动同步与思考强度自适应 (Active Settings Sync & Capabilities Adaptation):

    • 自动检测并计算 reasoningEfforts(支持 off、low、high、max 多档思考强度),无缝点亮 Composer 输入框下方的思考强度调节器;
    • 自动识别补齐 contextWindow (100万 Token)、maxTokens、多模态视觉能力 input: ['text', 'image']、以及 thinkingFormat: "deepseek" 方言兼容选项;
    • 在 DSH 启动及运行过程中自动将能力写回系统配置 ctx.settings。
  6. OpenCode 专属协议头自动增强 (OpenCode Request Header Enhancement):

    • 全局拦截 *.opencode.ai 请求,自动携带 User-Agent: opencode/1.0.0、x-opencode-client: opencode 与 x-opencode-session 会话标识,保障 API 鉴权与调用合规。

📂 目录结构

dsh-plugin-smart-config/
├── package.json               # 插件清单 (keywords: dsh-plugin, cordis)
├── tsconfig.json              # TypeScript 编译配置
├── README.md                  # 说明文档
├── src/
│   ├── index.ts               # DeepSeek Harness / Cordis 插件入口 (apply, Service, Hooks)
│   ├── types.ts               # 核心类型声明 (ModelConfig, Rule, OptionSpecs 等)
│   ├── engine.ts              # 逆向提取的核心 5 层级联算法与 Overlay 合并器
│   ├── sync.ts                # 远端规则热更新同步器 (带本地缓存与并发控制)
│   ├── adapter.ts             # Agent 模型调用拦截器与请求参数转译器
│   └── rules/
│       └── builtin-rules.json # 完整的出厂内置规则库 (从 ZCode 逆向提取)
└── test/
    ├── test.ts                # 完整自动化测试套件
    └── demo.ts                # 交互式命令行验证脚本

🚀 快速上手

1. 从 NPM 安装


# 使用 npm
npm install dsh-plugin-smart-config

# 使用 pnpm
pnpm add dsh-plugin-smart-config

# 使用 yarn
yarn add dsh-plugin-smart-config

2. 运行测试与演示 (Node.js 22+)

无需额外编译,直接借助 Node 运行测试: