DSH Profile 架构:Cordis → Bundle → Patch → Profile
你前面已经接触过 Cordis → Bundle → Patch → Profile,现在把这几个东西串起来,DSH 的 Profile 架构其实就很好理解了。
官方架构把 DSH 描述成:启动时按照多个有序 layer 组合出来的一棵 Cordis plugin tree。Profile 本质上就是这棵树的“组装说明书”。
1. 先记住一句话
Profile = 一个“可运行的 DSH 产品形态”的配置组合。
例如:
web profile
│
├── dsh-base
│
├── dsh-web-app
│
├── profile/cordis.patch.yml
│
├── $DSH_HOME/cordis.patch.yml
│
└── --patch xxx.yml最终这些东西会被组合成:
DSH
│
┌──────┴──────┐
│ Cordis Tree │
└──────┬──────┘
│
┌──────┴───────┐
│ │
core plugins web plugins
│ │
agent/llm/... web/api/...所以 Profile 自己并不是 Agent,也不是 Plugin。
它更像:
“我要启动什么样的一棵 Plugin Tree?”
2. Profile 到底是什么?
官方定义是:
Profile 是
$DSH_HOME/profiles/<name>下的一个 named composition。
也就是:
$DSH_HOME/
└── profiles/
└── web/
├── package.json
├── cordis.patch.yml
└── pnpm-workspace.yaml例如:
dsh --profile webDSH 首先找到:
$DSH_HOME/profiles/web/然后读取它的 ../../package.json。
其中会有类似:
{
"name": "dsh-profile-web",
"dsh": {
"profile": {
"bundles": [
"@deepseek-ai/dsh-base",
"@deepseek-ai/dsh-web-app"
]
}
}
}这里最重要的是:
bundles它告诉 DSH:
这个 Profile 由哪些 Bundle 组成,以及按照什么顺序组成。
官方源码文档也明确说明,dsh.profile.bundles 就是 Profile 的 bundle 列表。
3. Profile 和 Bundle 的关系
这是 DSH 最容易混淆的地方。
可以把它类比成:
Profile
↓
“我要组装什么?”
Bundle
↓
“我提供什么?”
Patch
↓
“具体怎么配置?”
Plugin
↓
“真正执行什么代码?”例如:
web Profile
│
├── dsh-base Bundle
│ ├── llm
│ ├── session
│ ├── agent
│ ├── tools
│ ├── sandbox
│ └── ...
│
└── dsh-web-app Bundle
├── web-server
├── api
├── workspace
└── browser UI所以:
Profile 不是 Bundle 的上级代码模块。
更准确地说:
Profile
│
│ references
▼
Bundle
│
│ provides
▼
Cordis patch entries
│
│ mounts
▼
Plugins4. 为什么需要 Profile?
这是 DSH 架构非常漂亮的一点。
假设 DSH 有一个共同的 Agent 核心:
LLM
Session
Agent
Agent Loop
Tools
Persistence
Sandbox
Credentials
...但是不同场景需要不同“外壳”。
例如:
Web
Agent Core
+
Web UI
+
HTTP/APIHeadless
Agent Core
+
CLI RunnerSDK
Agent Core
+
JSON-RPC ServerACP
Agent Core
+
ACP Server那么没必要复制四套 DSH。
而是:
dsh-base
│
┌────────────┼─────────────┐
│ │ │
web headless sdk
│ │ │
web-app runner sdk-app所以:
Profile 把“产品形态差异”从代码差异变成了配置组合差异。
官方目前的架构中,web、headless、sdk、acp 都采用这种方式;sdk-minimal 是一个特殊的独立 bundle。
5. Bundle 又是什么?
Bundle 是一个可以被 Profile 装进去的配置层。
例如:
@deepseek-ai/dsh-base它本身有:
package.json
cordis.patch.yml
代码模块package.json 会声明:
{
"dsh": {
"bundle": {
"patch": "./cordis.patch.yml"
}
}
}意思就是:
“我是一个 DSH Bundle,我提供了一份 Cordis Patch。”
官方文档对 Bundle 的定义就是:
Cordis config rows + the code they mount 的 distribution format。
6. Profile 真正厉害的地方:Layer
现在来到最关键的部分。
DSH 不是:
读取一个配置文件
↓
启动而是:
空配置
↓
Bundle 1
↓
Bundle 2
↓
Profile Patch
↓
Home Patch
↓
--patch
↓
最终配置
↓
启动 Cordis Tree官方定义的顺序是:
1. Profile 中的 Bundles
2. Profile cordis.patch.yml
3. $DSH_HOME/cordis.patch.yml
4. --patch后面的 layer 优先级更高。
7. 用你的 DSH 环境举例
你之前的:
~/.dsh/profiles/web/大概就是:
web/
├── package.json
├── cordis.patch.yml
└── pnpm-workspace.yaml而 ../../package.json 里面类似:
dsh.profile
│
└── bundles
│
├── @deepseek-ai/dsh-base
└── @deepseek-ai/dsh-web-app于是启动:
dsh --profile web实际上是在做:
dsh --profile web
│
▼
找到 web profile
│
▼
读取 dsh.profile
│
▼
┌──────────────┴──────────────┐
│ │
dsh-base dsh-web-app
│ │
└──────────────┬──────────────┘
▼
profile patch
│
▼
home-level patch
│
▼
--patch
│
▼
最终 Cordis Tree
│
▼
启动8. 为什么你之前的 cordis.yml 是 []?
这个地方非常容易误解。
你之前的:
[]并不意味着:
DSH 什么都没有。
它意味着:
Profile 本身没有直接声明 Cordis entry。
真正的东西来自:
dsh-base
dsh-web-app这些 Bundle。
所以:
profile/cordis.yml = []完全可以有:
几十个 / 上百个 plugin因为它们来自 Bundle 的 patch。
这也是 DSH 设计的核心之一:
Profile 是 composition,不是 plugin implementation。
9. Profile Patch 又是什么?
假设:
dsh-base里面有:
- id: llm
plugin: ...
config:
provider: ...然后你的:
profiles/web/cordis.patch.yml可以针对:
id: llm进行覆盖。
例如概念上:
- id: llm
config:
provider: xxx那么:
dsh-base
↓
创建 llm
↓
profile patch
↓
覆盖 llm因此最终使用的是 Profile 层的配置。
10. 一个非常重要的细节:不是 deep merge
这点以后你维护 DSH 会经常碰到。
如果原来:
- id: llm
config:
provider: openai
model: xxx
temperature: 0.7你 patch:
- id: llm
config:
model: yyy并不是简单地变成:
config:
provider: openai
model: yyy
temperature: 0.7而是 patch 对匹配的 row 的 config 进行整体替换。官方文档明确指出这里不是 deep merge。
所以理解成:
同一个 id
↓
后面的配置
↓
替换前面的配置更准确。
11. Home Patch 为什么还要存在?
这里就体现出 DSH 的分层思想了。
有:
~/.dsh/profiles/web/cordis.patch.yml也有:
~/.dsh/cordis.patch.yml它们的意义不同。
Profile patch
“Web 这个 Profile 怎么配置”只影响:
webHome patch
“我这台机器上的 DSH 都怎么配置”影响:
web
headless
sdk
...因此:
DSH_HOME
│
┌────────────┴────────────┐
│ │
profiles/ cordis.patch.yml
│ │
┌───┴───┐ │
│ │ │
web headless │
│ │ │
└───┬───┘ │
│ │
└──────────┬──────────────┘
▼
Home-level override这也是为什么 Home Patch 的优先级高于 Profile Patch。
12. --patch 是什么?
最后还有:
dsh --profile web --patch xxx.yml它是:
临时最高优先级覆盖层。
所以:
Bundle
↓
Profile Patch
↓
Home Patch
↓
--patch ← 最高这非常适合实验。
例如你想测试:
换一个模型没必要修改:
~/.dsh/profiles/web/cordis.patch.yml可以:
dsh --profile web --patch experiment.yml实验结束直接删掉命令即可。
13. 你可以把整个架构理解成“CSS 层叠”
这个比喻其实非常准确。
假设:
dsh-base定义:
llm = A然后:
web bundle定义:
llm = B然后:
profile patch定义:
llm = C然后:
home patch定义:
llm = D最后:
--patch定义:
llm = E最终:
llm = E也就是:
base
↓
web
↓
profile
↓
home
↓
command line
↓
最终值越靠后,优先级越高。
14. Profile 最核心的结构图
我建议你以后脑子里就记这一张:
DSH
│
▼
┌───────────┐
│ Profile │
│ "web" │
└─────┬─────┘
│
bundles[]
│
┌───────────┴───────────┐
▼ ▼
┌───────────┐ ┌──────────────┐
│ dsh-base │ │ dsh-web-app │
└─────┬─────┘ └──────┬───────┘
│ │
└───────────┬────────────┘
▼
Cordis Patch Entries
│
▼
profile/cordis.patch.yml
│
▼
$DSH_HOME/cordis.patch.yml
│
▼
--patch
│
▼
┌──────────────────┐
│ Final Config Tree│
└────────┬─────────┘
│
▼
Cordis Context
│
┌────────────┼────────────┐
▼ ▼ ▼
LLM Agent Tools
│ │ │
└────────────┼────────────┘
▼
Running DSH15. 这和你之前研究的 @local/sople-badge 又有什么关系?
这个就很重要了。
你之前实际上是在做:
DSH Profile
│
├── dsh-base
├── dsh-web-app
│
└── @local/sople-badge也就是说,你不是在修改 DSH 的核心代码。
你是在:
向一个现有 Profile 增加自己的 Plugin / Bundle。
这正是 DSH 架构希望你做的事情。
官方架构甚至明确强调:DSH 没有一个必须修改的“特权核心”;功能通过 Plugin 挂载到共享 Cordis Context 中。
16. 最后把四个概念彻底区分
| 概念 | 你可以把它理解成 |
|---|---|
| Cordis | Plugin 运行框架 |
| Plugin | 一个实际能力 |
| Bundle | 一组可分发、可组合的 Plugin 配置层 |
| Profile | “我要运行哪一套 Bundle”的产品组合 |
| Patch | 修改某个 Plugin 配置的覆盖层 |
--patch | 临时最高优先级 Patch |
最关键的一条关系:
Profile
│
chooses / orders
│
▼
Bundles
│
provide layers
│
▼
Patch Entries
│
mount code
│
▼
Plugins
│
▼
Cordis Context所以如果你现在准备真正深入 DSH 源码,下一步最值得搞懂的不是继续研究 Profile 文件本身,而是:
Profile → Bundle → cordis.patch.yml → composeEntries → Cordis Plugin Tree → ctx 的启动过程。
一旦这条链理解了,你之前遇到的 HARNESS Failed to load plugins、@local/sople-badge、Profile patch、Bundle、HMR 基本都会串成一个完整的体系。官方也建议用 dsh --profile web --dump-config 直接观察机器实际启动出来的配置树。