DeepSeek Harness 源码解析 · 第 2 讲
DeepSeek Harness 源码解析系列 第 2 讲:Profile、Bundle 与 Preset 组合机制 基于 DeepSeek Harness 源码 · 2026-08-17 引言 上一讲我们拆解了 DeepSeek Harness 的整体架构与 Cordis 插件框架,理解了 insert/patch/replace 三操作如何组合一棵插件树。但一个实际的问题随之而来:一个 Harness 部署 到底由哪些插件构成 ?用户如何定制 Agent 的能力?答案是三层组合体系—— Profile (启动模式)、 Bundle (共享配置层)与 Preset (Agent 能力预设)。这三者叠加,决定了每一个 Agent 实例的完整能力集。 一、Bundle:共享配置层 Bundle 是 Harness 的 共享配置层 。它定义了所有 Profile 共用的插件行,是系统的"地基"。每个 Bundle 包含一个 cordis.patch.yml 文件,通过 patch 操作向空白的 Profile Root 注入插件。 让我们看 dsh-base bundle——所有 CLI 模式共享的核心: 📄 packages/bundle/base/cordis.patch.yml(头部注释,第 1-13 行) <code style="font-family:Menlo,Monaco,Courier New,monospace !important;"># The dsh-base bundle patch: the shared core of every dsh profile, applied as # ONE insert over the empty profile root. Later bundle patches and the user's # profile cordis.patch.yml address these rows by id, with the last write # winning per row. # # A patch replaces the targeted row's whole `config` rather than merging into # it, so a row whose value differs by mode does NOT live here: it belongs to # each mode bundle, keeping any single row down to one bundle layer plus the # user's. Mode-specific rows appear below only with shared plugin identity and # neutral defaults; each mode bundle restates its complete configuration. # # Row order carries no load semantics (activation is service-availability # driven); the grouping is for readers. 这段注释揭示了 Bundle 设计的三个核心原则: 🔹 按 ID 覆盖(last write winning) :后续 Bundle Patch 和用户 Profile 的 cordis.patch.yml 通过 patch 操作按 ID 修改行,后写的覆盖先写的。 🔹 Config 整体替换 :Patch 替换整行 config 而非合并,因此不同模式(headless/tui/web)的值差异由各模式 Bundle 单独声明。 🔹 行序无加载语义 :插件激活由服务可用性驱动(Cordis 的 inject 依赖),而非文件中的行顺序。 Base Bundle 注入了约 70 个插件行 ,涵盖 LLM 适配器、Session 持久化、沙箱、工具注册、Subagent、Workflow、Compaction 等。关键行包括: 📄 packages/bundle/base/cordis.patch.yml(核心插件…