EXAMPLES

August 19, 2026 · View on GitHub

每种形态给一个「最小但真实」的样板,直接改名字/路径就能用。完整命令见 REFERENCE.md


1. Bundle 组合包

hello-plugin/
├── package.json
├── cordis.patch.yml
└── index.js

package.json

{
  "name": "dsh-hello-plugin",
  "version": "0.1.0",
  "type": "module",
  "main": "index.js",
  "files": ["index.js", "cordis.patch.yml"],
  "dsh": { "bundle": { "patch": "./cordis.patch.yml" } }
}

index.js

export const name = 'hello-plugin'
export function apply() {
  console.log('[hello-plugin] plugin loaded!')
}

cordis.patch.yml

- insert:
    - id: hello
      name: dsh-hello-plugin

安装(推荐 tarball):

cd hello-plugin && pnpm pack                 # -> dsh-hello-plugin-0.1.0.tgz
dsh plugin --profile demo add ./dsh-hello-plugin-0.1.0.tgz
dsh --profile demo --dump-config | grep -A2 hello
dsh --profile demo

2. 本地插件(Patch)

my-plugin.ts

import type { Context } from '@deepseek-ai/cordis'
export const name = 'my-plugin'
export function apply(ctx: Context) {
  ctx.effect(() => {
    const t = setInterval(() => console.log('heartbeat'), 5000)
    return () => clearInterval(t)
  })
}

cordis.ymlname 用绝对路径):

- insert:
    - id: my-plugin
      name: '/abs/path/to/my-plugin.ts'
pnpm dsh web --patch ./cordis.yml

3. Agent Preset

~/.dsh/.agent-presets/reviewer/agent.cordis.yml(示意,真实预设复制自带 preset 后改):

# 每个 preset 一个目录;服务行用 isolate 承载 preset 私有能力
plugins:
  - id: my-review-tool
    name: '@acme/dsh-review-tool'
    realm: isolate

在 Web UI 里「复制一份预设」创建,或让 agent 经 ctx.agentPresets.copy(...) 创建;选择该 preset 的会话即获得对应工具集/人设/提示词。


4. Skill

my-skill/SKILL.md

SKILL.md

---
name: my-skill
description: 给 SQL 查询做性能审查并给出改写建议。Use when 用户要求审查/优化 SQL 查询性能时使用。
---

# My Skill

## Quick start
...

安装:

git clone --depth 1 https://github.com/you/my-skill.git ~/.agents/skills/my-skill
# 或
npx skills add you/my-skill -g -y

5. 动态 Cordis 插件

cordis_inspect_list 查能力,再 cordis_define 提交 plain JS(Host 半):

return {
  name: 'runtime-hello',
  apply(ctx) {
    const logger = ctx.get('logger')
    logger?.info('runtime hello plugin active')
    ctx.effect(() => () => logger?.info('runtime hello disposed'))
  },
}

然后 cordis_run 激活。进程重启即失效;改代码走 cordis_define(existing)+ cordis_run(update)。