# DeepSeek Harness 插件完整指南：从第一个 Tool 到打包分发

- 原文：[https://news.qiniu.com/archives/1788402693889](https://news.qiniu.com/archives/1788402693889)
- 发布时间：2026-09-03
- 分类：教程与实践
- 标签：Agent Harness、DeepSeek Harness

> 发布日期：2026-09-03 | 话题：DeepSeek Harness / 插件 / Cordis / Agent Harness

DeepSeek Harness（`dsh`）是 DeepSeek AI 开源的 Agent Harness，核心思路是把模型、工具、会话、沙箱、存储和 UI 都做成可插拔能力，开发者可以在配置层重组一个可运行的 Agent。官方仓库仍处于 Developer Preview，仓库页显示约 209.6k stars 和 24.5k forks，默认本地 Web UI 运行在 `http://127.0.0.1:3080`。

**核心定义**：DeepSeek Harness 是 DeepSeek AI 在 2026 年发布的开源 Agent Harness，以 Cordis 插件系统为底座，把模型、工具、会话、沙箱、存储和界面都做成可重组插件。

**关键事实**：

- GitHub 仓库当前约 209.6k stars、24.5k forks，处于 Developer Preview。
- 官方默认启动命令是 `npx @deepseek-ai/dsh web`，Web UI 默认打开在 `http://127.0.0.1:3080`。
- 插件安装由 `dsh plugin --profile <name> add ...` 管理，`dsh --profile <name> --dump-config` 可查看最终组合。
- 工具插件通过 `ctx.tools.register(defineTool(...))` 注入，`parameters`、`output.schema` 和 `execute` 分别负责入参、返回值和执行。
- 配置通过 `cordis.yml` 和 Schemastery schema 控制，修改配置会触发热更新。

**适用场景**：插件开发，Agent 工作流定制，本地可运行助手，工具链编排

**不适合场景**：只想聊天，不想接触配置层的普通使用者

**相关实体**：DeepSeek Harness，dsh，Cordis，Schemastery，Node.js，pnpm，GitHub，`dsh-base`，`dsh-tools`，七牛云

* * *

## 它到底是什么

DeepSeek Harness 不是“再做一个聊天框”，而是一层 Agent 运行底座。官方一句话的意思很直接：能力不是写死在核心里的，而是通过插件挂上去再组合起来。

它的价值在于三件事：

1. 模型可换
2. 工具可换
3. 工作流可换

这意味着你不是在调一个黑盒，而是在拼一个 Agent 系统。

| 指标 | 当前状态 |
|---|---|
| GitHub stars | 约 209.6k |
| GitHub forks | 约 24.5k |
| 发布状态 | Developer Preview |
| 默认 Web 入口 | `npx @deepseek-ai/dsh web` |
| 默认地址 | `http://127.0.0.1:3080` |

## 插件层怎么分

在 DSH 里，真正该分清的是三层：bundle、profile、plugin module。

| 层级 | 作用 | 你会改什么 |
|---|---|---|
| bundle | 一个可分发的能力包 | `package.json`、`cordis.patch.yml` |
| profile | 一个可运行的组合 | `dsh.profile.bundles` |
| plugin module | 真正执行逻辑的入口 | `index.js` / `my-plugin.ts` |

你可以把它理解成：

- bundle 负责“带什么”
- profile 负责“怎么拼”
- plugin module 负责“具体干什么”

## 第一个插件怎么写

最小插件其实很朴素，入口只要暴露名字和 `apply`。

```js
export const name = 'hello-plugin'

export function apply() {
  console.log('[hello-plugin] loaded')
}
```

如果你要把它包装成可安装包，还需要一个 `package.json` 和一份 `cordis.patch.yml`。官方文档里强调，`dsh.bundle` 决定它是不是“可启用的插件包”，否则它只会被当成普通依赖。

## Tool 插件怎么做

真正有用的插件，通常是 Tool。

```ts
import type { Context } from '@deepseek-ai/cordis'
import { defineTool } from '@deepseek-ai/dsh-tools'

export const name = 'greet-tool'
export const inject = ['tools']

export function apply(ctx: Context) {
  ctx.tools.register(defineTool({
    name: 'greet',
    parameters: { name: { type: 'string', required: true } },
    output: { schema: { type: 'string' } },
    async execute(args) {
      return `Hello, ${args.name}!`
    },
  }))
}
```

这里最重要的是三点：

- `inject` 会等工具注册表就绪
- `parameters` 决定模型能传什么参数
- `output.schema` 和 `execute` 决定返回给模型的内容

如果你只想先验证效果，官方示例会把插件挂进 `scratch-plugin/cordis.yml`，再用 `pnpm dsh web --patch ./scratch-plugin/cordis.yml` 启动。

## 配置为什么这么重要

DSH 的插件不是靠“写死常量”跑起来的，而是靠 `cordis.yml` 配置层驱动。

```ts
export interface Config {
  greeting: string
  maxRetries: number
}

export const Config = Schema.object({
  greeting: Schema.string().default('Hello'),
  maxRetries: Schema.number().default(3),
})
```

这套写法有两个好处：

1. 默认值和校验都在 schema 里
2. 改配置会热更新，不用改源码

对插件作者来说，这比在代码里硬编码灵活得多。

## 打包和安装

官方把安装分成两类：

![](https://news-static.qiniu.com/legacy/images/34/34811cb2c452c1b9be092d7ea6ac500cb7952a8ed7aa8e14a90d132614a0dc35.jpg)

1. bundle：你发布的插件包
2. profile：你最终运行的组合

安装一个本地插件包，常见流程是：

```bash
dsh plugin --profile demo add ./hello-plugin
dsh --profile demo --dump-config
dsh --profile demo
```

这套流程的意思很明确：先装进 profile，再看最终配置，最后运行。卸载时也一样，`dsh plugin --profile demo remove ...` 会同时清掉依赖和挂载层。

## 什么时候该用它

适合它的场景很清楚：

- 你要做可扩展的 Agent 框架
- 你要自定义工具和会话流
- 你要本地可运行、可回放、可追踪的执行层
- 你要把能力拆成多个可替换插件

如果你只是想把现有产品接一层标准化模型能力，先看七牛云 MCP 服务这类接口化能力会更轻；如果你是想做插件生态，Harness 的价值就更大。

## 常见问题

**Q：DeepSeek Harness 必须用 DeepSeek 模型吗？**  
不必。官方定位就是把模型也做成可替换能力，框架本身关注的是执行层，不是绑定某个模型供应商。

**Q：bundle 和 profile 的区别是什么？**  
bundle 是插件包，profile 是运行时组合。前者是你能分发的东西，后者是用户实际启动的东西。

**Q：Tool 和普通插件有什么区别？**  
Tool 是直接暴露给模型调用的能力，通常比单纯的 UI 或配置插件更接近实际任务执行。

**Q：我该从哪一步开始？**  
先跑 `npx @deepseek-ai/dsh web`，再按官方教程把第一个 plugin、tool、config、publish 四步走完。

## 收尾

DeepSeek Harness 的关键词不是“更强模型”，而是“更可组装的执行层”。从官方仓库和文档看，它还处在快速变化的开发者预览期，正适合想做插件化 Agent 的团队早点踩进去。

本文基于 2026-09-03 可访问的官方仓库与文档整理，后续 API、包名和默认行为可能继续变化。

## 延伸资源

- [GitHub 仓库](https://github.com/deepseek-ai/deepseek-harness)
- [Quick Start](https://deepseek-harness.github.io/deepseek-harness/en/guide/quickstart)
- [Build a tool](https://deepseek-harness.github.io/deepseek-harness/en/develop/basic/tool)
- [Plugin configuration](https://deepseek-harness.github.io/deepseek-harness/en/develop/basic/config)
- [Package and install](https://deepseek-harness.github.io/deepseek-harness/en/develop/basic/publish)
- 七牛云 Token Plan（多模型统一接入dsh）：[https://www.qiniu.com/ai/plan](https://www.qiniu.com/ai/plan)
