Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

DeepSeek Harness bundles and profiles: two manifests

DeepSeek Harness bundles and profiles: two manifests

In earlier chapters we used --patch overlay to load local plugins; this chapter starts packaging them into installable bundles.

In this chapter we will clarify the two most basic concepts: bundle and profile, and their respective manifests.


Two concepts, two kinds of manifest

The installation mechanism is built on two concepts, both described by a package.json.

They carry different kinds of manifest under the dsh key and answer different questions.

bundle and profile relationship diagram

A bundle is an npm package that comes with a configuration layer.

Its manifest declares dsh.bundle, answering "what does this package contribute": a patch file that inserts or overrides plugin entries.

A profile is located under $DSH_HOME/profiles/ a directory describing a launchable composition.

Its manifest declares dsh.profile, answering "which bundles make up this configuration and in what order".

bundle is what you write and distribute;profile is what users use to dsh --profile launch.

Nothing is both at once.

Concept manifest key Question Answered Who writes / who uses
bundle dsh.bundle what the package contributes (a patch file) written by plugin authors, distributed with the package
profile dsh.profile which bundles make up this configuration and in what order modified by dsh plugin created and maintained automatically, launched by users

A profile lives outside the installation directory; the path template is $DSH_HOME/profiles/。


Hands-on: creating the hello-plugin bundle

Following the official tutorial, first create the package directory.

Example

mkdir -p hello-plugin

The bundle directory structure is as follows, with three files in total.

Example

hello-plugin/

├── package.json       # 声明 dsh.bundle

├── cordis.patch.yml   # profile 列出该 bundle 时应用的配置层

└── index.js           # patch 行引用的插件模块

Create hello-plugin/package.json to declare the bundle manifest.

Example

{

  "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" } }

}

The meanings of the fields in package.json are as follows.

Field Description
name The package name; Node module resolution uses it to find installed code
version Version number
type "module" indicates the use of the ESM module format
main Entry file
files the list of files to include when publishing
dsh.bundle.patch bundle manifest: declares the path of the contributed patch file

Create hello-plugin/index.js and write the plugin entry point.

Example

// File path: hello-plugin/index.js

export

const

name

=

'hello-plugin'

 

// Plugin name, used for logs and diagnostics

export

function

apply

(

)

{

  console.

log

(

'[hello-plugin] plugin loaded!'

)

 

// Print a log line when loaded

}

Create hello-plugin/cordis.patch.yml.

Example

File path: hello-plugin/cordis.patch.yml

Like the --patch overlay we have been using, this patch is a YAML array of patch entries

Difference: plugin entries reference by package name rather than relative source path, so Node module resolution can find the installed code

:

    - id

:

hello

      name

:

dsh-hello-plugin

This patch is fully isomorphic with --patch overlay.

The key difference is in the name field: here it is the package name dsh-hello-plugin, not a relative source path.

After installation pnpm links the package into node_modules, so Node's module resolution can find the installed code by package name.

No dsh.bundle The declared package can still be installed, but only as a regular dependency.

At this point dsh plugin A warning will be printed, and no layer is activated.

Use this package format if a library is meant to be imported by plugin packages rather than enabled by users.


profile manifest: never needs to be written by hand

The profile directory contains two files.

The first is package.json, containing the profile's out-of-tree plugin dependencies (managed by pnpm), plus dsh.profile the manifest and its ordered list of bundles.

The second is cordis.patch.yml, the user's own patch layer, applied after each bundle layer.

The profile manifest never needs to be written by hand.

dsh plugin It is responsible for creating and maintaining it; the next chapter on installing plugins will show its real result.


Advanced: letting a surface bundle hold its own command line

A bundle that defines a runnable application can mount a regular provider plugin to hold its own command line.

This provider plugin exports inject = ['cmdlineArgs'], calls its own commander program parseCmdline, and then provides the application's own services in the program's own action.

Example

Mount the provider plugin: id is arbitrary, name points to the startup module inside the bundle package

:

hello-startup

  name

:

'dsh-hello-plugin/startup'

Lines configured by these parameters inject the provider service and read it in their own !!js option, while writing the deployment value alongside as a fallback.

Example

Example: the port number comes from the provider service, falling back to 8080 if unavailable

:

my-app

  name

:

'@example/my-app'

  inject

:

[

myAppStartup

]

  config

:

    port

:

!!js

ctx.myAppStartup.port ??

8080

The launcher passes the same immutable arguments after its own flags to every plugin, so adding application-specific flags requires no change to the launcher, and multiple plugins can parse the same snapshot.

When encountering --help, the provider does not publish the service, so these lines are not activated.

The Loader mounts the composition only once, waits for the regular injection of each line, then evaluates that line's ... based on its already-injected context !!js configuration.


Summary and self-test

bundle declaration dsh.bundle answers "what it contributes", profile declaration dsh.profile answers "which bundles it is composed of"; both are carried by one package.json but with different manifests.

Self-test questions:

  1. Which key does a bundle's manifest declare, and what question does it answer?
  2. In which directory does a profile reside, and what question does its manifest answer?
  3. Why does hello-plugin's cordis.patch.yml use the package name instead of a relative source path?