dsh-plugin-tool-management 0.22.3 → 0.22.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/CHANGELOG.md +1415 -1363
  2. package/README.md +177 -176
  3. package/README_EN.md +177 -176
  4. package/docs/ARCHITECTURE.md +134 -0
  5. package/docs/COMPATIBILITY.md +107 -0
  6. package/docs/TROUBLESHOOTING.md +285 -0
  7. package/docs/UPDATE.md +50 -48
  8. package/lib/client.js +4693 -4626
  9. package/lib/compat/host-contracts.js +4 -2
  10. package/lib/confirm-gate.js +49 -18
  11. package/lib/context-inject-surface.js +45 -13
  12. package/lib/context-inject.js +1 -1
  13. package/lib/imports/unzip.js +144 -26
  14. package/lib/index.js +245 -93
  15. package/lib/legacy-tool-names.js +46 -0
  16. package/lib/mcp/manager.js +12 -1
  17. package/lib/mcp/secret-guard.js +27 -0
  18. package/lib/mcp/state-section.js +17 -8
  19. package/lib/mcp/tool-visibility.js +86 -10
  20. package/lib/memories/archive.js +44 -0
  21. package/lib/memories/index-io.js +4 -1
  22. package/lib/memories/service.js +94 -3
  23. package/lib/op-registry.js +5 -1
  24. package/lib/ops/scene-capture.js +72 -0
  25. package/lib/prompts/service.js +27 -0
  26. package/lib/scope/scope-overrides.js +9 -2
  27. package/lib/skills/catalog.js +18 -9
  28. package/lib/skills/dir-watch.js +49 -22
  29. package/lib/skills/service.js +2 -2
  30. package/lib/subagents/catalog.js +13 -7
  31. package/lib/subagents/run-provider.js +41 -10
  32. package/lib/subagents/tools.js +63 -7
  33. package/lib/tool-table-switch.js +41 -4
  34. package/lib/tools/control.js +158 -0
  35. package/lib/tools/deps.js +88 -0
  36. package/lib/tools/mcp.js +35 -10
  37. package/lib/tools/memory.js +9 -5
  38. package/lib/tools/prompt.js +7 -8
  39. package/lib/tools/remove.js +84 -65
  40. package/lib/tools/scene.js +179 -76
  41. package/lib/tools/skills.js +13 -8
  42. package/lib/tools/subagent.js +19 -10
  43. package/lib/tools/table.js +92 -57
  44. package/lib/trash-id.js +3 -2
  45. package/package.json +156 -152
