dsh-plugin-agents-loader:本地智能体配置的自动发现与加载

前言

在 DSH(DeepSeek Harness)插件化架构中,扩展智能体能力通常涉及手动配置 MCP 服务器或编写斜杠命令。dsh-plugin-agents-loader 插件通过自动扫描 ~/.agents 目录,将本地配置直接挂载到运行时环境,支持热重载,减少了手动编排的重复工作。

核心功能

该插件提供以下能力:

  1. MCP 服务器加载:读取 ~/.agents/mcp.json,自动创建 ctx.plugin(dsh-mcp-client, ...),支持 http 与 stdio 两种传输协议。
  2. 斜杠命令注册:扫描 ~/.agents/commands/*.md,将文件名注册为命令,正文内容在触发时注入 Agent。
  3. Agent 指令迁移:首次运行时,将 ~/.agents/AGENTS.md 链接到 dsh 的原生指令位置(~/.dsh/AGENTS.md),后续源文件变更自动同步。
  4. 热重载:监听配置文件变更,通过 500ms 防抖机制自动重建动态资源,无需重启进程。

安装与前置要求

使用该插件前,请确保环境满足以下条件:

  • dsh 版本:0.1.7-rc.2(对应 cordis 4.0.4)。peer 依赖已精确锁定,不匹配会直接安装失败。
  • pnpm:插件安装依赖 pnpm 环境。

安装命令如下:

dsh plugin --profile web add https://github.com/CrazyPigHead/dsh-plugin-agents-loader.git

如果需要修改源码,建议克隆仓库后使用本地路径安装:

git clone https://github.com/CrazyPigHead/dsh-plugin-agents-loader.git
dsh plugin --profile web add /path/to/dsh-plugin-agents-loader

配置说明

插件主要依赖 ~/.agents 目录下的三个文件/目录。

MCP 服务器配置

创建 ~/.agents/mcp.json。配置项支持 enabled 字段控制加载,timeoutMs 设置超时。

{
  "mcpServers": {
    "context-7": {
      "type": "http",
      "url": "https://mcp.context7.com/mcp",
      "headers": { "Authorization": "Bearer {CONTEXT7_API_KEY}" }
    },
    "local-tool": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "some-mcp-server"]
    }
  }
}

斜杠命令配置

在 ~/.agents/commands/ 下创建 .md 文件。文件名即命令名,frontmatter 中的 description 为命令描述。

---
description: 创建 conventional git commit
---

## Goal
Create conventional git commits...

## Workflow
1. `git diff --staged`
2. `git commit -m "feat: add new feature"`

验证与调试

安装完成后,可以通过 CLI 验证插件是否已挂载:

dsh --profile <name> --dump-config | grep -A1 agents-loader

在 Agent 会话中输入 / 查看命令列表,或尝试执行注册的斜杠命令。修改配置文件后,日志应出现 reload scheduled 并自动生效。

注意事项

  1. 版本兼容性:必须使用 dsh 0.1.7-rc.2 及以上版本,且需要 pnpm 环境。
  2. 源码修改:通过 pnpm link 安装后,若修改源码,需重启 dsh 进程才能生效(Node.js 模块缓存原因)。
  3. 本地安装:通过本地路径安装时,必须保留克隆目录,后续通过 git pull 更新。
  4. Profile 管理:不要手动修改 profile 目录下的 package.json 或直接运行 pnpm,这会绕过版本检查和写锁。
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

小夜