dsh-plugin-tool-management 0.1.2 → 0.2.0

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.
package/README_EN.md CHANGED
@@ -1,136 +1,231 @@
1
- # dsh-plugin-tool-management
2
-
3
- [![npm version](https://img.shields.io/npm/v/dsh-plugin-tool-management?logo=npm&color=cb3837)](https://www.npmjs.com/package/dsh-plugin-tool-management)
4
- [![License](https://img.shields.io/badge/license-MIT-blue)](LICENSE)
5
- [![Node](https://img.shields.io/badge/node-%3E%3D18-339933?logo=node.js)](package.json)
6
- [![GitHub](https://img.shields.io/badge/GitHub-ouli--1242%2Fdsh--plugin--tool--management-181717?logo=github)](https://github.com/ouli-1242/dsh-plugin-tool-management)
7
-
8
- **An MCP server & skills manager for DeepSeek Harness.** One settings panel keeps two things under control:
9
-
10
- - **MCP**: which servers are configured, what tools each one exposes, and which tools the model may call — add, edit, remove, toggle, restart; every change takes effect immediately;
11
- - **Skills**: every skill on the machine (DSH / Agents / Codex / Claude / project-level / any directory you add) at a glance — toggle individually or per source, create, import, recycle.
12
-
13
- No hand-editing of `cordis.patch.yml`, and skill source files are never touched. Configuration survives restarts and upgrades.
14
-
15
- ---
16
-
17
- <!-- Image slot 1: MCP management page screenshot → docs/images/mcp-page.png -->
18
-
19
- ![MCP management](https://raw.githubusercontent.com/ouli-1242/dsh-plugin-tool-management/main/docs/images/mcp-page.png)
20
-
21
- <!-- Image slot 2: Skills management page screenshot → docs/images/skills-page.png -->
22
-
23
- ![Skills management](https://raw.githubusercontent.com/ouli-1242/dsh-plugin-tool-management/main/docs/images/skills-page.png)
24
-
25
- ## Highlights
26
-
27
- | Capability | Description |
28
- |---|---|
29
- | Per-tool switches | **Toggle individual tools** inside one MCP server: hidden from the model and blocked at call time, restorable at any moment; whole-server batch enable/disable also supported |
30
- | Restart semantics | Restart only reconnects — it **never flips the enabled state** (restarting a disabled server does not silently enable it) |
31
- | Secret safety | Secret-looking values in `env` / `headers` are **masked by default**, URL query strings are always redacted; revealing plaintext is token-gated just like writes |
32
- | Write protection | Every patch rewrite keeps a timestamped `.bak` backup (last 5); duplicate loader ids are rejected before write; failed cross-level migration rolls back |
33
- | Backup / restore | JSON import supports `conflict: 'overwrite'` to replace entries with the same id, not just skip them |
34
- | Skill sources | Hooks up `~/.agents` / `~/.codex` / `~/.claude` (three directories official DSH does not load) plus **any custom skill directory** you add (read-only, overlapping paths rejected) |
35
- | Skill operations | Create skills, import ZIP / folders, plugin recycle bin (restore / permanent delete with OS-trash fallback), open the source file in the system editor |
36
- | Live refresh | Skill directories are watched from a background thread — edits made in an editor show up automatically |
37
- | Slash commands | `/mcp` and `/skills` right from the chat box |
38
- | Model tools | **7 tools**: `skill_mcp_manager_*` for MCP servers, `skill_manager_*` for skills (creating asks for user confirmation first) |
39
- | UI | Its own `dsm-*` design system, consistent across both pages |
40
-
41
- ## Getting started
42
-
43
- Prerequisites: DSH installed (`dsh web` runs), Node.js ≥ 18.
44
-
45
- ```sh
46
- # Install (package + auto-mount)
47
- dsh plugin --profile web add dsh-plugin-tool-management@latest
48
-
49
- # Update: run the same command again
50
- # Uninstall:
51
- dsh plugin --profile web remove dsh-plugin-tool-management
52
- ```
53
-
54
- Hard-refresh the browser (Cmd/Ctrl+Shift-R) after installing — the **MCP** and **Skills** pages appear in Settings (client changes are hot-loaded by DSH, no restart needed).
55
-
56
- You can also tell any DSH session:
57
-
58
- ```text
59
- Install the dsh-plugin-tool-management plugin:
60
- dsh plugin --profile web add dsh-plugin-tool-management@latest
61
- Then remind me to hard-refresh the browser.
62
- ```
63
-
64
- ## Feature guide
65
-
66
- ### Managing MCP servers
67
-
68
- - **Add a server**: fill in `serverName` (unique, 1–32 chars `[A-Za-z0-9_-]`), the transport and its fields (`streamable-http` → URL / headers; `stdio` → command / args / env), and choose project or global level. The write lands as a loader row in `cordis.patch.yml` and applies via HMR.
69
- - **See the state**: every card shows live status, loader phase and registered tool count; a summary bar sits on top, and fatal issues such as duplicate loader ids are flagged right on the page.
70
- - **Turn off just one tool**: the "Details" dialog lists every tool with its parameter summary — disable the ones the model keeps misusing; the schema disappears from the model's view and calls are denied, ready to re-enable anytime.
71
- - **Inspect secrets safely**: secret-looking values render as `••••••` by default; click "Reveal" only when you need them.
72
- - **Move and back up**: editing can rename a server or migrate it between project/global level (with automatic rollback on failure); JSON export/import covers full backups.
73
-
74
- ### Managing skills
75
-
76
- - **See everything**: skills are grouped by source — project, runtime, built-in, plugin-shipped, the four user directories (`~/.dsh` / `~/.agents` / `~/.codex` / `~/.claude`; the last three are hooked up by this plugin) and any custom directories you added.
77
- - **Toggle**: individual skills, whole sources or whole projects — implemented as an override-provider shadow policy, so not a single byte of the source file changes; moving machines is just copying the state file.
78
- - **Custom directories**: click "Add directory", enter an absolute path, and that directory becomes a read-only skill source — ideal for skill collections living in repos or synced folders; overlapping paths are rejected to keep the shadow policy sound.
79
- - **Create / import / recycle**: create from a form; drag in a ZIP, a `.md` file or a skill folder; deleted skills go to the plugin recycle bin first, and permanent delete still tries the OS trash as a last safety net.
80
-
81
- ### Let the model and scripts help
82
-
83
- | Entry point | What it does |
84
- |---|---|
85
- | `/mcp`, `/skills` | Check the current state from the chat box |
86
- | `skill_mcp_manager_list / set_enabled / restart / add` | Let the model query and operate MCP servers |
87
- | `skill_manager_list / set_enabled / create` | Let the model query and operate skills (creating asks for your consent) |
88
- | `POST /dsh-plugin-tool-management/api` | HTTP API for scripts (`{op, args}` protocol) |
89
-
90
- ## Configuration & security
91
-
92
- Optional fields on the plugin loader row (`dsh plugin add` inserts it automatically):
93
-
94
- | Field | Description |
95
- |---|---|
96
- | `token` | Optional access token. When set, **every write operation and "Reveal"** requires the `x-dsh-token` header. The client reads it from localStorage (key `dsh-plugin-tool-management-token`; set it in the DevTools console and refresh), or via the `DSH_PLUGIN_TOOL_MANAGEMENT_TOKEN` environment variable. |
97
- | `maxBodyBytes` | Request body cap, default 88 MiB (skill ZIP uploads need it). |
98
-
99
- Why a token: the cross-site protection (POST-only + custom header + same-origin check) assumes DSH listens on localhost only. If you forward the port to a LAN or the public internet, the token is the last line of defense against strangers injecting MCP commands (equivalent to remote code execution) and reading plaintext secrets — not needed for local single-user setups.
100
-
101
- ## Where data lives
102
-
103
- | Content | Location |
104
- |---|---|
105
- | MCP server definitions | `profiles/<profile>/cordis.patch.yml` (project) or `~/.dsh/cordis.patch.yml` (global), auto-`.bak` before every rewrite |
106
- | Server notes / page settings / disabled tools / export | Sidecar JSON files under the DSH home (`dsh-plugin-tool-management-*.json`) |
107
- | Skill toggle policy / custom directories | `~/.dsh/tool-management/state.json` |
108
- | Skill recycle bin / import staging | `~/.dsh/tool-management/trash`, `uploads` |
109
- | Runtime log | `~/.dsh/dsh-plugin-tool-management.log` (rolling) |
110
-
111
- ## FAQ
112
-
113
- | Symptom | Fix |
114
- |---|---|
115
- | Pages missing in Settings after install | Hard refresh; if that fails, restart DSH once. |
116
- | Duplicate MCP tabs / duplicated tools | Stale loader row double-mounting the plugin — remove the old entry from `cordis.patch.yml` and restart. |
117
- | Broken config, DSH won't boot | Restore the newest `cordis.patch.yml.bak-<timestamp>` next to it. |
118
- | Page data not refreshing | Wait for the automatic polling (default 5s) or click "Refresh". |
119
- | Latest version not found on a mirror | Add `--registry=https://registry.npmjs.org` and retry later. |
120
-
121
- ## Development
122
-
123
- ```bash
124
- npm install
125
- npm test # build + full test suite (node:test, ~1s)
126
- npm run test:fast # run tests without building
127
- npm run build # build only (tsc + sync client bundle)
128
- ```
129
-
130
- Layout: host half `src/index.ts` (object-form Cordis plugin, `lib/index.js` is the shipped artifact); skill core `src/skills/core.js` (pure Node, unit-testable); browser half `src/client.js` (ModuleLoader CJS bundle, `dsm-*` design system, talks to the host through the same-origin API). The only runtime dependency is `fflate` (ZIP extraction).
131
-
132
- Publish: `npm version patch && npm publish` (`prepublishOnly` builds automatically).
133
-
134
- ## License
135
-
136
- MIT
1
+ # dsh-plugin-tool-management
2
+
3
+ [![npm version](https://img.shields.io/npm/v/dsh-plugin-tool-management?logo=npm&color=cb3837)](https://www.npmjs.com/package/dsh-plugin-tool-management)
4
+ [![License](https://img.shields.io/badge/license-MIT-blue)](LICENSE)
5
+ [![Node](https://img.shields.io/badge/node-%3E%3D18-339933?logo=node.js)](package.json)
6
+ [![GitHub](https://img.shields.io/badge/GitHub-ouli--1242%2Fdsh--plugin--tool--management-181717?logo=github)](https://github.com/ouli-1242/dsh-plugin-tool-management)
7
+
8
+ [简体中文](README.md) · **English**
9
+
10
+ **An MCP server, skills & memory manager for DeepSeek Harness.** One settings panel keeps five things under control:
11
+
12
+ - **MCP**: which servers are configured, what tools each one exposes, and which tools the model may call — add, edit, remove, toggle, restart; every change takes effect immediately;
13
+ - **Skills**: every skill on the machine (DSH / Agents / Codex / Claude / project-level / any directory you add) at a glance — toggle individually or per source, create, import, recycle;
14
+ - **AGENTS.md**: keep multiple global instruction baselines as presets, apply one with a click to write `~/.dsh/AGENTS.md` — new sessions pick it up, current sessions stay unchanged;
15
+ - **History**: archived sessions in one place — grouped by project, batch restore / delete, import & export transcripts, retention-based auto-cleanup;
16
+ - **Scene Memory**: under `~/.dsh/scene-memory/<scene>/`, one folder = one scene and one `.md` = one memory — **create a scene**, drop `.md` files in (Chinese file names are fine), toggle the scene; the full body of every memory in an enabled scene is **injected into the system prompt automatically**, so you never repeat yourself.
17
+
18
+ No hand-editing of `cordis.patch.yml`, and skill source files are never touched. Configuration survives restarts and upgrades.
19
+
20
+ ---
21
+
22
+ <!-- Image slot 1: MCP management page screenshot → docs/images/mcp.png -->
23
+
24
+ ![MCP management](docs/images/mcp.png)
25
+
26
+ <!-- Image slot 2: Skills management page screenshot → docs/images/skills.png -->
27
+
28
+ ![Skills management](docs/images/skills.png)
29
+
30
+ <!-- Image slot 3: AGENTS.md presets page screenshot → docs/images/agents-md.png -->
31
+
32
+ ![AGENTS.md presets](docs/images/agents-md.png)
33
+
34
+ <!-- Image slot 4: History archived sessions page screenshot → docs/images/history.png -->
35
+
36
+ ![History archived sessions](docs/images/history.png)
37
+
38
+ <!-- Image slot 5: Scene memory page screenshot → docs/images/场景记忆.png -->
39
+
40
+ ![Scene memory](docs/images/场景记忆.png)
41
+
42
+ ## Highlights
43
+
44
+ | Capability | Description |
45
+ |---|---|
46
+ | Per-tool switches | **Toggle individual tools** inside one MCP server: hidden from the model and blocked at call time, restorable at any moment; whole-server batch enable/disable also supported |
47
+ | Restart semantics | Restart only reconnects — it **never flips the enabled state** (restarting a disabled server does not silently enable it) |
48
+ | Secret safety | Secret-looking values in `env` / `headers` are **masked by default**, URL query strings are always redacted; revealing plaintext is token-gated just like writes |
49
+ | Write protection | Every patch rewrite keeps a timestamped `.bak` backup (last 5); duplicate loader ids are rejected before write; failed cross-level migration rolls back |
50
+ | Backup / restore | JSON import supports `conflict: 'overwrite'` to replace entries with the same id, not just skip them |
51
+ | Skill sources | Hooks up `~/.agents` / `~/.codex` / `~/.claude` (three directories official DSH does not load) plus **any custom skill directory** you add (read-only, overlapping paths rejected) |
52
+ | Skill operations | Create skills, import ZIP / folders, plugin recycle bin (restore / permanent delete with OS-trash fallback), open the source file in the system editor |
53
+ | Live refresh | Skill directories are watched from a background thread — edits made in an editor show up automatically |
54
+ | AGENTS.md presets | Multiple global instruction baselines as presets — create / import / edit / apply / delete; "Apply" writes `~/.dsh/AGENTS.md` (new sessions pick it up, current sessions stay unchanged) |
55
+ | Archived session management | History page groups archived sessions by project: search, select-all, batch restore / permanent delete, retention-based auto-cleanup (changing the retention resets the countdown from the change time) |
56
+ | Transcript import / export | Seamlessly take over conversations from Claude Code / Cursor (JSONL), Codex (Markdown), or any text; export picks the session scope, defaults to the desktop, in Markdown / JSONL |
57
+ | Slash commands | `/mcp`, `/skills`, `/agents-md`, `/scene-memory` right from the chat box |
58
+ | Scene memory auto-injected | A memory is `~/.dsh/scene-memory/<scene>/<name>.md`; every `.md` inside an enabled scene is **injected into the system prompt automatically** (per-agent `systemPrompt` section) with no tool call, and toggling takes effect on the next request |
59
+ | Scene enable switch | A scene is a top-level `scene-memory/` folder (Unicode names fine); the multi-select switch persists globally in `rules-index.json`'s `active`; **all scenes enabled by default**, `_shared/` always on |
60
+ | Prefix-cache friendly | Section text depends only on enabled scenes + file contents, so it is byte-stable; switching scenes or editing a memory changes it exactly once, every other request keeps hitting the cache (this does not violate the "no injection layer" rule — that one only bans per-turn dynamic content) |
61
+ | Rule checkup | One click scans for shadowed rules, over-long descriptions, filename ≠ name, bad frontmatter, empty bodies, and memories whose scene is disabled |
62
+ | Model tools | **10**: `skill_mcp_manager_*` for MCP, `skill_manager_*` for skills, `rule_manager_*` for memories (creation asks for confirmation unless disabled in settings) |
63
+ | Model tools | **10 tools**: `skill_mcp_manager_*` for MCP servers, `skill_manager_*` for skills, `rule_manager_*` for rules (writes ask for user confirmation; can be disabled in settings) |
64
+ | UI | Its own `dsm-*` design system, consistent across all six pages |
65
+
66
+ ## Getting started
67
+
68
+ Prerequisites: DSH installed (`dsh web` runs), Node.js ≥ 18.
69
+
70
+ ```sh
71
+ # Install (package + auto-mount)
72
+ dsh plugin --profile web add dsh-plugin-tool-management@latest
73
+
74
+ # Update: run the same command again
75
+ # Uninstall:
76
+ dsh plugin --profile web remove dsh-plugin-tool-management
77
+ ```
78
+
79
+ Hard-refresh the browser (Cmd/Ctrl+Shift-R) after installing — the **MCP**, **Skills**, **AGENTS.md**, **History** and **Scene Memory** pages appear in Settings (client changes are hot-loaded by DSH, no restart needed).
80
+
81
+ You can also tell any DSH session:
82
+
83
+ ```text
84
+ Install the dsh-plugin-tool-management plugin:
85
+ dsh plugin --profile web add dsh-plugin-tool-management@latest
86
+ Then remind me to hard-refresh the browser.
87
+ ```
88
+
89
+ ## Feature guide
90
+
91
+ ### Managing MCP servers
92
+
93
+ - **Add a server**: fill in `serverName` (unique, 1–32 chars `[A-Za-z0-9_-]`), the transport and its fields (`streamable-http` → URL / headers; `stdio` → command / args / env), and choose project or global level. The write lands as a loader row in `cordis.patch.yml` and applies via HMR.
94
+ - **See the state**: every card shows live status, loader phase and registered tool count; a summary bar sits on top, and fatal issues such as duplicate loader ids are flagged right on the page.
95
+ - **Turn off just one tool**: the "Details" dialog lists every tool with its parameter summary — disable the ones the model keeps misusing; the schema disappears from the model's view and calls are denied, ready to re-enable anytime.
96
+ - **Inspect secrets safely**: secret-looking values render as `••••••` by default; click "Reveal" only when you need them.
97
+ - **Move and back up**: editing can rename a server or migrate it between project/global level (with automatic rollback on failure); JSON export/import covers full backups.
98
+
99
+ ### Managing skills
100
+
101
+ - **See everything**: skills are grouped by source — project, runtime, built-in, plugin-shipped, the four user directories (`~/.dsh` / `~/.agents` / `~/.codex` / `~/.claude`; the last three are hooked up by this plugin) and any custom directories you added.
102
+ - **Toggle**: individual skills, whole sources or whole projects — implemented as an override-provider shadow policy, so not a single byte of the source file changes; moving machines is just copying the state file.
103
+ - **Custom directories**: click "Add directory", enter an absolute path, and that directory becomes a read-only skill source — ideal for skill collections living in repos or synced folders; overlapping paths are rejected to keep the shadow policy sound.
104
+ - **Create / import / recycle**: create from a form; drag in a ZIP, a `.md` file or a skill folder; deleted skills go to the plugin recycle bin first, and permanent delete still tries the OS trash as a last safety net.
105
+
106
+ ### Managing AGENTS.md presets
107
+
108
+ - **Preset library**: create, import and edit multiple global instruction baselines (e.g. different teams' coding standards or role behaviors).
109
+ - **Apply = write**: "Apply" writes the selected preset to `~/.dsh/AGENTS.md` — **new sessions pick it up, current sessions stay unchanged**; "Re-apply" syncs the latest content after editing; switch to another preset before deleting.
110
+
111
+ ### Managing archived sessions
112
+
113
+ - **Grouped by project**: archived sessions are grouped by workspace automatically; search by title / session ID / project path; sessions whose workspace folder no longer exists are flagged with ⚠.
114
+ - **Batch operations**: "Select all" then batch-restore or permanently delete; restored sessions return to the workspace list, and deletion cascades to their subagent sessions.
115
+ - **Retention**: pick the cleanup period from the dropdown (0 = keep forever); the expiry baseline is the later of the archive time and the last retention change, so changing the retention resets the countdown.
116
+ - **Import conversations**: take over sessions from other tools — Claude Code / Cursor JSONL, Codex Markdown, and arbitrary text — and keep chatting right after import.
117
+ - **Export conversations**: pick a session scope (all / archived only / by workspace); each session becomes a Markdown or JSONL file; the export directory defaults to the desktop, and the adjacent "Select" button opens a directory tree to browse and fill in the absolute path.
118
+
119
+ ### Managing scene memory (the Scene Memory page)
120
+
121
+ > This page merges the former "Rules" and "Scenes" pages: **a scene (top-level folder) is the grouping dimension, a memory (`.md`) is the content.**
122
+ > The folder was also renamed from `~/.dsh/rules/` to **`~/.dsh/scene-memory/`** — move your existing files over after upgrading (see "Upgrade note" below).
123
+
124
+ - **A scene is a top-level folder under `scene-memory/`; the folder name *is* the scene name**: `~/.dsh/scene-memory/办公/流程.md` is one memory in the "办公" scene. Folder names accept any Unicode (≤64 chars, no `/ \ < > : " | ? *`, must not start with a dot); `_shared/` is the reserved shared scene.
125
+ - **New scene**: "New scene" creates the folder for you (or just `mkdir` under `scene-memory/` — same result). Empty scenes are listed and get a "Delete scene" button; a scene that still holds memories cannot be deleted, so nothing is lost in one click.
126
+ - **Every `.md` is one memory**: a sentence or a paragraph, no frontmatter needed, and the whole body is injected. Drop a file into the scene folder and it takes effect, or use "New memory" on the card to write it on the page — **file names can be Chinese** (e.g. `站会流程.md`).
127
+ - **Toggle a scene**: the switch on the right of each scene card enables/disables it (same component and layout as the Skills page). Every `.md` inside an enabled scene is **injected into the system prompt automatically**; the model needs no tool call and you never have to explain again. Toggling takes effect on the **very next request**, with no new session and no plugin reload.
128
+ - **All scenes are enabled by default**: with no configuration at all, every scene is live ("drop it in and it works"); narrow the set in the UI once you have many scenes. `_shared/` is always on (its card has no checkbox).
129
+ - **One memory = one Markdown file**: `<scene>/<name>.md` (flat) or `<scene>/<name>/SKILL.md` (bundle, with attachments). When creating, fill in the scene (pick an existing one or **type a new scene name** — its folder is created for you), the name (= file name), description and body — frontmatter is entirely optional and derived automatically when missing.
130
+ - **Bundle attachments**: with the bundle form you can **add attachments** right in the dialog (multi-select, ≤8 MB each, ≤16 MB / 32 files per upload); they live in the memory folder and are **never injected into the prompt** (only the `SKILL.md` body is), and you can remove them one by one while editing. The flat form is a single file, so it has nowhere to put attachments.
131
+ - **Toggle & recycle**: enable/disable each memory (the switch on the right of every row — a disabled memory stays on disk and is simply left out of the prompt), edit, and move to trash; the "Trash" button in the page header can **restore** or **permanently delete** removed memories, with a confirmation step before the permanent delete. `enabled` and friends live in the sidecar index and are never written back to your files.
132
+ - **Injection budget is visible**: a budget bar (used / max bytes) sits under the summary and turns red with an "Over budget" label. Default cap 64 KiB; when one memory does not fit it is **skipped** while smaller ones behind it are still included, and the section tail carries a "not injected (over budget)" list — both the model and you can see what was left out instead of losing it silently.
133
+ - **`~/.dsh/AGENTS.md` is no longer written**: the old "always layer" is gone; the shared baseline now lives in `_shared/` and flows through the system-prompt section.
134
+
135
+ #### Caching and refresh (§5.2)
136
+
137
+ | Situation | Is the prefix stable? | Result |
138
+ |---|---|---|
139
+ | Scene set unchanged, memory files unchanged | byte-for-byte stable | ✅ prompt prefix cache hits |
140
+ | Enabling/disabling a scene (explicit action) | changes once | ⚠️ that session re-warms once — acceptable |
141
+ | Editing a memory (page or editor) | changes once | ⚠️ same, and it takes effect on the **next request** |
142
+ | Timestamps / counts / relative time in the section | changes every request | ❌ forbidden (and absent from the implementation) |
143
+
144
+ The implementation uses a **two-phase scan with a fingerprint cache**: each assembly only walks
145
+ directories with `stat` to build a fingerprint (no body reads) and reuses the previous rendering
146
+ when it is unchanged; only a changed fingerprint (scene toggle, file edit, enable/disable) triggers
147
+ reading bodies and re-rendering. **`fs.watch` is deliberately not used** — recursive watching is
148
+ unreliable on Windows, and a silently dead watcher would return stale content forever; the
149
+ fingerprint probe costs sub-milliseconds and buys "always fresh, never silently stale".
150
+
151
+ #### Upgrade note: the folder was renamed
152
+
153
+ Since v0.3 the default folder is `~/.dsh/scene-memory/`; the plugin **neither reads nor migrates** the
154
+ old `~/.dsh/rules/` automatically. Just move your content over (instant on the same volume):
155
+
156
+ ```sh
157
+ # Windows PowerShell
158
+ Move-Item ~/.dsh/rules ~/.dsh/scene-memory
159
+ # macOS / Linux
160
+ mv ~/.dsh/rules ~/.dsh/scene-memory
161
+ ```
162
+
163
+ If the new folder already exists, move the **scene subfolders** one by one instead; `_shared/` is an
164
+ ordinary scene folder and moves along with the rest.
165
+
166
+ ### Let the model and scripts help
167
+
168
+ | Entry point | What it does |
169
+ |---|---|
170
+ | `/mcp`, `/skills`, `/agents-md`, `/scene-memory` | Check the current state from the chat box |
171
+ | `skill_mcp_manager_list / set_enabled / restart / add` | Let the model query and operate MCP servers |
172
+ | `skill_manager_list / set_enabled / create` | Let the model query and operate skills (creating asks for your consent) |
173
+ | `rule_manager_list / read / write` | Let the model query and write rules (writes ask for your consent; can be disabled in settings) |
174
+ | `POST /dsh-plugin-tool-management/api` | HTTP API for scripts (`{op, args}` protocol) |
175
+
176
+ ## Configuration & security
177
+
178
+ Optional fields on the plugin loader row (`dsh plugin add` inserts it automatically):
179
+
180
+ | Field | Description |
181
+ |---|---|
182
+ | `token` | Optional access token. When set, **every write operation and "Reveal"** requires the `x-dsh-token` header. The client reads it from localStorage (key `dsh-plugin-tool-management-token`; set it in the DevTools console and refresh), or via the `DSH_PLUGIN_TOOL_MANAGEMENT_TOKEN` environment variable. |
183
+ | `maxBodyBytes` | Request body cap, default 88 MiB (skill ZIP uploads need it). |
184
+
185
+ Why a token: the cross-site protection (POST-only + custom header + same-origin check) assumes DSH listens on localhost only. If you forward the port to a LAN or the public internet, the token is the last line of defense against strangers injecting MCP commands (equivalent to remote code execution) and reading plaintext secrets — not needed for local single-user setups.
186
+
187
+ ## Where data lives
188
+
189
+ | Content | Location |
190
+ |---|---|
191
+ | MCP server definitions | `profiles/<profile>/cordis.patch.yml` (project) or `~/.dsh/cordis.patch.yml` (global), auto-`.bak` before every rewrite |
192
+ | Server notes / page settings / disabled tools / export | Sidecar JSON files under the DSH home (`dsh-plugin-tool-management-*.json`) |
193
+ | Skill toggle policy / custom directories | `~/.dsh/tool-management/state.json` |
194
+ | Skill recycle bin / import staging | `~/.dsh/tool-management/trash`, `uploads` |
195
+ | AGENTS.md presets / applied file | Plugin dir `data/agents-md-presets/`; "Apply" writes `~/.dsh/AGENTS.md` |
196
+ | Archived session ledger / retention | Plugin dir `data/history-archived-at.json`, `data/history-retention.json` |
197
+ | Rule files (source of truth) | `~/.dsh/scene-memory/<scene>/<name>.md` (flat) or `<scene>/<name>/SKILL.md` (bundle); scene folder names may be non-ASCII |
198
+ | Rule index / enabled scenes | `~/.dsh/tool-management/rules-index.json` (`enabled` / order / tags + `active` enabled-scene set; `active: null` = all scenes enabled) |
199
+ | Rule recycle bin | `~/.dsh/tool-management/rules-trash/<trashId>/` (deleted memories land here and can be restored) |
200
+ | Runtime log | `~/.dsh/dsh-plugin-tool-management.log` (rolling) |
201
+
202
+ ## FAQ
203
+
204
+ | Symptom | Fix |
205
+ |---|---|
206
+ | Pages missing in Settings after install | Hard refresh; if that fails, restart DSH once. |
207
+ | Duplicate MCP tabs / duplicated tools | Stale loader row double-mounting the plugin — remove the old entry from `cordis.patch.yml` and restart. |
208
+ | Broken config, DSH won't boot | Restore the newest `cordis.patch.yml.bak-<timestamp>` next to it. |
209
+ | Page data not refreshing | Wait for the automatic polling (default 5s) or click "Refresh". |
210
+ | Latest version not found on a mirror | Add `--registry=https://registry.npmjs.org` and retry later. |
211
+
212
+ ## Development
213
+
214
+ ```bash
215
+ npm install
216
+ npm run build # build (tsc + sync client bundle)
217
+ npm run build:client # sync src/client.js → lib/client.js only
218
+ npm run lint # syntax self-check (node --check on both artifacts)
219
+ ```
220
+
221
+ > This project keeps no test suite. Changes are verified by **actually exercising the real
222
+ > behaviour** (see the acceptance items in the change requests under `docs/`) instead of asserting
223
+ > what the code currently does — the latter just copies the implementation and passes by construction.
224
+
225
+ Layout: host half `src/index.ts` (object-form Cordis plugin, `lib/index.js` is the shipped artifact); skill core `src/skills/core.js` (pure Node); AGENTS.md presets `src/agents-md/service.ts`; archived session management `lib/history/` (`workspace.js` / `projcache.js` / `tombstone.js`); transcript import parsing `src/imports/parsers.js`; scene-memory store `src/rules/` (`service.ts` discovery/CRUD/index/checkup/two-phase section render, `provider.ts` per-agent `systemPrompt` section registration; the module path and `rules-*` op names stay as internal protocol, while the user-visible page and folder became “Scene Memory” / `scene-memory/`); browser half `src/client.js` (ModuleLoader CJS bundle, `dsm-*` design system, talks to the host through the same-origin API). The only runtime dependency is `fflate` (ZIP extraction).
226
+
227
+ Publish: `npm version patch && npm publish` (`prepublishOnly` builds automatically).
228
+
229
+ ## License
230
+
231
+ MIT
package/cordis.patch.yml CHANGED
@@ -25,7 +25,25 @@
25
25
  # short-circuits on every unrelated entry (e.g. dsh-better-sidebar's own
26
26
  # guard), so `!e.disabled` is only ever read on a genuinely matching
27
27
  # legacy/aggregate row (a plain boolean, no re-entry).
28
+ # 折叠 dsh-archive-manager:替换官方 workspace 与 session-projection-cache
29
+ # 服务为归档感知子类(永久删除 + unarchive + 批量 + archivedAt 保留期账本)。
30
+ # 官方 ui-workspace 保持启用;归档菜单仍由官方 UI 提供,删除/恢复/保留期
31
+ # 由本插件的 TOOLS → History 页面经 HTTP API 驱动。
32
+ #
33
+ # 冲突告警:不要同时安装独立的 @michengai/dsh-archive-manager——两个补丁都
34
+ # 禁用官方 workspace 行并插入替换,会导致重复服务注册、启动失败。
35
+ - id: workspace
36
+ disabled: true
37
+ - id: session-projection-cache
38
+ disabled: true
28
39
  - insert:
29
40
  - id: dsh-plugin-tool-management
30
41
  name: 'dsh-plugin-tool-management'
31
42
  disabled: !!js "[...ctx.loader.entries()].some((e) => e.options.id !== 'dsh-plugin-tool-management' && e.options.name === 'dsh-plugin-tool-management' && !e.disabled)"
43
+ - id: workspace-tool-management-history
44
+ name: 'dsh-plugin-tool-management/workspace'
45
+ - id: session-projection-cache-tool-management-history
46
+ name: 'dsh-plugin-tool-management/projcache'
47
+ config:
48
+ writeEveryEvents: 200
49
+ writeIntervalMs: 5000
Binary file
Binary file
Binary file
Binary file