DSH Atlas Harness & Super-Agent
CLI & Web UI dsh plugin 管理 Creator 模式开发

dsh 安装上手与自定义插件实战

dsh 基于 Node.js / TypeScript 生态构建,既能直接在终端当 CLI 用,也能一行命令拉起本地 Web 控制台进行可视化调试。

1. 环境准备与启动方式

确保本地具备现代 Node.js 运行时并配置好模型 API Key 后,即可快速体验 CLI 与本地 Web 界面:

# 1. 通过 npx 直接拉起本地 Web UI 控制台
npx @deepseek-ai/dsh web

# 2. 查看帮助与当前可用运行模式
dsh --help

# 3. 插件管理与版本兼容性检查
dsh plugin list
dsh plugin search memory
版本兼容校验:engines.dsh

社区第三方插件在 package.json 中通常会声明 engines.dsh 字段。安装插件时,dsh plugin 会自动校验当前 Harness 版本与插件 API 契约是否匹配,避免接口不兼容导致运行时崩溃。

2. 编写一个 Cordis 风格工具插件(概念示例)

得益于模块化注入机制,给 Agent 增加一个只读检索或内部系统查询工具,不需要动任何核心代码,只需声明一个带上下文注入的插件模块:

import { Context, Schema } from 'cordis'

export const name = 'project-health-tool'

export interface Config {
  timeoutMs: number
}

export const Config: Schema<Config> = Schema.object({
  timeoutMs: Schema.number().default(5000).description('检查请求超时时间'),
})

export function apply(ctx: Context, config: Config) {
  // 通过 ctx 向工具注册表挂载新能力;插件卸载时自动注销
  ctx.tools.register({
    name: 'check_service_health',
    description: '只读检测指定本地服务端口的 /health 接口返回状态',
    parameters: {
      type: 'object',
      properties: {
        url: { type: 'string', description: '本地健康检查地址' }
      },
      required: ['url']
    },
    async execute({ url }) {
      const ctrl = new AbortController()
      const timer = setTimeout(() => ctrl.abort(), config.timeoutMs)
      try {
        const res = await fetch(url, { signal: ctrl.signal })
        return { status: res.status, ok: res.ok }
      } finally {
        clearTimeout(timer)
      }
    }
  })
}

3. 用 Creator 模式在内存中热调试