dsh-subagent-cwd:给 DSH 子智能体调用增加 per-call cwd

前言

在 DSH 的插件工作方式下,subagent / subagent_fork 这类委托工具已经支持按次覆盖 model、provider、persona 和 toolFilter。若还需要某一次子智能体调用在指定工作目录里运行,dsh-subagent-cwd 提供了对应能力:它在 dsh-subagent-tools 的能力基础上加入 per-call cwd,并附带两个必要的 in-process provider patches。

这是什么

dsh-subagent-cwd 是 lynx-gt 维护的 DSH 插件,许可证为 MIT。它继续暴露 subagent / subagent_fork 工具面,支持 per-call model / provider / persona / toolFilter overrides、@preset: references、provider/model composite ids,并新增 per-call cwd 参数。

核心功能

  • 提供 subagent / subagent_fork 的委托工具面。
  • 支持按次覆盖:model、provider、persona、toolFilter
  • 支持 @preset: 引用和 provider/model 组合 id。
  • 新增 per-call cwd 参数,用于指定某一次子智能体调用的工作目录。
  • cwd 需要两个 provider patches;插件随附这两个 in-process provider patches,使按次 cwd 可被传递。

安装与启用

先安装插件:

dsh plugin --profile web add dsh-subagent-cwd

再应用 cwd 所需的两个 provider patches。Windows 上使用:

powershell -ExecutionPolicy Bypass -File patches\install.ps1

POSIX 环境使用:

./patches/install.sh

如果运行在 Web 会话中,还需要 preset adapter。Windows:

powershell -ExecutionPolicy Bypass -File install-preset.ps1

POSIX:

./install-preset.sh

完成后再重启 Web 进程,并开启新会话:

dsh --profile web

新会话生效后,Web 会话即可使用。headless 和其他 non-web profiles 则不需要 preset adapter。

这里需要注意:dsh-subagent-toolsdsh-subagent-cwd 二选一,不要同时安装。两者暴露相同的 subagent / subagent_fork 工具名,冲突安装会争抢工具名。

典型用法

下面是一个示例:

subagent(description="Summarize this file", prompt="...", cwd="D:\\projects\\scratch\\notes")

这里的 cwd 是 per-call 参数,表示这一次 subagent 调用使用指定目录。其他已核实的调用能力仍可使用,例如 model、provider、persona、toolFilter@preset: 引用和 provider/model 组合 id。

适用场景与注意

适合这类情况:

  • 需要让某次子智能体调用在指定目录中运行。
  • 希望在 DSH 的 subagent / subagent_fork 调用中保留 model / provider / persona / toolFilter 覆盖。
  • 使用 Web profile,并愿意在启用后新建会话。

安装前:

  • 插件以当前 dsh 进程权限运行,安装前应检查源码与 MIT 许可证。
  • 只安装 dsh-subagent-cwddsh-subagent-tools 中的一个,不同时安装两者。

升级与补丁:

  • dsh 升级会重写 node_modules,并清除两个 provider patches。升级后需要重新运行 installer,例如:
powershell -ExecutionPolicy Bypass -File patches\install.ps1
  • POSIX 环境可在升级后重新运行对应 installer。

Preset 与 persona:

  • Web 会话需要 preset adapter;presets 在会话创建时读取,因此更改 preset 后要开启新会话。
  • headless 和其他 non-web profiles 不需要 preset adapter。
  • preset 相关补丁目前只在 Windows 的 install.ps1 中落地;POSIX install.sh 的 preset hunks 后续补齐。在 Linux 上,preset 参数可被接受,但在补丁落地前不会 recompose。
  • 在 router-style presets 下,即使已有 patch v2,per-call persona 仍可能不进入 system prompt。可选做法是使用 non-router-style preset、通过 message layer 注入角色定义,或接受 preset 自带的 dynamic persona 生效。

结尾

dsh-subagent-cwd 的作用是把 dsh-subagent-tools 的委托能力和真正可用的 per-call cwd 组合起来,并附带必要的 provider patches。GitHub 地址:https://github.com/lynx-gt/dsh-subagent-cwd。社区目录可按插件名 dsh-subagent-cwd 检索。

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye