快速上手:编写你的第一个 dsh 插件
August 14, 2026 · View on GitHub
前置准备
git clone https://github.com/deepseek-ai/deepseek-harness.git
cd deepseek-harness
pnpm install
pnpm run build
创建一个工具插件(5 分钟)
1. 创建插件文件
mkdir -p my-plugin/src
创建 my-plugin/src/index.ts:
import type { Context } from '@deepseek-ai/cordis'
import { defineTool } from '@deepseek-ai/dsh-tools'
export const name = 'hello-tool'
export const inject = ['tools']
export function apply(ctx: Context) {
ctx.tools.register(defineTool({
name: 'greet',
description: 'Greet someone by name.',
parameters: {
name: { type: 'string', required: true, description: 'The name to greet' },
},
output: {
schema: { type: 'string' },
render: (_args, value) => [{ type: 'text', text: value }],
},
async execute(args) {
return `Hello, ${args.name}!`
},
}))
}
2. 创建 cordis.yml
创建 my-plugin/cordis.yml:
- !!js ./src/index.ts
config: {}
3. 启动并测试
pnpm dsh web --patch ./my-plugin/cordis.yml
打开 http://127.0.0.1:3080,对 agent 说:
Use the greet tool to greet Ada.
Agent 会调用 greet 工具并返回 Hello, Ada!。