package/README_EN.md CHANGED
@@ -1,176 +1,177 @@
1
- <p align="center">
2
- <img src="docs/images/banner-en.png" alt="Tool Management — one click swaps the entire environment" width="100%">
3
- </p>
4
-
5
- <p align="center">
6
- <a href="https://www.npmjs.com/package/dsh-plugin-tool-management"><img src="https://img.shields.io/npm/v/dsh-plugin-tool-management?logo=npm&color=cb3837&style=flat-square" alt="npm"></a>
7
- <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue?style=flat-square" alt="MIT"></a>
8
- <img src="https://img.shields.io/badge/DSH-0.2.2-4f7cf7?style=flat-square" alt="DSH 0.2.2">
9
- <a href="https://github.com/ouli-1242/dsh-plugin-tool-management"><img src="https://img.shields.io/badge/GitHub-ouli--1242-181717?logo=github&style=flat-square" alt="GitHub"></a>
10
- </p>
11
-
12
- <p align="center">
13
- <a href="https://dsh.market/"><img src="https://raw.githubusercontent.com/2BingLing/dsh-market/master/assets/readme/badge-listed-en.svg" height="20" alt="DSH Market"></a>
14
- <a href="https://awesome-dsh-plugin.com"><img src="https://img.shields.io/badge/awesome--dsh--plugin-listed-3fb950?style=flat-square" alt="awesome-dsh-plugin"></a>
15
- <a href="https://dshfind.com/en/plugins/ouli-1242/dsh-plugin-tool-management"><img src="https://dshfind.com/api/badge/ouli-1242/dsh-plugin-tool-management?lang=en" alt="dshfind"></a>
16
- <a href="https://github.com/0xsline/awesome-deepseek-harness"><img src="https://img.shields.io/badge/0xsline-listed-3fb950?style=flat-square" alt="0xsline"></a>
17
- </p>
18
-
19
- <p align="center">
20
- <a href="README.md">简体中文</a> · <b>English</b> · <a href="CHANGELOG.md">Changelog</a> · <a href="docs/UPDATE.md">Release overview</a>
21
- </p>
22
-
23
- MCP servers, skills, subagents, prompts, memories and archived sessions for DeepSeek Harness — all in one panel. Bundle them into a **scene**, swap the whole environment with one click, and roll back to the pre-entry snapshot when you leave.
24
-
25
- ```sh
26
- dsh plugin --profile web add dsh-plugin-tool-management@latest # web
27
- dsh plugin --profile desktop add dsh-plugin-tool-management@latest # desktop
28
- ```
29
-
30
- Hard-refresh the browser after installing for web (Cmd/Ctrl+Shift+R), or restart the desktop app — then open **Settings → Tools Management**. For desktop, open the app once and quit it completely before running the command. An older version usually means registry lag or pnpm's `minimumReleaseAge` — install an exact version (`@0.X.X`) instead.
31
-
32
- ---
33
-
34
- ## Highlights
35
-
36
- <table>
37
- <tr>
38
- <td width="33%" valign="top"><b>One-click scene switch</b><br>Each scene stores a full profile: MCP, skills, subagents, memories, quick prompts, a prompt preset and a model-tool table. Enter it and the whole stack switches; leave it and the pre-entry snapshot comes back.</td>
39
- <td width="33%" valign="top"><b>Control from the chat</b><br>Type <code>/</code> for a “Tools” section: enter or leave a scene, toggle any of the six domains. The menu stays open and leaves no command text in the composer.</td>
40
- <td width="34%" valign="top"><b>Three scopes</b><br>All global / per workspace / per conversation. By default every conversation has its own settings — two conversations in the same project can run two different environments at once.</td>
41
- </tr>
42
- <tr>
43
- <td valign="top"><b>The agent can drive it</b><br>26 model tools across six domains: list, read, create, update, delete, toggle, enter scenes, apply prompts, run personas. Writes ask for confirmation (except in a full-permission session, where the card is skipped and only a log line is written); disabled tools are not in the schema at all.</td>
44
- <td valign="top"><b>The Host page is a control center</b><br>Version and capability checks, access token, scope mode, per-domain injection switches, the model-tool table and the sidebar entry — all on one page.</td>
45
- <td valign="top"><b>One panel, eight tabs</b><br>Scenes / MCP / Skills / Subagents / Prompts / Memories / Sessions / Host — no more hunting through six different settings pages.</td>
46
- </tr>
47
- </table>
48
-
49
- ## Demo
50
-
51
- <video controls width="100%" src="https://github.com/user-attachments/assets/ff3111c3-4228-45b7-9e28-b85dc60fb6b3"></video>
52
-
53
- Player refuses to start (browsers with a stricter CSP sometimes block the inline embed)? [Watch the same file directly](https://github.com/user-attachments/assets/ff3111c3-4228-45b7-9e28-b85dc60fb6b3).
54
-
55
- Every interface shown is a real screenshot of the running product.
56
-
57
- Music: Kevin MacLeod「Limit 70」, [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/).
58
-
59
- ## Screenshots
60
-
61
- | | |
62
- |:----------------------------------------------------------------------------:|:------------------------------------------------------------------------------:|
63
- | <img src="docs/images/1-EN.png" alt="Scenes" width="100%"><br>**Scenes** | <img src="docs/images/2-EN.png" alt="MCP" width="100%"><br>**MCP** |
64
- | <img src="docs/images/3-EN.png" alt="Skills" width="100%"><br>**Skills** | <img src="docs/images/4-EN.png" alt="Subagents" width="100%"><br>**Subagents** |
65
- | <img src="docs/images/5-EN.png" alt="Prompts" width="100%"><br>**Prompts** | <img src="docs/images/6-EN.png" alt="Memories" width="100%"><br>**Memories** |
66
- | <img src="docs/images/7-EN.png" alt="Sessions" width="100%"><br>**Sessions** | <img src="docs/images/8-EN.png" alt="Host" width="100%"><br>**Host** |
67
-
68
- ## Three scopes
69
-
70
- Every conversation gets its own settings by default. Switch once on the **Host page → Scope**, and the whole panel plus every model tool follows that layer:
71
-
72
- | | All global | Per workspace | Per conversation (default) |
73
- |:------------------------ |:---------------------------------------------- |:------------------------------------------ |:------------------------------------------ |
74
- | **Who shares one set** | Every conversation | Conversations in the same workspace | Each conversation separately |
75
- | **Best for** | One person, one machine, consistent everywhere | One project, one environment | Parallel tasks in one project |
76
- | **Lost when switching?** | — | Nothing is deleted; switch back to restore | Nothing is deleted; switch back to restore |
77
-
78
- The selector at the top of the panel jumps to a specific conversation or workspace and shows its own copy; when that layer is locked, the unlock button sits on the same row. Within a layer, every switch resolves top-down: **this layer's edit > entered scene > creation snapshot > global**.
79
-
80
- Scenes work in all three scopes. Under per-conversation, conversation A can sit in “Coding” while B stays in “Writing”, each with its own MCP servers, skills and personas.
81
-
82
- ## What each tab does
83
-
84
- <table>
85
- <tr><th width="15%" align="left">Tab</th><th align="left">What it does</th></tr>
86
- <tr><td><b>Scenes</b></td><td>Save the whole environment as a profile; enter and leave with one click; lock it against edits; bind a prompt preset and a model-tool table; deleting it sends its memories to the recycle bin too.</td></tr>
87
- <tr><td><b>MCP</b></td><td>Add, edit and remove servers; toggle individual tools; write a note the model sees; inspect the last-known tool list while a server is stopped; import/export with automatic backups.</td></tr>
88
- <tr><td><b>Skills</b></td><td>Grouped by source; enable, remove, import, edit; same-name skills show which copy is in effect; external directories stay read-only.</td></tr>
89
- <tr><td><b>Subagents</b></td><td>One <code>.md</code> per persona; delegate work, limit tools, pick a model; only the result comes back, never into your History.</td></tr>
90
- <tr><td><b>Prompts</b></td><td>Multiple <code>AGENTS.md</code> baselines with one-click apply/undo and five generations of backups; quick prompts paste into the composer from <code>/</code>.</td></tr>
91
- <tr><td><b>Memories</b></td><td>A scene is the folder; <code>.md</code> bodies are injected automatically; import/export, recycle bin, injection budget.</td></tr>
92
- <tr><td><b>Sessions</b></td><td>Archived by project, searchable, batch restore; import Claude Code / Cursor / Codex transcripts; export Markdown / JSONL.</td></tr>
93
- <tr><td><b>Host</b></td><td>Version and capability checks, access token, scope mode, injection switches, model-tool table, sidebar entry, backup cleanup.</td></tr>
94
- </table>
95
-
96
- ## Let the agent drive it
97
-
98
- Six domains, **26 model tools**: list, read, create, update, delete, toggle, enter or leave a scene, apply a prompt, run a persona.
99
-
100
- - **Only 6 ship enabled** (~1.6k tokens/turn); the other 20 stay off. Off means **not in the schema at all** — the model cannot see them, let alone call them.
101
- - **Scoped writes**: the model writes to the current layer by default and the receipt says which one; `scope: "global"` is required to touch everything.
102
- - **Confirmation cards**: stopping servers, deleting, machine-wide toggles and similar writes ask first; recovery actions (restart, restore, undo apply) go straight through.
103
- - **Per-tool control**: the model-tool table on the Host page adjusts visibility per layer. All 26 on is ~6.2k tokens/turn; profiles can be saved per task and switched together with a scene.
104
-
105
- ## The Host page
106
-
107
- More than a version number:
108
-
109
- - **Checks**: host version, the plugin build actually loaded this run, and whether each action is native / adapted / unavailable, with reasons. Items whose names can be checked but whose timing or rendering cannot are listed under “not automatically verifiable”. If an upgrade quietly breaks something, it shows up here; the “Re-check” button re-runs the probe in place.
110
- - **Upgrade diff**: per-package versions for cordis, the 11 peers and 15 runtime-only official packages against the verified baseline (out-of-range peers become blockers), plus canaries for event names, session-directory layout, patch dialect, MCP config keys and tool argument schemas, prompt section ordering, client UI slots and official skill assets.
111
- - **Access token**: set / disable / change / delete; writes and plaintext secrets go through it.
112
- - **Scope**: all global / per workspace / per conversation.
113
- - **Injection**: per-domain switches, minimal-preset fallback, catalog caps for skills / MCP / subagents (overflow folds into a one-line count; per-entry description length is configurable too), the two slash-menu entries, sidebar entry.
114
- - **Model tools**: per-tool visibility for all 26, saved per layer.
115
- - **Maintenance**: old-backup cleanup, feature overview, recent changes.
116
-
117
- <details>
118
- <summary><b>Where data lives · security boundaries</b></summary>
119
-
120
- | Content | Location |
121
- |:-------------------------------------------------------------- |:---------------------------------------------------------------------------- |
122
- | MCP definitions | `~/.dsh/cordis.patch.yml` (global) · `~/.dsh/profiles/<name>/cordis.patch.yml` (current profile) |
123
- | Skill policy / custom directories | `~/.dsh/tool-management/skills-state.json` |
124
- | Skills / memories / personas / presets | `~/.dsh/tool-management/{skills,memories,subagents,prompts}/` |
125
- | Memory index / scenes / profiles | `~/.dsh/tool-management/memories-index.json` |
126
- | Recycle bins (skills / memories / personas / presets / scenes) | `~/.dsh/tool-management/trash/<domain>-trash/` |
127
- | Archive ledger / retention | `~/.dsh/tool-management/history-*.json` |
128
- | MCP sidecars (disabled tools / known tools / notes / settings) | `~/.dsh/tool-management/mcp-*.json` |
129
- | Injection settings (six domain switches · catalog caps) | `~/.dsh/tool-management/inject-settings.json` |
130
- | Model-tool table / scope overrides | `~/.dsh/tool-management/tool-table.json` · `scope-overrides.json` |
131
- | Runtime log / patch backups | `~/.dsh/tool-management/tool-management.log` · `backups/` |
132
-
133
- - **Write scope**: skill sources are never touched; MCP changes go to the two patch files above (five backups each); applying a prompt overwrites the `~/.dsh/AGENTS.md` the host reads (the previous text is kept inside the hub); the desktop build clears `dsh-auth-*` cookies older than ten minutes at startup.
134
- - **Token**: once set, every write and every plaintext secret requires `x-dsh-token`; the UI stores it in browser localStorage bound to the current boot (a restart asks again), and plaintext still needs the token.
135
- - **Process-level boundary is the token**: writes normally sit behind the host's browser auth; when the host fence is absent the route falls back to a loopback-only check, which any local process can pass — only the access token gives you a process-level boundary.
136
- - **Plaintext on disk**: masking happens in the UI only. MCP `env` / `headers` and the plugin `token` stay plaintext in the patch file, and backups are not encrypted. The token gate cannot stop disk reads — file permissions are the boundary.
137
- - **Deletes are recoverable**: skills / memories / personas / presets / scenes go to the recycle bin (permanent session deletion excepted), with an optional retention period (keep forever by default).
138
-
139
- </details>
140
-
141
- ## FAQ
142
-
143
- | Symptom | Fix |
144
- |:--------------------------------------- |:-------------------------------------------------------------------------------------------------------------------------------------------------------- |
145
- | No panel after installing | Hard-refresh the browser; if that fails, restart DSH. |
146
- | The model cannot call a tool | Host page → “Model tools”, make sure the right conversation / workspace is selected (20 tools are off by default). The panel and scripts are unaffected. |
147
- | Actions unavailable after a DSH upgrade | Check the reason on the Host page; run `node scripts/doctor.mjs`, then `node scripts/host-deps.mjs --fix`. |
148
- | Version mismatch | Supports DSH **0.2.2** only (`>=0.2.2-rc.1 <0.2.3`); cross-generation upgrades wait for the plugin to catch up. Install 0.21.x for older hosts. |
149
- | Duplicate MCP tab | Remove the old loader line from `cordis.patch.yml` and restart. |
150
- | DSH won't start after a bad edit | Restore the newest `cordis.patch.yml.*.bak-*` from `~/.dsh/tool-management/backups/`. |
151
-
152
- Full troubleshooting guide: [docs/TROUBLESHOOTING.md](docs/TROUBLESHOOTING.md).
153
-
154
- ## Docs
155
-
156
- | Doc | When to read it |
157
- |:-------------------------------------------------------------- |:--------------------------------------------------------------------------------------------------------- |
158
- | [Troubleshooting](docs/TROUBLESHOOTING.md) | Missing panel, duplicate tab, actions unavailable after an upgrade, broken sidecars |
159
- | [Architecture](docs/ARCHITECTURE.md) | How content reaches the model, why one toggle differs between conversations, which file a change lands in |
160
- | [Compatibility matrix](docs/COMPATIBILITY.md) | Capability matrix per DSH version (verified / untested / unavailable) |
161
- | [Changelog](CHANGELOG.md) · [Release overview](docs/UPDATE.md) | What changed in each version |
162
-
163
- ## Development
164
-
165
- ```bash
166
- npm install
167
- npm run build # tsc + sync client
168
- npm test # build + i18n + contract tests
169
- npm run doctor # host compatibility check
170
- ```
171
-
172
- `lib/` is not committed — run `npm run build` after cloning, and restart `dsh web` to pick up changes. Runtime dependencies are `fflate`, `js-yaml` and `semver` (static imports in the build; the plugin will not load without any of them); every `@deepseek-ai/*` package uses the host's copy.
173
-
174
- ## License
175
-
176
- MIT
1
+ <p align="center">
2
+ <img src="docs/images/banner-en.png" alt="Tool Management — one click swaps the entire environment" width="100%">
3
+ </p>
4
+
5
+ <p align="center">
6
+ <a href="https://www.npmjs.com/package/dsh-plugin-tool-management"><img src="https://img.shields.io/npm/v/dsh-plugin-tool-management?logo=npm&color=cb3837&style=flat-square" alt="npm"></a>
7
+ <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue?style=flat-square" alt="MIT"></a>
8
+ <img src="https://img.shields.io/badge/DSH-0.2.2-4f7cf7?style=flat-square" alt="DSH 0.2.2">
9
+ <a href="https://github.com/ouli-1242/dsh-plugin-tool-management"><img src="https://img.shields.io/badge/GitHub-ouli--1242-181717?logo=github&style=flat-square" alt="GitHub"></a>
10
+ </p>
11
+
12
+ <p align="center">
13
+ <a href="https://dsh.market/"><img src="https://raw.githubusercontent.com/2BingLing/dsh-market/master/assets/readme/badge-listed-en.svg" height="20" alt="DSH Market"></a>
14
+ <a href="https://awesome-dsh-plugin.com"><img src="https://img.shields.io/badge/awesome--dsh--plugin-listed-3fb950?style=flat-square" alt="awesome-dsh-plugin"></a>
15
+ <a href="https://dshfind.com/en/plugins/ouli-1242/dsh-plugin-tool-management"><img src="https://dshfind.com/api/badge/ouli-1242/dsh-plugin-tool-management?lang=en" alt="dshfind"></a>
16
+ <a href="https://github.com/0xsline/awesome-deepseek-harness"><img src="https://img.shields.io/badge/0xsline-listed-3fb950?style=flat-square" alt="0xsline"></a>
17
+ </p>
18
+
19
+ <p align="center">
20
+ <a href="README.md">简体中文</a> · <b>English</b> · <a href="CHANGELOG.md">Changelog</a> · <a href="docs/UPDATE.md">Release overview</a>
21
+ </p>
22
+
23
+ MCP servers, skills, subagents, prompts, memories and archived sessions for DeepSeek Harness — all in one panel. Bundle them into a **scene**, swap the whole environment with one click, and roll back to the pre-entry snapshot when you leave.
24
+
25
+ ```sh
26
+ dsh plugin --profile web add dsh-plugin-tool-management@latest # web
27
+ dsh plugin --profile desktop add dsh-plugin-tool-management@latest # desktop
28
+ ```
29
+
30
+ Hard-refresh the browser after installing for web (Cmd/Ctrl+Shift+R), or restart the desktop app — then open **Settings → Tools Management**. For desktop, open the app once and quit it completely before running the command. An older version usually means registry lag or pnpm's `minimumReleaseAge` — install an exact version (`@0.X.X`) instead.
31
+
32
+ ---
33
+
34
+ ## Highlights
35
+
36
+ <table>
37
+ <tr>
38
+ <td width="33%" valign="top"><b>One-click scene switch</b><br>Each scene stores a full profile: MCP, skills, subagents, memories, quick prompts, a prompt preset and a model-tool table. Enter it and the whole stack switches; leave it and the pre-entry snapshot comes back.</td>
39
+ <td width="33%" valign="top"><b>Control from the chat</b><br>Type <code>/</code> for a “Tools” section: enter or leave a scene, toggle any of the six domains. The menu stays open and leaves no command text in the composer.</td>
40
+ <td width="34%" valign="top"><b>Three scopes</b><br>All global / per workspace / per conversation. By default every conversation has its own settings — two conversations in the same project can run two different environments at once.</td>
41
+ </tr>
42
+ <tr>
43
+ <td valign="top"><b>The agent can drive it</b><br>24 model tools across six domains: list, read, create, update, delete, toggle, enter scenes, apply prompts, run personas. Writes ask for confirmation (except in a full-permission session, where the card is skipped and only a log line is written); disabled tools are not in the schema at all.</td>
44
+ <td valign="top"><b>The Host page is a control center</b><br>Version and capability checks, access token, scope mode, per-domain injection switches, the model-tool table and the sidebar entry — all on one page.</td>
45
+ <td valign="top"><b>One panel, eight tabs</b><br>Scenes / MCP / Skills / Subagents / Prompts / Memories / Sessions / Host — no more hunting through six different settings pages.</td>
46
+ </tr>
47
+ </table>
48
+
49
+ ## Demo
50
+
51
+ <video controls width="100%" src="https://github.com/user-attachments/assets/ff3111c3-4228-45b7-9e28-b85dc60fb6b3"></video>
52
+
53
+ Player refuses to start (browsers with a stricter CSP sometimes block the inline embed)? [Watch the same file directly](https://github.com/user-attachments/assets/ff3111c3-4228-45b7-9e28-b85dc60fb6b3).
54
+
55
+ Every interface shown is a real screenshot of the running product.
56
+
57
+ Music: Kevin MacLeod「Limit 70」, [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/).
58
+
59
+ ## Screenshots
60
+
61
+ | | |
62
+ |:----------------------------------------------------------------------------:|:------------------------------------------------------------------------------:|
63
+ | <img src="docs/images/1-EN.png" alt="Scenes" width="100%"><br>**Scenes** | <img src="docs/images/2-EN.png" alt="MCP" width="100%"><br>**MCP** |
64
+ | <img src="docs/images/3-EN.png" alt="Skills" width="100%"><br>**Skills** | <img src="docs/images/4-EN.png" alt="Subagents" width="100%"><br>**Subagents** |
65
+ | <img src="docs/images/5-EN.png" alt="Prompts" width="100%"><br>**Prompts** | <img src="docs/images/6-EN.png" alt="Memories" width="100%"><br>**Memories** |
66
+ | <img src="docs/images/7-EN.png" alt="Sessions" width="100%"><br>**Sessions** | <img src="docs/images/8-EN.png" alt="Host" width="100%"><br>**Host** |
67
+
68
+ ## Three scopes
69
+
70
+ Every conversation gets its own settings by default. Switch once on the **Host page → Scope**, and the whole panel plus every model tool follows that layer:
71
+
72
+ | | All global | Per workspace | Per conversation (default) |
73
+ |:------------------------ |:---------------------------------------------- |:------------------------------------------ |:------------------------------------------ |
74
+ | **Who shares one set** | Every conversation | Conversations in the same workspace | Each conversation separately |
75
+ | **Best for** | One person, one machine, consistent everywhere | One project, one environment | Parallel tasks in one project |
76
+ | **Lost when switching?** | — | Nothing is deleted; switch back to restore | Nothing is deleted; switch back to restore |
77
+
78
+ The selector at the top of the panel jumps to a specific conversation or workspace and shows its own copy; when that layer is locked, the unlock button sits on the same row. Within a layer, every switch resolves top-down: **this layer's edit > entered scene > creation snapshot > global**.
79
+
80
+ Scenes work in all three scopes. Under per-conversation, conversation A can sit in “Coding” while B stays in “Writing”, each with its own MCP servers, skills and personas.
81
+
82
+ ## What each tab does
83
+
84
+ <table>
85
+ <tr><th width="15%" align="left">Tab</th><th align="left">What it does</th></tr>
86
+ <tr><td><b>Scenes</b></td><td>Save the whole environment as a profile; enter and leave with one click; lock it against edits; bind a prompt preset and a model-tool table; deleting it sends its memories to the recycle bin too.</td></tr>
87
+ <tr><td><b>MCP</b></td><td>Add, edit and remove servers; toggle individual tools; write a note the model sees; inspect the last-known tool list while a server is stopped; import/export with automatic backups.</td></tr>
88
+ <tr><td><b>Skills</b></td><td>Grouped by source; enable, remove, import, edit; same-name skills show which copy is in effect; external directories stay read-only.</td></tr>
89
+ <tr><td><b>Subagents</b></td><td>One <code>.md</code> per persona; delegate work, limit tools, pick a model; only the result comes back, never into your History.</td></tr>
90
+ <tr><td><b>Prompts</b></td><td>Multiple <code>AGENTS.md</code> baselines with one-click apply/undo and five generations of backups; quick prompts paste into the composer from <code>/</code>.</td></tr>
91
+ <tr><td><b>Memories</b></td><td>A scene is the folder; <code>.md</code> bodies are injected automatically; import/export, recycle bin, injection budget.</td></tr>
92
+ <tr><td><b>Sessions</b></td><td>Archived by project, searchable, batch restore; import Claude Code / Cursor / Codex transcripts; export Markdown / JSONL.</td></tr>
93
+ <tr><td><b>Host</b></td><td>Version and capability checks, access token, scope mode, injection switches, model-tool table, sidebar entry, backup cleanup.</td></tr>
94
+ </table>
95
+
96
+ ## Let the agent drive it
97
+
98
+ Six domains, **24 model tools**: list, read, create, update, delete, toggle, enter or leave a scene, apply a prompt, run a persona.
99
+
100
+ - **Only 6 ship enabled** (~1.5k tokens/turn); the other 18 stay off. Off means **not in the schema at all** — the model cannot see them, let alone call them.
101
+ - **Scoped writes**: the model writes to the current layer by default and the receipt says which one; `scope: "global"` is required to touch everything.
102
+ - **Confirmation cards**: stopping servers, deleting, machine-wide toggles and similar writes ask first; recovery actions (restart, restore, undo apply) go straight through.
103
+ - **Per-tool control**: the model-tool table on the Host page adjusts visibility per layer. All 24 on is ~6.1k tokens/turn; profiles can be saved per task and switched together with a scene.
104
+ - **The model can switch tools back on**: the always-on `tool_manager_tools` lists the tools that are off in this conversation (name, purpose, ≈tokens) and turns them on as needed — when the user asks for a scene whose tools happen to be off, the model has a way forward instead of bouncing back to the user.
105
+
106
+ ## The Host page
107
+
108
+ More than a version number:
109
+
110
+ - **Checks**: host version, the plugin build actually loaded this run, and whether each action is native / adapted / unavailable, with reasons. Items whose names can be checked but whose timing or rendering cannot are listed under “not automatically verifiable”. If an upgrade quietly breaks something, it shows up here; the “Re-check” button re-runs the probe in place.
111
+ - **Upgrade diff**: per-package versions for cordis, the 11 peers and 15 runtime-only official packages against the verified baseline (out-of-range peers become blockers), plus canaries for event names, session-directory layout, patch dialect, MCP config keys and tool argument schemas, prompt section ordering, client UI slots and official skill assets.
112
+ - **Access token**: set / disable / change / delete; writes and plaintext secrets go through it.
113
+ - **Scope**: all global / per workspace / per conversation.
114
+ - **Injection**: per-domain switches, minimal-preset fallback, catalog caps for skills / MCP / subagents (overflow folds into a one-line count; per-entry description length is configurable too), the two slash-menu entries, sidebar entry.
115
+ - **Model tools**: per-tool visibility for all 26, saved per layer.
116
+ - **Maintenance**: old-backup cleanup, feature overview, recent changes.
117
+
118
+ <details>
119
+ <summary><b>Where data lives · security boundaries</b></summary>
120
+
121
+ | Content | Location |
122
+ |:-------------------------------------------------------------- |:---------------------------------------------------------------------------- |
123
+ | MCP definitions | `~/.dsh/cordis.patch.yml` (global) · `~/.dsh/profiles/<name>/cordis.patch.yml` (current profile) |
124
+ | Skill policy / custom directories | `~/.dsh/tool-management/skills-state.json` |
125
+ | Skills / memories / personas / presets | `~/.dsh/tool-management/{skills,memories,subagents,prompts}/` |
126
+ | Memory index / scenes / profiles | `~/.dsh/tool-management/memories-index.json` |
127
+ | Recycle bins (skills / memories / personas / presets / scenes) | `~/.dsh/tool-management/trash/<domain>-trash/` |
128
+ | Archive ledger / retention | `~/.dsh/tool-management/history-*.json` |
129
+ | MCP sidecars (disabled tools / known tools / notes / settings) | `~/.dsh/tool-management/mcp-*.json` |
130
+ | Injection settings (six domain switches · catalog caps) | `~/.dsh/tool-management/inject-settings.json` |
131
+ | Model-tool table / scope overrides | `~/.dsh/tool-management/tool-table.json` · `scope-overrides.json` |
132
+ | Runtime log / patch backups | `~/.dsh/tool-management/tool-management.log` · `backups/` |
133
+
134
+ - **Write scope**: skill sources are never touched; MCP changes go to the two patch files above (five backups each); applying a prompt overwrites the `~/.dsh/AGENTS.md` the host reads (the previous text is kept inside the hub); the desktop build clears `dsh-auth-*` cookies older than ten minutes at startup.
135
+ - **Token**: once set, every write and every plaintext secret requires `x-dsh-token`; the UI stores it in browser localStorage bound to the current boot (a restart asks again), and plaintext still needs the token.
136
+ - **Process-level boundary is the token**: writes normally sit behind the host's browser auth; when the host fence is absent the route falls back to a loopback-only check, which any local process can pass — only the access token gives you a process-level boundary.
137
+ - **Plaintext on disk**: masking happens in the UI only. MCP `env` / `headers` and the plugin `token` stay plaintext in the patch file, and backups are not encrypted. The token gate cannot stop disk reads — file permissions are the boundary.
138
+ - **Deletes are recoverable**: skills / memories / personas / presets / scenes go to the recycle bin (permanent session deletion excepted), with an optional retention period (keep forever by default).
139
+
140
+ </details>
141
+
142
+ ## FAQ
143
+
144
+ | Symptom | Fix |
145
+ |:--------------------------------------- |:-------------------------------------------------------------------------------------------------------------------------------------------------------- |
146
+ | No panel after installing | Hard-refresh the browser; if that fails, restart DSH. |
147
+ | The model cannot call a tool | Host page → “Model tools”, make sure the right conversation / workspace is selected (18 tools are off by default). The panel and scripts are unaffected. |
148
+ | Actions unavailable after a DSH upgrade | Check the reason on the Host page; run `node scripts/doctor.mjs`, then `node scripts/host-deps.mjs --fix`. |
149
+ | Version mismatch | Supports DSH **0.2.2** only (`>=0.2.2-rc.1 <0.2.3`); cross-generation upgrades wait for the plugin to catch up. Install 0.21.x for older hosts. |
150
+ | Duplicate MCP tab | Remove the old loader line from `cordis.patch.yml` and restart. |
151
+ | DSH won't start after a bad edit | Restore the newest `cordis.patch.yml.*.bak-*` from `~/.dsh/tool-management/backups/`. |
152
+
153
+ Full troubleshooting guide: [docs/TROUBLESHOOTING.md](docs/TROUBLESHOOTING.md).
154
+
155
+ ## Docs
156
+
157
+ | Doc | When to read it |
158
+ |:-------------------------------------------------------------- |:--------------------------------------------------------------------------------------------------------- |
159
+ | [Troubleshooting](docs/TROUBLESHOOTING.md) | Missing panel, duplicate tab, actions unavailable after an upgrade, broken sidecars |
160
+ | [Architecture](docs/ARCHITECTURE.md) | How content reaches the model, why one toggle differs between conversations, which file a change lands in |
161
+ | [Compatibility matrix](docs/COMPATIBILITY.md) | Capability matrix per DSH version (verified / untested / unavailable) |
162
+ | [Changelog](CHANGELOG.md) · [Release overview](docs/UPDATE.md) | What changed in each version |
163
+
164
+ ## Development
165
+
166
+ ```bash
167
+ npm install
168
+ npm run build # tsc + sync client
169
+ npm test # build + i18n + contract tests
170
+ npm run doctor # host compatibility check
171
+ ```
172
+
173
+ `lib/` is not committed — run `npm run build` after cloning, and restart `dsh web` to pick up changes. Runtime dependencies are `fflate`, `js-yaml` and `semver` (static imports in the build; the plugin will not load without any of them); every `@deepseek-ai/*` package uses the host's copy.
174
+
175
+ ## License
176
+
177
+ MIT
@@ -0,0 +1,134 @@
1
+ # 架构
2
+
3
+ 三张图。看懂它们就能回答「这条内容从哪来、为什么这个对话看得见、改完落到哪个文件」这三个问题。
4
+
5
+ 细节不在这里 —— 代码注释里逐条记着每个决定的原因。
6
+
7
+ ---
8
+
9
+ ## 一、注入链路:内容怎么到模型眼前
10
+
11
+ 插件的六个域(场景 / 记忆 / MCP / 技能 / 子智能体 / 提示词)各自算出一段文本,在**每一步请求开始前**塞进本轮消息。这条通道是宿主官方自己也在用的那一条,任何预设都关不掉它。
12
+
13
+ ```
14
+ 你的文件(真源)
15
+ hub/memories/<场景>/*.md 记忆正文
16
+ hub/subagents/*.md 人设
17
+ hub/skills/**/SKILL.md 技能
18
+ hub/prompts/*/AGENTS.md 提示词预设
19
+ 宿主服务里的 MCP 清单 服务器与工具
20
+ hub/*.json 启停 / 顺序 / 备注
21
+ │
22
+ │ 每个域各自算一段文本(各域自带缓存,这一步不读盘)
23
+ ▼
24
+ 六个域:scene / memory / mcp / skills / subagents / prompt
25
+ │
26
+ │ 宿主 agent/pre-step 瀑布,每一步请求前触发
27
+ ▼
28
+ 一条合成的 user 消息(每域一条,框架包住整段正文)
29
+ │
30
+ │ 与会话表面上该域最近一条己方消息逐字节比对
31
+ ▼
32
+ 一样 → 不发(零 token)
33
+ 不一样 → 追加一条新消息
34
+ 被压缩移出表面 → 比对不到 → 自动重发
35
+ 曾经注入过、现在空了 → 发一条「已清空」
36
+ │
37
+ ▼
38
+ 模型上下文
39
+ ```
40
+
41
+ 三个后果值得记住:
42
+
43
+ - **每个域一条消息,不是一大坨快照。** 只改一个域就只重发那一条,轨迹里也各自一行、各显各的名字。
44
+ - **注入失败绝不影响这一轮对话。** 任何异常都在监听器里吞掉、原样放行 —— 宁可少一段提示,不能让对话中断。
45
+ - **子会话默认不收人设目录。** 人设的 `catalogDepth` 决定它在哪一层深度出现(默认只在顶层),这是减少噪声,不是禁止嵌套委派。
46
+
47
+ `AGENTS.md` 是**另一条**路:提示词域把它写进 `$DSH_HOME/AGENTS.md`(全局基线),由宿主自己的 `dsh-agent-instructions` 每步读取注入。所以「应用了预设但模型没反应」要分两种查:写没写进去(文件内容),和宿主有没有重读(宿主的刷新契约)。
48
+
49
+ ---
50
+
51
+ ## 二、四层作用域:同一个开关为什么在两个对话里不一样
52
+
53
+ 按对话 / 按工作区模式下,一个会话看到的**每一格**取值都由四层叠加决定,自上而下,先有话说者赢:
54
+
55
+ ```
56
+ ① 会话覆盖 scope[domain][key]
57
+ 这个对话里显式拨过的开关 —— 永远赢
58
+ │ 没这一格
59
+ ▼
60
+ ② 场景层 处于场景模式时(scope.scene 存在)
61
+ 按场景档案实时算:档案里有这一段 → 勾了开、没勾关
62
+ 档案里没这一段 → 这一层没话说
63
+ │ 没这一格
64
+ ▼
65
+ ③ 基线 仅当 scope.detached === true
66
+ 会话创建时的冻结快照 —— 退出场景落回这里
67
+ │ 没这一格
68
+ ▼
69
+ ④ 全局 实时值
70
+ 前三层都没话说时才轮到它
71
+ ```
72
+
73
+ 几条容易踩的边界:
74
+
75
+ - **退出场景落回基线,不是落回全局。** 全局是会变的;落回全局等于「退出场景时顺手把别人的改动也吃了」。
76
+ - **三态存储、二态展示。** 存储上是「没这一格 / 显式开 / 显式关」;界面上只有绿与灰 —— 停在某一层时看到的就是**这个对话的生效值**。
77
+ - **点回「跟随」会自动清掉覆盖。** 写侧判一次(新值 == 下层此刻的值就删键),读侧再判一次(下层后来被改成同一个值,那条覆盖就不该再起作用)。
78
+ - **记忆不收场景层。** 记忆的「在哪一层」由场景名 + 逐条开关决定,档案的记忆段已废弃;场景层只影响开关类域。
79
+ - **拿不到会话身份时一律按全局。** 冷恢复的临时 agent、宿主契约变更 —— 猜错的代价是「A 的设置漏进 B」,按全局最多是「这一处没隔离」,用户看得见且不串内容。
80
+ - **子代理与侧聊向上找父会话的作用域。** 否则父会话里藏起来的服务器 / 技能 / 工具表,派一个子代理就能重新看见。
81
+
82
+ 工作区档的作用域键由**根会话的 cwd** 派生(会话头里没有 workspaceId),与下拉分组、工作区挂回同一口径。
83
+
84
+ ---
85
+
86
+ ## 三、写盘落点:每个改动落在哪个文件
87
+
88
+ 插件产生的一切都在 `$DSH_HOME/tool-management/` 一个目录里,方便整体备份。
89
+
90
+ ```
91
+ $DSH_HOME/
92
+ ├─ AGENTS.md ← 宿主每轮读取的全局基线(插件按场景/预设写它)
93
+ ├─ cordis.patch.yml ← 宿主加载插件的配置入口(插件写 MCP 服务器时改它)
94
+ └─ tool-management/ ← hub:插件的全部状态
95
+ ├─ memories/<场景>/<名>.md 记忆正文(真源)
96
+ ├─ subagents/<人设>.md 子智能体人设
97
+ ├─ prompts/<预设 id>/AGENTS.md 提示词预设库
98
+ ├─ skills/ 插件新建 / 导入的技能(可写根)
99
+ │
100
+ ├─ memories-index.json 记忆启停/顺序 + 场景记录/档案/模式
101
+ ├─ subagents-index.json 人设启停集合
102
+ ├─ skills-state.json 技能启停 / 首选 / 自定义目录
103
+ ├─ scope-overrides.json 会话 / 工作区的四层覆盖
104
+ ├─ scope-intent.json 全局意图开关
105
+ ├─ tool-table.json 模型工具表(每层一份整名单)
106
+ ├─ mcp-disabled-tools.json 全局停用表(安全边界,fail-closed)
107
+ ├─ mcp-known-tools.json 见过的工具清单
108
+ ├─ mcp-notes.json / mcp-settings.json / mcp-export.json
109
+ ├─ inject-settings.json / scene-settings.json
110
+ ├─ slash-settings.json / sidebar-settings.json
111
+ ├─ trash-retention.json 回收站保留期
112
+ ├─ update-check.json 更新检查缓存(纯缓存,可删)
113
+ ├─ mount.json 挂载心跳:这一轮插件真的挂上了吗
114
+ ├─ .write.lock 跨进程写锁(临时;崩溃后最多挡 1 分钟)
115
+ ├─ audit.jsonl 审计记录(追加写,不参与任何判定)
116
+ ├─ tool-management.log (+ .1) 插件日志(滚动)
117
+ │
118
+ ├─ backups/cordis.patch.yml[.global|.profile-<名字>].bak-<YYYYMMDD>-<HHMMSSmmmsss>
119
+ │ 改宿主 patch 前的备份(按层级各留 5 份)
120
+ └─ trash/
121
+ ├─ skills-trash/<id>/ 六类回收站:条目 = manifest.json + 负载
122
+ ├─ subagents-trash/<id>/ 移入 = 移动(原位置立刻消失)
123
+ ├─ prompts-trash/<id>/ 绝不覆盖(恢复时目标已存在就报错)
124
+ ├─ scenes-trash/<id>/ 失败要回滚(搬了一半就搬回去)
125
+ ├─ quick-prompts-trash/<id>/
126
+ └─ memories-trash/<id>/
127
+ ```
128
+
129
+ 几条纪律:
130
+
131
+ - **正文与索引分开。** 索引坏了最多丢「启停 / 顺序 / 场景档案」,`memories/` `subagents/` `prompts/` `skills/` 里的正文一个都不会动 —— 所以任何修复都不要碰这四个目录。
132
+ - **写侧车一律原子写。** 半截文件比没有文件更糟:读不出来时多数路径会 fail-closed(停用表坏了就全部拒绝),而不是猜一个默认值。
133
+ - **安全边界上的文件有取证副本。** 停用表损坏时覆盖前强制留一份,复制失败就拒绝写入。
134
+ - **旧布局只搬不删、绝不覆盖。** 升级时的目录改名是幂等的一次性动作,搬不动的留在原地下次再试 —— 失败也绝不阻断启动。