Preface¶
DSH (DeepSeek Harness) follows the “everything is a plugin” philosophy. Plugin developers typically need to restart the desktop process to observe the effects of their changes during debugging and acceptance testing. Frequent restarts are both slow and prone to missed changes, especially when validating the plugin contract layer (guard chains, tool registration and execution), where repeated cold starts drag down the iteration pace.
To validate plugins without modifying the DSH desktop process, an environment is needed that can mount the target plugin within a real cordis boot path and run acceptance scenarios. dsh-plugin-lab is designed precisely for this purpose.
What This Is¶
dsh-plugin-lab is a lab environment for DSH plugin developers. It allows you to mount a target plugin in a child process running a real cordis boot + real ToolsService/SystemPrompt, execute acceptance scenarios, and receive per-item PASS/FAIL results with a verdict. It uses the same boot function as the DSH desktop process (boot() from @deepseek-ai/dsh-app-boot)—it is not a mock.
It ships with a minimal example: example/fixture-plugin + example/scenarios/fixture.mjs. You can run a one-click self-test via npm run selftest, or perform offline unit tests with npm test.
Core Features¶
- Zero-restart validation: Mount the plugin and run scenarios in a child process. Code changes take effect immediately without restarting the DSH desktop process.
- Real environment: Uses real cordis Context, ToolsService, and SystemPrompt, consistent with the DSH desktop process boot path.
- In-session tool: After mounting, you can use the
lab_runtool within a session to configure the target directory, scenario paths, services, and settings. - Standalone CLI: When not in a session, you can directly invoke
dsh-plugin-labornode bin/dsh-plugin-lab.mjswith arguments to run scenarios. - Scenario contract: Write acceptance steps using official interfaces such as
ctx.tools.checkGuards,defs, anddef.execute. - Security boundary: The child process environment uses a whitelist and does not inherit host tokens/API keys. Timeout and process tree cleanup are handled uniformly by the runner.
Installation & Activation¶
Install directly from GitHub (gets the latest commit on main):
dsh plugin add github:Oseas031/dsh-plugin-lab
Or install from npm:
npm i dsh-plugin-lab
After installation, you need to add the package to the profile’s dsh.profile.bundles, or add "dsh-plugin-lab": "file:<path-to-this-package>" to the profile’s package.json and similarly include it in dsh.profile.bundles. Once mounted, all sessions in that profile can use the lab_run tool (intended for dev profiles; use caution in production profiles, see dsh.patch.yml).
Typical Usage¶
Calling lab_run In-Session¶
{
"target": "E:/x/dsh-foo",
"config": { "anyConfig": true },
"scenarios": ["E:/x/dsh-foo/scenarios/contract.mjs"],
"services": ["@deepseek-ai/dsh-skill", { "name": "@deepseek-ai/dsh-tools", "config": { "strict": true } }],
"serviceConfigs": { "@deepseek-ai/dsh-skill": { "skillDirs": [] } },
"dshHome": "E:/tmp/isolated-dsh-home",
"timeoutMs": 120000,
"keep": false
}
Parameter descriptions:
services(optional): Additional DSH official base services to mount. Supports string package names or{ name, config }objects. Only@deepseek-ai/dsh-[a-z0-9-]+is allowed (defaults already includedsh-system-promptanddsh-tools; duplicates are automatically deduplicated).serviceConfigs(optional): Pass cordis configuration objects keyed by official service package name. Keys are likewise restricted to@deepseek-ai/dsh-*.dshHome(optional): Create an isolatedDSH_HOME/HOME/USERPROFILEdirectory for the child process to avoid polluting the host desktop configuration.- Return:
{ pass, total, passed, failed[], dshVersion?, durationMs, timedOut?, aborted?, stdoutTail[], stderrTail[], jobDir?, cleanupFailed? }.
Return field descriptions:
timedOut: trueindicates the child process was killed due to timeout;aborted: trueindicates it was terminated early viaAbortSignaland the process tree was cleaned up (total/passedwill recover completed steps from stdout as best as possible).
Standalone CLI Invocation¶
node bin/dsh-plugin-lab.mjs \
--target E:/x/dsh-foo \
--scenario E:/x/dsh-foo/scenarios/contract.mjs \
--service @deepseek-ai/dsh-skill \
--service-config '{"@deepseek-ai/dsh-skill":{"skillDirs":[]}}' \
--dsh-home E:/tmp/isolated-dsh-home \
--config '{"anyConfig":true}'
The underlying runner can also be invoked directly with a prepared job.json:
node runner/child.mjs job.json
Example job.json:
{
"dshRoot": "/path/to/dsh-root",
"ymlPath": "/path/to/dsh.profile.yml",
"jobDir": "/tmp/job-uuid",
"scenarioPaths": ["/path/to/scenario.mjs"],
"targetEntry": "/path/to/target/plugin",
"targetConfig": { "anyConfig": true }
}
Scenario Contract Example¶
export default async ({ ctx, defs, step, jobDir, targetEntry, targetConfig }) => {
const deny = ctx.tools.checkGuards({ name: 'your.tool', args: { ... } }); // Official guard chain
step('Assertion name', !!deny, deny?.reason);
const def = defs.find(d => d.name === 'your.tool'); // Official definitions()
const out = await def.execute({ ... }, { name: 'your.tool' }); // Real execution
step('Real execution', out.ok === true);
};
How It Works¶
- A real cordis Context is instantiated in a child process via
boot(), using the same boot function as the DSH profile. - The target plugin is mounted by absolute path—code changes take effect immediately, and the next
lab_runpicks up the new code. - Official
@deepseek-ai/*services are resolved from the local DSH installation viabareModuleBaseUrl(the Loader’s official built-in channel).
Security Boundary¶
By design, this package executes local code—it boots a real cordis instance in a child process and mounts the plugin you specify. The single code-exec point is the one async spawn in lib/index.js:
- Arguments passed as an argv array with
shell: false. - Only runs the built-in
runner/child.mjs+ the freshly writtenjob.json. - Timeout 1–600000ms (default 120s; 0 is treated as default).
- 4 MiB output buffer.
- Isolated mkdtemp working directory.
- stdin is not inherited.
- Child process environment uses a whitelist (does not inherit host tokens/API keys).
On timeout, the entire process tree is killed. On normal exit, the runner reclaims the grandchild processes it spawned after writing the verdict, preventing orphan processes from lingering on the machine. Temporary directory cleanup failures trigger backoff retries; if still failing, the error is logged to boot.log and cleanupFailed: true is returned. No network access, no telemetry, zero npm dependencies.
Compatibility & License Boundaries¶
- Code license: MIT.
- Zero npm dependencies: No
@deepseek-aiprivate packages are declared or distributed; at runtime, they are resolved from the user’s own DSH installation. boot()andbareModuleBaseUrlare DSH internal interfaces with no stability guarantee. Tested against: DSH 0.2.2-rc.3 (selftest fully green). After upgrading DSH, run selftest first; if the resolver cannot find dsh-app-boot, it will fail loudly and list the paths it attempted.- DSH tool output schema does not support type arrays (
['string','null']will be rejected byassertSupportedJsonSchema, causing plugin activation failure)—nullable fields should not be placed in the schema.
Limitations¶
- The lab validates the plugin contract layer (guard chains / tool registration / execution); the preset composition layer (persona, tool surface, skill roots) still requires a one-time DSH restart for final confirmation.
- In CI environments without a DSH installation, only pure function tests can run; lab-type tests should be marked
requires-DSH(self-hosted runner or local execution).
Applicable Scenarios & Cautions¶
Suitable for developers who need to quickly validate plugin behavior in a real DSH environment. This plugin runs with the current dsh process privileges. Review the source code and license before installation. Note: It is designed for development profiles. Use caution in production profiles to avoid introducing unnecessary dependencies.
Brief Summary¶
dsh-plugin-lab provides DSH plugin developers with a zero-restart lab environment that mounts plugins in a real cordis child process and runs acceptance scenarios, supporting both in-session tool invocation and standalone CLI. It ensures security through a whitelisted environment and unified process tree cleanup, making it ideal for quickly validating the plugin contract layer in local development or self-hosted CI.
- Directory page: https://www.skillhub.cn/plugins/Oseas031/dsh-plugin-lab
- GitHub: https://github.com/Oseas031/dsh-plugin-lab