dsh-subagent-mode

September 12, 2026 · View on GitHub

DeepSeek Harness 插件:内建多智能体模式——专家子代理角色库 + 确定性步骤拆解器。

License: MIT

✨ 这是什么

主模型无需真正的子代理调度,也能跑一套“多智能体工作流”:

  1. role_list 看清有哪些专家角色;
  2. plan_steps 把目标拆成有归属、有依赖顺序的步骤;
  3. role_prompt 把每一步渲染成该角色的完整 system prompt,主模型自己逐轮扮演。

三个工具全部是纯逻辑:不调用 LLM、不派生真实 agent、不联网、不读写文件; isConcurrencySafe() 恒为 true,同输入必同输出,可安全并发、可回放。

📦 安装

npx -y @deepseek-ai/dsh plugin --profile web add @qingshanjiluo/dsh-subagent-mode

安装后插件会随 bundle 的 cordis.patch.yml 注入 profile,注册下面三个工具。

🛠️ 工具

工具名参数返回说明
role_listroles[] { id, title, when, strengths[] }count列出 8 个内建专家角色及其适用场景,是 role_prompt / plan_steps 的合法 id 来源。
role_promptid(必填)、task(必填)、context(可选)idtitlesystemPrompterror渲染该角色的完整人设指令,并把任务与上下文嵌入。角色不存在或 task 为空 → systemPrompt: ""error 给出原因。
plan_stepsgoal(必填)、constraints(可选字符串数组)goalsourcesteps[] { index, title, ownerRole, dependsOn[] }counttruncatednotes[]扫描目标里的阶段线索,输出有序、带依赖的步骤计划;无线索时退化为通用链路。

内建角色(8 个)

id标题何时交给它
code-reviewerCode Reviewer改动完成,需要一次怀疑式审查
test-writerTest Author需要回归网兜住行为
refactorerRefactorer能跑但难改:重复、耦合、巨型函数
doc-writerDocumentation WriterREADME / API 文档 / 用户指南
security-auditorSecurity Auditor涉及不可信输入、鉴权、密钥、依赖
api-designerAPI Designer需要定义别人要依赖的边界与契约
debuggerDebugger出错了,原因未知
summarizerSummarizer长线程 / 大 diff / 计划需要浓缩摘要

plan_steps 的阶段线索

按固定顺序扫描 11 个阶段,命中即成一步;每步的 ownerRole 来自上表:

阶段承担角色英文线索(示例)中文线索
designapi-designerdesign / architect / plan / spec / scope / research设计、方案、规划、选型
apiapi-designerapi / endpoint / interface / contract / route / sdk接口、契约
implementrefactorerimplement / build / write / develop / create / integrate实现、开发、编写、接入
refactorrefactorerrefactor / simplify / extract / dedupe / rename重构、抽取、拆分
debugdebuggerdebug / fix / bug / crash / reproduce / root cause调试、排查、修复、定位
testtest-writertest / unit / coverage / verify / benchmark / e2e测试、验证、覆盖
reviewcode-reviewerreview / critique / approve / lint / sign off评审、审查、复核
securitysecurity-auditorsecurity / auth / secret / injection / supply chain安全、鉴权、越权
docsdoc-writerdocument / readme / changelog / guide / example文档、说明、注释
releasecode-reviewerdeploy / release / ship / ci / docker / rollback部署、发布、上线
summarizesummarizersummarize / recap / report / overview / wrap up总结、汇报、交付说明
  • 每步 title = 阶段动作 + 命中该阶段线索的那个子句(按 , ; : 、。then/并且/然后 切分),例如 "… implement the writer, debug the crash, add tests"Test: add tests;取不到子句时退化为整个目标的前 48 字符摘要。
  • dependsOn1 起算的步骤下标;为空表示可与同伴并行。
  • 一个线索都没命中时,返回通用链路 design → implement → test → review,且 source"fallback"
  • 步骤超过 maxSteps 时按尾部截断,truncated: true,并在 notes 里列出被丢掉的步骤。

⚙️ 配置

配置项类型默认值实际作用
maxStepsnumber8plan_steps 返回步骤的硬上限(越界自动夹到 1..11)。
defaultLanguagestring'en'写进每个角色 prompt 的“Response language”一节;en/zh/ja 等常见码会展开成 English/Chinese/Japanese,其它值原样使用。
# cordis.patch.yml(随包发布,安装时自动注入)
- insert:
    - id: subagent-mode
      name: '@qingshanjiluo/dsh-subagent-mode'
      config:
        maxSteps: 8
        defaultLanguage: en

🚀 典型用法

role_list()
plan_steps("为导出功能设计 API、实现、补测试、评审并写文档", ["不新增依赖"])
role_prompt("api-designer", "Step 1 — Define the contract: 为导出功能设计 API、实现、补测试…", "<上一步结论>")

🧪 本地开发

npm install --no-audit --no-fund
npx tsc --noEmit      # 类型检查
npm run build         # 产出 lib/index.js + lib/index.d.ts
npx vitest run        # 行为测试
node scripts/load-smoke.mjs   # 用构建产物做加载冒烟

📄 License

MIT