Skip to content

feat(dsh): 改用标准 DSH profile 机制,支持 Dashboard 选 profile 与独立 workspace - #1167

Merged
deepcoldy merged 11 commits into
deepcoldy:masterfrom
nil-err:feat/dsh-cordis-config-cli-arg
Sep 2, 2026
Merged

deepcoldy merged 11 commits into
deepcoldy:masterfrom
nil-err:feat/dsh-cordis-config-cli-arg

Conversation

@nil-err

@nil-err nil-err commented Sep 1, 2026 •

Copy link
Copy Markdown
Collaborator

将 dsh-runner 从动态生成 cordis.yml 改为使用标准 DSH profile 目录
(~/.dsh/profiles/botmux/),插件组合全部放在 cordis.patch.yml 中,
cordis.yml 保持空数组。DSH 运行时自动发现同目录的 cordis.patch.yml。

改动

核心:dsh-runner 改用 profile 机制

  • 删除 VENDORED_CONFIG 常量和 generatePiAiComposition/writeComposition
  • 新增 resolveProfilePath() 解析 profile 目录,自动创建空 cordis.yml
  • resolveNativeDshConfig() 简化为从 profile 路径 + settings.yaml 读取 provider/model
  • dsh.ts buildArgs 传递 --dsh-profile botmux(支持 per-bot 覆盖)
  • 不再需要 mkdir ~/.dsh/botmux(composition 不再写到这里)

ensureProfileDir / createDshProfile:最小骨架 profile

  • 仅写入最小骨架:package.json(dsh-base bundle + sdk-jsonrpc-server + sdk-protocol 依赖)、cordis.yml(空数组)、cordis.patch.yml(仅 disable Web GUI + insert SDK JSON-RPC server)
  • 不再手写 8 个插件到 cordis.patch.yml:dsh-base 已提供 agent、llm、bash、fs、sessions、sandbox、subagent、subprocess、session-checkpoints 等 50+ 个插件,重复声明会导致 duplicate id 错误
  • 社区插件(traex-bridge、openviking、genui 等)通过 dsh plugin --profile <name> add <pkg> 安装,具有 dsh.bundle 的包会自动注入其 cordis.patch.yml
  • 修复 dsh-sdk-jsonrpc-server 缺少 peer dep dsh-sdk-protocol 导致 ERR_MODULE_NOT_FOUND 的问题

Dashboard:DSH profile 选择与新建

  • bots.json 新增 dshProfile 字段(per-bot,仅 dsh CLI 生效)
  • GET /api/dsh/profiles — 列出 ~/.dsh/profiles/ 下可用 profile
  • POST /api/dsh/profiles — 创建新 profile,预填最小骨架
  • BotAgentSection 新增 profile 下拉选择器,切换 dsh CLI 时自动拉取列表
  • i18n 新增 dshProfileTitle / dshProfileHelp / dshProfileNew 等字段

独立 workspace 目录

  • 每个 bot 使用独立 workspace 目录(~/.dsh/sessions/botmux/<id>/)进行 DSH Web GUI 分组
  • initialize RPC 使用实际工作目录作为 cwd

文档

  • 更新 adapters.md(zh/en)和设计文档,将 dsh-jsonrpc-agent 改为 dsh CLI
  • 更新 RAW_CLI_EXECUTABLES 将 dsh-jsonrpc-agent 改为 dsh

测试修复

  • 更新 dsh-runner 测试以匹配 profile 方案
  • 修复 mojo 并发凭据轮次竞态(A/B/C 不再跑成 A/C/C)——liveJwt 在 write() 时截取快照,避免序列化延迟导致 buildEnv() 读到被覆盖的凭据
  • 修复 dashboard-bot-defaults-cliid 测试:mock fetch 新增 /api/dsh/profiles 过滤,避免 fetchDshProfiles() 污染 requests 数组

好处

  • 插件配置不再被 botmux 每次 spawn 覆盖
  • 用户可直接编辑 cordis.patch.yml 增删插件/改模型
  • 遵循 DSH 官方 profile 分层机制,Dashboard 可直接选 profile 和新建 profile
  • 每个 bot 独立 workspace,不会互相干扰

验证

  • bun run build 通过
  • 编译产物中旧代码(VENDORED_CONFIG、generatePiAiComposition)已清除
  • --dsh-profile 参数正确传递
  • mojo 跨边界测试 7/7 通过
  • dsh-runner 22 项测试全部通过
  • dsh --profile botmux 启动正常,SDK JSON-RPC 响应正常

@nil-err
nil-err requested a review from deepcoldy as a code owner September 1, 2026 09:58
@nil-err
nil-err marked this pull request as draft September 1, 2026 10:35
## 问题

