# Architecture `dsh-local-plugins` keeps plugins you have edited as ordinary git repos and puts them in front of dsh **only as exact commits**, switched on atomically. Three rules never change: 1. **dsh only runs a commit.** Never a working tree, never a half-merged tree. 2. **Build aside, switch last.** A deployment is built in its own folder; only a finished one is made live, by one atomic rename. 3. **Nothing is destroyed.** Originals are backed up, deleted repos go to a trash folder, user work is stashed before any revert. ``` you / agent Local Plugins (this plugin) dsh ─────────── ─────────────────────────── ─── edit + commit ──► ~/.dsh/local-plugins// (git repo) ├─ branch upstream = pristine original (npm release / git tag) └─ branch local = your edits Apply ─────────────► 1. journal begins (.txn/) 2. snapshot: detached worktree of ONE commit .deployed/@/ 3. install deps (scripts off unless allowed) + build 4. verify: deps present, entry files exist, every JS file parses 5. mark finished (.lpm-ready) 6. swap .deployed/ -> @ (atomic rename) 7. link dsh to the stable link ─────────────────────► profile dependency "link:" core package: /node_modules/@deepseek-ai/x or the package folder is moved to .backup/ and replaced by a symlink ───► symlink to the stable link 8. registry saved, journal closed, restart requested ``` ## Where things live (`$DSH_HOME/local-plugins`, default `~/.dsh/local-plugins`) | Path | What | Safe to delete? | |---|---|---| | `registry.json` (`.v1.bak`, `.corrupt-*`) | the manager's only state file, `0600` | no — but `Repair installation` can rebuild it from the repos | | `/` (`@scope__pkg/`) | the plugin's git repo (`upstream`, `local`) | **no** — this is your work | | `.deployed/@/` | immutable snapshots (git worktrees); `.deployed/` is the stable link | yes (rebuilt on demand); the live one and the rollback target are protected | | `.work//` | trial-merge worktree during an update/conflict | only via Abort | | `.backup/@/` | the original of a built-in dsh package | **no** while the package is overridden | | `.nested/` | private `node_modules` of a core package | no while overridden | | `.txn/` | journal of operations in flight | no — recovery reads it | | `.trash/-