Skip to content
MyDSHMy DSH Field Notes
中文
Independently maintained; not affiliated with DeepSeek. No association with mydsh.dev or other MyDSH sites.

Home/Developers & plugin dev/Dev setup & scaffolding

A minimal plugin from scratch: three files until apply() runs

Wanting to write a plugin and finding no clear answer on how many files are needed or which field is mandatory.

VerifiedVersion and environmentChecked 2026-11-14
Host
0.1.2-alpha.5 source checkout
Method
isolated DSH_HOME plus file: install
Checked
2026-11-14

Copyable command

dsh plugin --profile web add "file:C:/path/to/minplug"

Three files suffice. What follows was measured working and can be copied.

1. package.json

{
  "name": "dsh-plugin-hello",
  "version": "0.0.1",
  "type": "module",
  "main": "lib/index.js",
  "dsh": { "bundle": { "patch": "./cordis.patch.yml" } }
}

2. cordis.patch.yml

# insert one entry into the profile root
- insert:
    - id: hello-world
      name: 'dsh-plugin-hello'

3. lib/index.js

export const name = 'dsh-plugin-hello'

export function apply(ctx) {
  // your logic
}

Install into an isolated environment

dsh plugin --profile web add "file:C:/path/to/minplug"

Measured at 3.1 seconds. package.json gains "dsh-plugin-hello": "file:C:/..." under dependencies, and the same name is appended to bundles.

Two verifications, both required

  1. Verify composition: --dump-config should show a # == dsh-plugin-hello section and a - id: hello-world entry.
  2. Verify real loading: have apply write a file (appendFileSync) and check whether it appears after boot.
These must stay separate. I did only the first at first and assumed success on seeing the dump-config entry — but web does not log at info level, so whether apply ran was invisible. Only an observable side effect produced evidence. An entry in dump-config is not apply running.

Do not conflate id and name

In the patch, id: hello-world is your own targeting label; name: dsh-plugin-hello is the module. To patch that entry later you use the id. The ecosystem routinely mixes the two up.

What counts as working

Check every line. All of them pass or the job is not done.

  • dump-config shows a section headed by your package name
  • The side-effect file written by apply actually appeared
  • id and name are written separately, not conflated

Where it fails

Symptom, cause, what to do — written in the order it actually happens.

SymptomCauseWhat to do
No new entry in dump-configdsh.bundle.patch missing or mispointedConfirm package.json has dsh.bundle.patch pointing at a real file
Entry exists but apply never runsResolution failed or name is wrongSet name to the package name string, not a relative path

Sources

Verified means measured here. Compiled means every line carries a source.