A DSH session is rooted by default in a single working directory, which serves both as the sandbox boundary and the base for all relative paths. This default is reasonable in most cases, but it can become awkward for certain layouts: for example, the PC and mobile versions of the same product, iOS and HarmonyOS apps that must stay in sync, or a shared library and its consumers. These directories are often sibling directories, and keeping the same file consistent across them can lead to absolute paths, duplicated calls, or silent drift.
The dsh-workspace-merge plugin introduces a named workspace group to DSH sessions. It is an ordered collection of local project root directories and provides a set of ws_* tools. These tools treat a relative path as a single operation across all roots in the group, rather than an operation against a single root, thereby avoiding the problems above.
Core Features¶
The plugin provides the following tools and mechanisms:
ws_groups: Lists the defined groups, the root directory IDs in each group, and which group the current session is in.ws_group_set/ws_group_remove: Maintain the group registry to add or remove workspace groups (this does not modify project files).ws_ls: Lists the same relative directory under each root in the group (for example, to locate components with the same name).ws_read: Reads the content at the same relative path under each root in the group.ws_diff: Compares copies of the same file under each root before editing (using the first root as the baseline).ws_edit: Applies one literal replacement (old_string -> new_string) in each root in the group. If the replacement content occurs multiple times in the file,replace_allmust be used.ws_write: Writes identical full content to each root in the group (for creating a new shared file or enforcing synchronization).- Sandbox behavior: The tools first resolve the session’s
sandboxPolicyand do not relax permission restrictions. They supportdanger-full-access,workspace-write, andread-onlymodes.
Installation and Enablement¶
Install it using the official plugin management command:
dsh plugin add dsh-workspace-merge
After installation, you can manually add it to the configuration by editing the package under the $DSH_HOME/profiles/web directory and listing dsh-workspace-merge in dsh.profile.bundles.
Typical Usage¶
1. Configure a Workspace Group¶
Define a group using ws_group_set. id is the identifier used by subsequent tool calls, and path accepts an absolute path or a path starting with ~.
// ws_group_set {group:"ecam", description:"PC + mobile", roots:[
// {id:"pc", path:"~/Desktop/JLXY/ecam-ui"},
// {id:"mobile", path:"~/Desktop/JLXY/ecam-mobile-ui"}
// ]}
This command generates a configuration file at $DSH_HOME/workspace-groups.json. The file is plain JSON and can be edited manually.
2. List and View¶
List all groups and their status in the current session:
ws_groups
List the same relative directory under all roots in the group (for example, src/components). The tool automatically skips .git and node_modules directories:
ws_ls src/components
Read the content of a specific file in each root:
ws_read src/components/AmountInput.vue
3. Compare and Edit¶
Before editing, use ws_diff to compare differences (line alignment is limited to 4000 lines per side):
ws_diff src/components/AmountInput.vue
Perform a literal replacement in each root:
ws_edit src/components/AmountInput.vue old_string new_string
To preview changes without actually writing them, use the dry_run flag:
ws_edit src/components/AmountInput.vue old_string new_string --dry_run
If you want to operate on only a specific subset of roots in the group (for example, PC only), specify roots:
ws_edit src/components/AmountInput.vue old_string new_string --roots ["pc"]
4. Debug¶
If the plugin is added to the configuration but the tools do not appear, enable debug logging:
WSM_DEBUG=1
Use Cases and Cautions¶
- Not a Monorepo: A workspace group is not a monorepo. It changes what the
ws_*tools target, but it does not change the current working directory of the DSH session. The built-inread,edit,write, andbashtools still operate only against the session root. - Writing Mechanism: All write operations go through the Harness filesystem service (
ctx.fs). Before writing, anfs/observedevent is emitted, and thereplaceIfVersionpolicy is followed. If that service is not mounted, the tools fall back tonode:fs, and the result is explicitly labeledvia: node:fs (fs service failed: ...). - Permission Restrictions: In
read-onlysandbox mode, any write operation (includingws_group_setandws_group_remove) is rejected. - Testing Requirements: The project includes unit tests (
npm test), but the tests depend on a locally installed DSH and its dependencies (@deepseek-ai/dsh-tools, etc.) and cannot be run in a purely remote environment.
Summary¶
dsh-workspace-merge provides a standardized set of tools for working with multiple local project root directories within a single DSH session. By maintaining a group registry, it makes cross-directory file reads, diff comparisons, and batch literal replacements simple and auditable.
- Plugin Directory: https://www.skillhub.cn/plugins/LoserForLoser/dsh-workspace-merge
- Source Code: https://github.com/LoserForLoser/dsh-workspace-merge