How DeepSeek Harness Assembles Its Plugin Tree: Bundles, Profiles, and Whole-Row Patches
Agent frameworks that compose behavior from plugins need a predictable override system. dsh's whole-row replacement and empty-root-on-boot discipline prevent the configuration drift and merge ambiguity that plague layered config systems in production.
Three concepts govern dsh's plugin assembly: Bundles package plugins for distribution, Profiles declare which bundles to stack and hold user overrides, and Patches replace an entry's entire config by id. The startup chain parses CLI arguments, composes four patch layers in a strict bottom-up order, rewrites the root config to an empty list on every boot to prevent state accumulation, and deep-clones patch objects to avoid reference aliasing during hot reloads.
Patch semantics are deliberately whole-row, not deep-merge. Changing one field requires restating the full config, a tradeoff that makes the final configuration tree completely predictable without inferring merge behavior. The `--dump-config` command prints the composed tree for debugging.
Three default bundles ship with the distribution: dsh-base provides model adapters, tools, persistence, sandboxing, and platform-gated shell stacks; dsh-web-app adds a web host, API gateway, and HMR; dsh-headless adds a one-shot runner for CI. Custom profiles follow a six-step workflow of copying a template, editing the bundle list, writing patches, and installing out-of-tree plugins.
Choosing whole-row replacement over deep merge is a readability-over-writability tradeoff: the final config is self-contained and requires no mental merge resolution, but users must restate complete configs for any change.
Rewriting the root config to an empty list on every boot is a defensive measure against Cordis's persistence write-back, not a cosmetic reset. Skipping it would cause bundle insertions to compound across restarts.
The structuredClone calls in both boot and live-reload paths address a subtle aliasing bug where Include inserts rows by reference, and subsequent id-targeted patches mutate the original bundle objects in place.
Platform gating inside dsh-base means the same profile declaration produces different plugin trees on Windows versus POSIX, which shifts compatibility responsibility from the user to the bundle author.