前言¶
在 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-tools 和 dsh-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-cwd或dsh-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中落地;POSIXinstall.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 檢索。