dsh 适配器原来直接用 `dsh-jsonrpc-agent` 二进制启动,它只加载单个
`cordis.yml`,完全不经过 `dsh-base` 的 bundle 组合和 `cordis.patch.yml`
分层,导致:

1. 社区插件(openviking-memory、session-insights、genui 等)完全不加载
2. `llm-pi-ai` 的 traex-bridge provider 配置不生效
3. 插件配置无法由用户编辑,每次 spawn 都被 runner 覆盖

## 方案

改为 `dsh --profile <name>` 启动,这是 DSH 官方的 profile 组合路径:

```
dsh --profile botmux
  → loadLayeredEnv
  → 读取 package.json → dsh.profile.bundles → ["@deepseek-ai/dsh-base"]
  → 解析 bundle 的 cordis.patch.yml
  → 读取 profile 的 cordis.patch.yml
  → 组合所有 patch
  → boot() 启动全量插件树
  → sdk-jsonrpc-server 接管 stdin/stdout JSON-RPC
```

### 代码改动

**dsh-runner.ts** — 核心改动
- `NativeDshConfig.configPath` → `profileName`:不再传 cordis.yml 路径
- `resolveProfilePath()` → `ensureProfileDir(name)`:只创建目录,不写 cordis.yml
- 删除 `DSH_CORDIS_CONFIG` 环境变量覆盖(profile 机制已取代)
- 删除 `generatePiAiComposition` / `writeComposition`(不再动态生成 cordis.yml)
- 删除 `writeFileSync` 导入
- `DshJsonRpcClient` 构造函数接受 `profileName`,`start()` 改为
  `spawn(dshBin, ['--profile', profileName], ...)`

**src/adapters/cli/dsh.ts**
- `rawDshBin`: `'dsh-jsonrpc-agent'` → `'dsh'`
- `buildArgs` 新增 `dshProfile` 参数,`--dsh-profile` 从 bot config 读取
  而非硬编码 `'botmux'`

**src/adapters/cli/registry.ts**
- `RAW_CLI_EXECUTABLES['dsh']`: `'dsh-jsonrpc-agent'` → `'dsh'`

**src/adapters/cli/types.ts**
- `CliAdapterBuildArgs` 新增 `dshProfile?: string`

**src/adapters/cli/dsh-tui.ts**
- 注释更新:dsh-jsonrpc-agent → dsh CLI

**src/bot-registry.ts**
- `BotConfig` 新增 `dshProfile?: string` 字段

**src/core/worker-pool.ts**
- `forkWorker()` / `forkAdoptWorker()` 传递 `dshProfile`

**src/types.ts**
- `WorkerSnapshot` 新增 `dshProfile`

**src/worker.ts**
- `spawnCli()` 传递 `dshProfile`

**src/dashboard.ts / src/dashboard/web/** — Dashboard 支持
- `listDshProfiles()` 列出 ~/.dsh/profiles/ 下所有 profile
- Dashboard API 新增 `GET /api/dsh-profiles` 端点
- Bot 默认配置页新增 `dshProfile` 下拉选择器
- i18n 新增 `botDefaults.dshProfile*` 文案

**test/** — 测试更新
- `dsh-runner.test.ts`:检查 profile 目录存在性而非 cordis.yml 生成
- `cli-adapters.test.ts`:bin 路径引用更新为 `dsh`

**docs/** — 文档更新
- 设计文档、中英文使用文档全部更新为 `dsh --profile` 架构

### Profile 配置(~/.dsh/profiles/botmux/cordis.patch.yml)

botmux profile 的 cordis.patch.yml 内容(不上库,由用户自行维护):

```yaml
# 禁用 headless 模式下不需要的交互式插件
# 参考 dsh-headless bundle 的做法
- id: hmr
  disabled: true
- id: web
  disabled: true
- id: web-search-deepseek
  disabled: true
- id: tool-web
  disabled: true

# 插入 SDK JSON-RPC server + 社区插件
- insert:
    - id: sdk-jsonrpc-server
      name: '@deepseek-ai/dsh-sdk-jsonrpc-server'
    - id: archify-skill-filesystem
      name: '@deepseek-ai/dsh-skill-filesystem'
    - id: openviking-memory
      name: '@deepseek-ai/cordis-plugin-group'
      ...
    - id: session-insights
      name: 'dsh-session-insights'
    - id: genui
      name: '@changfenhuang/dsh-genui'
    - id: describe-image
      name: '@linxin666/dsh-tool-describe-image'
      disabled: true  # 缺少依赖待解决
    - id: llm-traex-bridge
      name: '@byted/dsh-traex-bridge'

# 覆盖 dsh-base 的 llm-pi-ai 配置
- id: llm-pi-ai
  config:
    providers:
      treax-bridge:
        apiKeyEnv: TREAX_BRIDGE_API_KEY
        baseURL: http://127.0.0.1:8319/v1
        models: [...]
```

关键点:`dsh-base` 包含 `hmr`、`web` 等交互式 Web GUI 插件,在
headless JSON-RPC 模式下 `loader.await()` 会永久阻塞,导致
`initialize` 超时。必须禁用它们。

### 验证

```
dsh --profile botmux
→ initialize: {"serverInfo":{"name":"deepseek-harness-sdk-runtime"}}
→ session/prompt: Agent 正常处理消息
→ 飞书 QA bot 端到端测试通过
```

### 与旧版本的兼容性

- bots.json 中已有的 dsh bot 无需修改,`dshProfile` 默认 `'botmux'`
- 升级前需要确保 `~/.dsh/profiles/botmux/cordis.patch.yml` 已配置好
- `cliPathOverride` 不再需要(之前指向 `dsh-jsonrpc-agent` 的已删除)
@nil-err
nil-err force-pushed the feat/dsh-cordis-config-cli-arg branch from 6966d12 to a2923ac Compare September 1, 2026 15:19
- 不再校验 provider 是否在 llm-pi-ai.providers 中(dsh --profile 独立管理插件组合)
- 缺少 agent-default-model 时降级为默认 provider/model 而非报错退出
- cordis.yml 检查改为 profile 目录检查(runner 只创建目录,不生成文件)
@nil-err
nil-err marked this pull request as ready for review September 1, 2026 15:51
dsh-workspace 插件按 session header 里的 canonical cwd 分组,所有 bot
共用同一个 cwd 会导致 session 全挤在未分组下。改为给每个 bot 创建
~/.dsh/workspaces/<botName>/ 作为 initialize cwd,agent 实际工作目录
仍由 spawn({ cwd }) 控制,不受影响。
之前为每个 bot 创建 ~/.dsh/workspaces/<botName>/ 合成目录传入 initialize
cwd,导致每个 bot 在 DSH Web GUI 中出现独立 workspace。这不符合 DSH 的
workspace 语义——在 web 界面从某个 workspace 新建会话时,会直接在该目录下
启动 dsh,而合成目录是空目录,无法正常工作。

改为直接使用 bot 的实际工作目录(--cwd),所有 botmux 会话统一归入
.codebase workspace,与 DSH 原生设计语义一致。
@nil-err nil-err changed the title feat(dsh): 改用标准 DSH profile 机制加载插件组合 feat(dsh): 改用标准 DSH profile 机制,支持 Dashboard 选 profile 与独立 workspace Sep 1, 2026
- mojo: write() 时截取 liveJwt 快照,避免序列化后 buildEnv() 读到被覆盖的凭据
- test(dashboard): mock fetch 新增 /api/dsh/profiles 过滤,避免 fetchDshProfiles() 污染 requests 数组
@deepcoldy

Copy link
Copy Markdown
Owner

自动评审初步意见(复审后汇总)

先说结论:方向认可,dshProfile 全链路串接得很干净,CI 也已全绿;但 profile 的生成侧有几处会让新装用户走不通的问题,建议合入前处理。以下带 🔴 的是我们实测出来的功能性问题,不是风格建议。

🔴 1. 生成出来的 profile 无法被 dsh 启动

在装了真实 @deepseek-ai/[email protected] 的环境实测:

  • dsh 判定 profile 是否存在,看的是 ~/.dsh/profiles/<name>/package.json,不是目录、也不是 cordis.yml。botmux 不属于 shipped template(只有 web / headless)。
  • 干净 HOME 下,runner 的 ensureProfileDir() 只 mkdir,随后 dsh --profile botmux 直接报错:
Error: dsh: profile "botmux" does not exist; create it with 'dsh plugin --profile botmux add <package>'

所以 ensureProfileDir 上方那句注释 —— "dsh CLI auto-creates cordis.yml if missing; we just need the dir" —— 对非 shipped profile 并不成立。

另外 sdk-jsonrpc-server 并不在 dsh-base 里,它是独立 npm 包 @deepseek-ai/dsh-sdk-jsonrpc-server,需要 dsh plugin add 才会装上(package.json 也是这一步建的)。

🔴 2. createDshProfile()(dashboard,目前唯一写 cordis.patch.yml 的地方)有三处对不上

  1. 不写 package.json → 即使 patch 内容正确,dsh 仍判定 profile 不存在。
  2. patch 结构:当前生成的是顶层 insert: 映射,而 dsh 要求顶层是 loader patch 数组,否则报 must be a top-level YAML array of loader patch entries。
  3. name: 字段写的是展示名(如 DSH JSON-RPC Server),而 dsh 需要 npm 包名。这一点可以直接对照本仓库被删掉的 VENDORED_CONFIG —— 同样的 id,原来配的是包名:
id 原 VENDORED_CONFIG 当前 createDshProfile
sdk-jsonrpc-server '@deepseek-ai/dsh-sdk-jsonrpc-server' DSH JSON-RPC Server
agent-core '@deepseek-ai/dsh-agent-spine-demo' Agent Core
sessions '@deepseek-ai/dsh-session-persistence-jsonl' Sessions

按正确的 package.json + patch 格式 + 包名手工配好后,dsh --profile botmux 是能正常回 initialize 的,说明机制本身没问题,只是生成侧的产物还不对。

🔴 3. 模板把插件 config 都写成了 {},运行时绑定丢了

原 VENDORED_CONFIG 里有三处绑定,新模板中都变成了空 config:

sessions.root = !!js process.env.DSH_SESSION_ROOT ?? './.sessions'
bash.cwd      = !!js process.env.DSH_CWD ?? process.cwd()
fs-local.cwd  = !!js process.env.DSH_CWD ?? process.cwd()

而 runner 目前仍在设这两个环境变量(src/dsh-runner.ts:705-706,且 DSH_SESSION_ROOT 是按 sessionId 分目录的)。也就是设了但没人接:即便上面两条修好,会话持久化会落到 dsh 默认的 ./.sessions(即进程 cwd,通常是用户仓库目录)而不是 botmux 分配的目录,bash / fs 的 cwd 同理。这类问题不会报错,只会静默跑偏,建议一并修掉。

🟡 4. mojo 快照修复缺测试守护(非阻断)

turnLiveJwt 快照这个修复逻辑是对的(writeChain 延迟 spawn 期间确实可能被 applyLivePatch() 覆盖)。但 PR 描述提到的 mojo-cross-boundary.test.ts §1 目前守不住它:把快照传递撤掉后该用例仍然全绿;把 mojo-backend.ts 整体还原到 master 也仍然全绿,说明它从未复现过这个竞态。

原因是 §1 在 [A] 落盘后才把 B、C 作为两条独立 IPC 发出,此时 worker 空闲,B 会以 microtask 走完 buildEnv(),C 的 IPC 要等下一个 macrotask,竞态窗口结构上打不开。要复现 A/C/C,需要 B、C 在 turn A 仍在运行(或 restart 期间)入队、同一次 flush 排空。建议补一条这样的用例——这条路径是所有 mojo 会话共用的凭据链路,值得有守卫。

补充:两处建议顺手带上的收尾

  • DSH_CORDIS_CONFIG 移除本身合理(profile 机制取代了它),但 docs/design/2026-08-13-dsh-adapter.md:33 还留着旧描述。
  • RAW_CLI_EXECUTABLES 从 dsh-jsonrpc-agent 改为 dsh 是合理的,建议在升级说明里点一句"需安装 npm 的 @deepseek-ai/dsh,不再是 Python wheel",避免 PATH 里只有旧名的用户升级后找不到命令。

关于 CI 全绿

这次 CI 确实是全绿的(build 门禁通过,20372 passed),但它覆盖不到上面 1–3:test/fixtures/fake-dsh-server.mjs 从不读 config、也不 spawn 真实 dsh,相关断言只检查 profile 目录存在,不检查能否启动。所以这里不是"测试没跑",而是这套 fixture 结构上看不见这类问题。


以上是自动评审的初步意见,可能有我们判断错的地方(尤其如果你本地的 dsh 版本或 profile 约定与我们实测的 0.1.1-rc.2 不同,欢迎直接指出)。最终以维护者审阅为准。

- ensureProfileDir() 不再仅 mkdir,改为写入 package.json(含 dsh-base bundle
  和 sdk-jsonrpc-server 依赖)+ cordis.yml(空数组)+ cordis.patch.yml
  (8 个插件,npm 包名 + !!js 环境绑定)
- createDshProfile() 同上修复,从 YAML 键值格式改为正确的数组
  patch 格式
- 回填 VENDORED_CONFIG 的 !!js 绑定(DSH_SESSION_ROOT / DSH_CWD)
  使 runner 环境变量生效
- 修正插件名从 display name 到 npm 包名(如 agent-core →
  @deepseek-ai/dsh-agent-spine-demo)

Closes PR review item 1-3.
@deepcoldy

Copy link
Copy Markdown
Owner

自动评审初步意见(第三轮,复审后汇总)

先说好消息:上一轮提的四点都改对了,我在干净 HOME 跑 runner、检查实际落盘的产物逐条确认:

  • package.json / cordis.yml / cordis.patch.yml 三个文件都生成了
  • patch 用 yaml.parse() 跑得通,顶层是数组、8 条 entry
  • name: 已改为 npm 包名
  • sessions.root / bash.cwd / fs-local.cwd 三处 !!js 绑定回来了,与原 VENDORED_CONFIG 逐字节一致

另外两处模板(dsh-runner.ts 与 dashboard.ts)交叉比对,8 个 id + 8 个包名完全一致,两条路径不会产出不同的 profile。

不过这一轮又发现两个会让 dsh 路径仍然走不通的问题,都是实测出来的。

🔴 1. patch 条目是裸 - id:,在 cordis loader 里属于「覆盖」而非「插入」,8 条实际全部 no-op

applyEntryPatches(@deepseek-ai/dsh-app-boot/lib/index.js:57)区分两种条目:

写法 含义 目标 entry 不存在时
- insert: [...] 插入新 entry 追加
裸 - id: X(无 insert) 覆盖已存在 entry 的 config warn("patch: entry ... not found") + 跳过

把该 loader 的 applyEntryPatches 原样取出,喂入本 PR 实际生成的 patch:

空 base + 8 条裸 `- id:`   → 加载 entry 数 = 0,8 条 warn 全是 "entry not found"
同样 8 条包进 `- insert:`   → 加载 entry 数 = 8,无 warning

再对照 @deepseek-ai/dsh-base 自己的 cordis.patch.yml,逐个核 id:

patch id dsh-base 中是否存在 净效果
sdk-jsonrpc-server 无 跳过
agent-core 无 跳过
sessions 无 跳过
session-checkpoints 无 跳过
bash 无 跳过
fs-local 无 跳过
llm-deepseek 有(name 也匹配) 覆盖成立,但未带 config,等于空操作
subprocess 有(name 也匹配) 同上

净效果是 0 个插件被加载,其中包括 sdk-jsonrpc-server —— 没有 JSON-RPC server,runner 的握手就没有对端,表现为静默挂起(实测 exit=124,无任何输出)。这类问题不报错、不崩溃,比报错更难排查。

关于修法的一点建议:这里不宜简单把 8 条都改成 - insert:。旧的 VENDORED_CONFIG 是从零构建一份 composition,id 可以自定义;而 profile 是叠在 dsh-base 之上,id 需要与 dsh-base 对齐。具体来说:

  • sessions 这个 id 在 dsh-base 里不存在,承载 JSONL 持久化的行叫 session-persistence-jsonl,且已有自己的 root: !!js dshHomePath('sessions')。所以要让 botmux 的 per-session 目录生效,应当覆盖 session-persistence-jsonl 的 config;insert 一个叫 sessions 的新行会让两个 JSONL 持久化插件同时存在。
  • bash / fs-local 同理:dsh-base 已经有 tool-bash / bash-sandbox / tool-fs / fs-sandbox / fs-observation-policy 一整套,再 insert dsh-bash-local / dsh-fs-local 相当于把旧架构的插件塞进新架构。
  • llm-deepseek / subprocess 已在 dsh-base 中,保持覆盖语义即可(按需补 config)。

也就是说,需要逐个判断「该 insert 还是该覆盖 dsh-base 的对应 id」,sdk-jsonrpc-server 大概是其中唯一真正需要 insert 的。

🔴 2. "^0.1.1" 解析不到任何版本,npm install 必然 ETARGET

@deepseek-ai/dsh-sdk-jsonrpc-server 至今只发布过 prerelease,没有 stable:

["0.0.1-rc.5","0.1.0-rc.2",…,"0.1.1-rc.1","0.1.1-rc.2","0.1.2-alpha.2","0.1.2-alpha.3"]

npm/semver 默认排除 prerelease(除非 range 自身带 prerelease 标识),所以 ^0.1.1 解析结果是 null(* 同样是 null)。用本 PR 实际生成的 package.json 跑:

npm error code ETARGET
npm error notarget No matching version found for @deepseek-ai/dsh-sdk-jsonrpc-server@^0.1.1.

同一份文件只把 range 改成 ^0.1.1-rc.1 → added 29 packages in 2s。@deepseek-ai/dsh-base 也是全 prerelease,建议一并确认。

❓ 3. profile 依赖由谁安装,需要定一下

实测 dsh 不会自行安装 profile 依赖:profile 有 package.json 但无 node_modules 时,dsh --profile botmux 报 Cannot find package '@deepseek-ai/dsh-sdk-jsonrpc-server'。而 botmux 目前没有任何 npm install / dsh plugin add 调用,干净 HOME 跑完 profile 目录里也没有 node_modules。所以需要在三者中选一个:botmux 负责安装、要求用户手动安装、或依赖缺失时 fail loud 给出可操作提示。

🟡 4. mojo 快照修复仍缺测试守护(非阻断,沿用上轮意见)

turnLiveJwt 快照逻辑是对的,但 mojo-cross-boundary.test.ts §1 守不住它(撤掉修复后该用例仍全绿,还原到 master 也仍全绿)。原因是 §1 在 [A] 落盘后才发 B、C,此时 worker 空闲,B 走 microtask 就读完 buildEnv(),竞态窗口打不开。建议补一条「B、C 在 turn A 运行期间入队」的用例。

关于 CI

CI 目前是绿的(build 门禁通过),但它覆盖不到上面 1–3:test/fixtures/fake-dsh-server.mjs 从不读 config、不 spawn 真实 dsh、也不安装 profile 依赖,相关断言只检查文件/目录存在。所以这里不是"测试没跑",而是这套 fixture 结构上看不见这类问题。


以上是自动评审的初步意见。若你本地的 dsh 版本或 profile 约定与我们实测的 0.1.1-rc.2 / [email protected] 不同,欢迎直接指出。最终以维护者审阅为准。

@deepcoldy

Copy link
Copy Markdown
Owner

补充一个上一条没点明、但直接影响改法的细节 —— 关于 sessions 这一行:

它是 id 对不上,不是包对不上。 dsh-base 里那行的引用包与本 PR patch sessions 行的引用包是同一个 @deepseek-ai/dsh-session-persistence-jsonl,只是 dsh-base 把 id 命名为 session-persistence-jsonl:

# @deepseek-ai/dsh-base 的 cordis.patch.yml(节选)
- id: session-persistence-jsonl
  name: '@deepseek-ai/dsh-session-persistence-jsonl'
  config:
    root: !!js dshHomePath('sessions')

所以让 botmux 的 per-session 目录生效,改法是覆盖 dsh-base 那一行的 config(此时裸 - id: 的覆盖语义正是想要的):

- id: session-persistence-jsonl
  config:
    root: !!js process.env.DSH_SESSION_ROOT ?? './.sessions'

而不是 insert 一个叫 sessions 的新行 —— 那会让两个 JSONL 持久化插件同时挂载,各自写自己的 root。

同样的「先查 dsh-base 有没有等价行」也适用于 bash / fs-local:dsh-base 已提供 tool-bash / bash-sandbox / tool-fs / fs-sandbox / fs-observation-policy,直接 insert dsh-bash-local / dsh-fs-local 会与之并存。agent-core(dsh-agent-spine-demo)与 dsh-base 的 agent(dsh-agent)之间怎么取舍,属于设计选择,交由你判断。

一句提醒:llm-deepseek / subprocess 这两行 id 在 dsh-base 中已存在且 name 一致,覆盖语义可以正常生效 —— 但 applyEntryPatches 在 name 与目标行不一致时会 warn 并跳过整条 patch,所以覆盖已有行时 name 要么省略、要么与 dsh-base 完全一致。

之前的 commit 2c57be1 在 ensureProfileDir/createDshProfile 中手写了 8 个插件到
cordis.patch.yml,导致两个问题:

1. 6/8 个插件(llm-deepseek, sessions, session-checkpoints, subprocess, bash,
   fs-local)已在 dsh-base 中提供,重复声明导致 dsh 加载失败(duplicate id)
2. agent-spine-demo 的旧版本(0.0.1-rc.1)缺少 dsh-environment 依赖导致 crash

修复方案:
- cordis.patch.yml 最小化:仅 disable Web GUI 插件 + insert sdk-jsonrpc-server
- package.json 新增 dsh-sdk-protocol 依赖(sdk-jsonrpc-server 的 peer dep)
- 社区插件(traex-bridge, openviking, genui 等)通过 dsh plugin add 安装,
  具有 dsh.bundle 的包会自动注入其 cordis.patch.yml,无需手写

验证:dsh-runner 22 项测试全部通过,dsh --profile botmux 启动正常
…ation

Two issues caught by review:
1. ^0.1.1 doesn't match npm prereleases (dsh-sdk-* are 0.1.1-rc.x only).
   Changed to ^0.1.1-rc.1 so pnpm can resolve the packages.
2. Writing skeleton files (package.json/cordis.yml/cordis.patch.yml) was
   not enough — dsh needs node_modules to exist. Now call
   'dsh plugin --profile <name> add @deepseek-ai/dsh-sdk-jsonrpc-server@next'
   after skeleton creation to install deps. Only on new profiles; existing
   ones are left untouched.
…ild-process rule

dashboard.ts must not import node:child_process directly — every host child
must go through managed-spawn.ts so it runs on redactChildEnv (no Feishu H5
credentials leak). Extracted installDshProfileDeps() into managed-spawn.ts
and call it from createDshProfile().
@deepcoldy

Copy link
Copy Markdown
Owner

自动评审初步意见(第四轮,复审后汇总)

这一轮的三处改动都验证通过,而且 profile 的组合方式比我们上一轮建议的更好。剩下一个新问题,涉及失败路径。

✅ patch 语义已正确(零 warning)

上一轮的问题是 8 条 patch 全为裸 - id:,在 cordis loader 里属于「覆盖」语义,命中不到 dsh-base 的 id 时会 warn 并跳过,净效果 0 个插件加载。现在改成了「只 insert dsh-base 真正缺的那一个,其余交给 dsh-base」,并额外 disable 掉在 headless 下会阻塞 loader.await() 的 Web GUI 行。

用真实 dsh-app-boot 的 applyEntryPatches 先把 dsh-base 展开成基线,再叠本 PR 生成的 patch:

dsh-base entries        : 78
叠加本 PR 的 patch 之后 : 79   (delta +1)
warnings                : 无
  hmr / web / web-search-deepseek / tool-web  → disabled=true(四行都命中 dsh-base 实有的 id)
  sdk-jsonrpc-server                          → 已插入

复审侧用 dsh --dump-config 从 dsh 自己的视角看也是 79 条、sdk-jsonrpc-server 在位;端到端用本 PR 生成的 profile 加装依赖后 dsh --profile botmux 能正常回 initialize(serverInfo.name = deepseek-harness-sdk-runtime),stderr 无 warning。

这个方向比逐条改 - insert: 更好:sessions / bash / fs-local 那批 id 错配与「旧插件塞进新架构」的隐患一并消失了。

✅ 版本 range 与依赖安装

  • range 改为 ^0.1.1-rc.1,并显式声明了 dsh-sdk-protocol peer dep。顺带印证了这个包的 dist-tag 情况:latest → 0.0.1-rc.5、next → 0.1.1-rc.2,即 latest 指向的是最老的版本,所以 @next 与所 pin 的范围是一致的。
  • dashboard 侧的安装走 managed-spawn 并使用 redactChildEnv,符合该模块的既有约定;对应的结构守卫(dashboard.ts 不得直接 import node:child_process)确认有效——把 import 加回去该用例会转红。

🔴 新问题:dsh plugin add 失败会让 profile 永久卡死,且完全静默

两处安装(src/dsh-runner.ts 的 ensureProfileDir、managed-spawn.ts 的 installDshProfileDeps)都存在同一组合:

  1. isNew 以 package.json 是否存在判定,而 package.json 在安装之前就已写入;
  2. spawnSync 的返回值未被检查(status / error 都没读),且 stdio: 'pipe'。

用一个在 plugin add 时 exit 1 的假 dsh(模拟离线 / registry 不可达 / dsh 版本过老)实测:

RUN 1(安装失败)      :package.json / cordis.yml / cordis.patch.yml 均已写入,node_modules 不存在
RUN 2(同一个 HOME)   :isNew = false → 整段安装被跳过 → node_modules 仍然不存在
随后 dsh --profile botmux → Cannot find package '@deepseek-ai/dsh-sdk-jsonrpc-server'

也就是说首次安装失败之后不会再重试,用户不手动删掉 profile 目录就无法恢复;而由于返回值被丢弃 + stdio: 'pipe',日志里没有任何线索。dashboard 侧同理,POST /api/dsh/profiles 仍会返回 {ok: true}。

建议两处都做:

  • 可自愈:把 isNew 的判据从「package.json 不存在」改为「node_modules 不存在」,这样上次失败后下次会自动重试;
  • 可诊断:检查 status !== 0 || error,runner 侧记录日志(或直接失败退出),dashboard 侧让 POST 返回非 200 并带上 stderr。

单做前者会把真实故障静默自愈掉,单做后者每次都需人工介入,两者互补。

🟡 非阻断

  • 两处安装都是新增代码路径,目前 test/ 下没有任何引用。test/dashboard-managed-spawn.test.ts 已有「每个 host child 都必须来自该模块、且跑在 redacted env 上」的现成模式,照着加一条成本很低。
  • mojo turnLiveJwt 快照修复仍缺测试守护(前几轮已说明原因:mojo-cross-boundary.test.ts §1 的 B/C 是在 turn A 结束后才发出,竞态窗口打不开)。
  • docs/design/2026-08-13-dsh-adapter.md:33 仍留有 DSH_CORDIS_CONFIG 的旧描述;dsh-jsonrpc-agent → dsh 的改名建议在升级说明里提一句。

关于 CI

本轮 CI 四条腿全部通过(含此前红的 bun-test)。需要说明的是它覆盖不到上面的 🔴:fixture 不 spawn 真实 dsh、也不执行 profile 的依赖安装,因此失败路径不在断言范围内。


以上为自动评审的初步意见。若你本地的 dsh 版本或 profile 约定与我们实测的 0.1.1-rc.2 / [email protected] 不同,欢迎直接指出。最终以维护者审阅为准。

nil-err and others added 2 commits September 2, 2026 17:36
…e errors

Keyed the install guard on node_modules existence instead of package.json
— if dsh plugin add fails (offline, registry down, etc.) the skeleton files
are already on disk but node_modules is not, so the next run will retry.
Previously a failed install would permanently wedge the profile because
isNew was keyed on package.json, which was written before the install.

Also check spawnSync status/error and surface failures:
- dashboard.ts → throw via installDshProfileDeps (HTTP caller sees the error)
- dsh-runner.ts → warn to stderr (runner is a subprocess; dsh startup will
  fail with a clear 'Cannot find package' error, more actionable than a
  silent crash)
设计文档里 `DSH_CORDIS_CONFIG` 与 wheel 默认 cordis.yml 的描述已随本次
改动失效,替换为标准 profile 机制的实际约定;用户文档补上两处容易踩的坑。

- `docs/design/2026-08-13-dsh-adapter.md`:改写 runtime 启动一节——dsh 以
  profile 的 `package.json` 判定存在性(非目录、非 cordis.yml),非 shipped
  profile 不会被自动创建,依赖需 `dsh plugin add` 安装(dsh 自身不触发安装);
  补充 `- insert:` 与裸 `- id:` 的语义差异(后者目标 id 缺失时静默跳过),
  以及 `@deepseek-ai/dsh-*` 全 prerelease 导致 `^0.1.1` 解析不到版本的坑。
  argv 列表里过期的 `--dsh-config` 改为 `--dsh-profile`。
- `docs-site/docs/{zh,en}/adapters.md`:说明 profile 首次使用无需手工创建、
  botmux 只在文件缺失时落盘骨架且不覆盖已有内容;`cliId: dsh` 的前置条件
  补上升级提示——需要 npm 包 `@deepseek-ai/dsh` 提供的 `dsh` 命令,PATH 上
  只有旧的 `dsh-jsonrpc-agent` 会报找不到命令。

Co-Authored-By: Claude Code <[email protected]>

@deepcoldy deepcoldy left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

双审通过(Claude 首审 + pi 复审,五轮迭代)。

五轮下来的阻断项已全部解决,逐条都有实测依据:

  • profile 可启动:dsh 以 profile 的 package.json 判定存在性,非 shipped profile 需自行落盘骨架 + dsh plugin add 装依赖——两条路径都已实现。
  • patch 语义正确:用真实 dsh-app-boot 的 applyEntryPatches 展开 dsh-base(78 条)再叠本 PR 的 patch → 79 条、零 warning,四个 disable 行全部命中 dsh-base 实有 id,sdk-jsonrpc-server 正确插入;复审侧用 dsh --dump-config 交叉同得 79 条,并端到端跑通 initialize。
  • 依赖范围可解析:^0.1.1-rc.1(该包只发 prerelease,^0.1.1 会 ETARGET)。
  • 失败可自愈可诊断:安装重试判据改为 node_modules 是否存在,失败时错误上抛/落 stderr。用「装依赖时 exit 1 的假 dsh」复验:首次失败会报错,再次运行会重试(此前是永久跳过且静默)。

其中 profile 组合方式比评审建议的更好——只 insert dsh-base 真正缺少的一个插件,其余能力全部沿用 dsh-base,并 disable 掉 headless 下会阻塞启动的 Web GUI 行,从而整类消除了 id 错配问题。

验证:bun run build 通过;dsh / cli-adapters / dashboard / managed-spawn 相关 496 条测试全绿;本地 rebase 树与 merge-tree 真合并树 23 文件逐字节一致。

已知遗留(均不阻断,建议后续跟进):

  1. 两处依赖安装路径与新增的失败处理暂无测试覆盖,test/dashboard-managed-spawn.test.ts 已有可直接套用的模式。
  2. mojo turnLiveJwt 快照修复逻辑正确,但 mojo-cross-boundary.test.ts §1 守不住它(该用例在 turn A 结束后才发出 B/C,竞态窗口打不开),建议单独补一条「B、C 在 turn A 运行期间入队」的用例。
  3. 该链路尚无真实 IM 端到端验证(协议层已验通);当前配置中没有使用该 CLI 的 Bot,故无存量影响。

@deepcoldy
deepcoldy merged commit b11d224 into deepcoldy:master Sep 2, 2026
4 checks passed
@nil-err
nil-err deleted the feat/dsh-cordis-config-cli-arg branch September 2, 2026 10:17
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

🚀 Released in v3.18.13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants