dsh-efm-integration 0.4.1 → 0.4.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.
package/README.md CHANGED
@@ -1,348 +1,367 @@
1
- # dsh-efm-integration
2
-
3
- English | [简体中文](README.zh.md)
4
-
5
- `dsh-efm-integration` is a DeepSeek Harness (DSH) plugin bundle that adds coding
6
- discipline, skill routing, verification, and archived-session maintenance to the
7
- same underlying model. It does not replace the model, fork DSH, or modify the
8
- upstream DeepSeek Harness checkout.
9
-
10
- ## What it adds
11
-
12
- | Module | Behavior |
13
- | --- | --- |
14
- | `prompt` | Adds an action-first coding contract to the system prompt. |
15
- | `skill-router` | Publishes `whenToUse` routing hints and injects `always-load` or resident skill bodies, deduplicating unchanged content. |
16
- | `skill-guard` | Denies configured tools until their required skills have been loaded. |
17
- | `verification` | Emits one corrective steer when a turn edits files without running a recognized verification command. |
18
- | `command-guard` | Refuses long foreground sleeps and filesystem-root scans before execution. |
19
- | `bundled-skill` | Ships the `powershell-usage` skill and exposes it without a user-directory copy. |
20
- | `archive-cleaner` | Adds a sidebar page that permanently deletes archived Sessions and their descendants. |
21
- | `lsp-servers` | Owns the DSH LSP stack and adds a sidebar page to enable or disable language servers without restarting. |
22
-
23
- All host plugins are mounted by `cordis.patch.yml`. `client.js` provides the web
24
- sidebar pages. The bundle's `dsh.bundle.patch` and `dsh.client` fields tell DSH how
25
- to load both halves.
26
-
27
- ## Requirements
28
-
29
- - DSH `>=0.2.2-rc.5 <0.3.0`
30
- - Node.js `>=24.9.0`
31
- - pnpm `10.18.3` when building from source
32
-
33
- ## Install
34
-
35
- From a local checkout:
36
-
37
- ```sh
38
- dsh plugin --profile web add /absolute/path/to/dsh-efm-integration
39
- ```
40
-
41
- From a Git repository:
42
-
43
- ```sh
44
- dsh plugin --profile web add github:<owner>/dsh-efm-integration
45
- ```
46
-
47
- Installing from a source checkout can run the package's `prepare` script, which
48
- builds `lib/` with TypeScript. Review the source before allowing package build
49
- scripts to execute.
50
-
51
- Restart DSH, then inspect the composed profile:
52
-
53
- ```sh
54
- dsh --profile web --dump-config
55
- ```
56
-
57
- The profile should contain the `dsh-efm-integration-client-anchor` row and the
58
- other `dsh-efm-integration-*` plugin rows from `cordis.patch.yml`.
59
-
60
- ## System prompt
61
-
62
- By default the `prompt` module appends one section — the coding-agent execution
63
- contract — to the system prompt DSH assembles. To send a complete system prompt
64
- of your own instead, set exactly one of `prompt` (inline text) or `promptFile`
65
- (a UTF-8 file path) on the plugin row:
66
-
67
- ```yaml
68
- - id: dsh-efm-integration-prompt
69
- name: 'dsh-efm-integration/prompt'
70
- config:
71
- promptFile: 'D:/prompts/system.md'
72
- ```
73
-
74
- The configured text then **replaces every system-prompt section**: DSH's
75
- first-party guidance, the harness identity opener, and this bundle's execution
76
- contract are all dropped. Three things are deliberately unaffected:
77
-
78
- - **Tool schemas** are still assembled and sent, so the model keeps its tools.
79
- - **Runtime context** such as the current-directory snapshot is delivered as
80
- user-role context and is not part of the replaced text.
81
- - **The text is not interpolated.** `{{…}}` stays literal, so a prompt that
82
- documents template syntax cannot break assembly.
83
-
84
- Setting both keys, an empty `prompt`, a missing `promptFile`, or an empty file
85
- fails at plugin load time. Sections from other plugins (skills, MCP
86
- instructions, LSP guidance) are dropped as well, so a replacement prompt is
87
- responsible for any guidance the model still needs.
88
-
89
- ## Skill routing
90
-
91
- The stock DSH catalog exposes a skill's `name` and `description`. This bundle adds
92
- a routing supplement containing `whenToUse`, which is often more specific than the
93
- short description.
94
-
95
- Keep a skill active for the whole session with frontmatter:
96
-
97
- ```yaml
98
- metadata:
99
- always-load: true
100
- ```
101
-
102
- Or configure resident skills explicitly:
103
-
104
- ```yaml
105
- - id: dsh-efm-integration-skill-router
106
- config:
107
- residentSkills:
108
- - engineer-style
109
- - project-conventions
110
- maxTriggerChars: 500
111
- ```
112
-
113
- Resident content and the routing supplement are deduplicated by digest against
114
- visible session history, so unchanged instructions are not injected again on the
115
- next step.
116
-
117
- ## Bundled PowerShell skill
118
-
119
- `powershell-usage` is packaged under `skills/powershell-usage/`, including its
120
- syntax and version-difference references. It is marked `always-load`, so its
121
- instructions are available before the first tool decision.
122
-
123
- ## Skill guard
124
-
125
- `skill-guard` enforces prerequisites at `tools/pre-execute`. The default bundle
126
- rule requires `powershell-usage` before the `pwsh` tool:
127
-
128
- ```yaml
129
- requiredSkillsByTool:
130
- pwsh:
131
- - powershell-usage
132
- ```
133
-
134
- A denied call receives the exact skill name and must retry after loading it. A
135
- successful `skill` call, an explicit user skill invocation, a resident skill
136
- injection, or a matching event in resumed session history satisfies the guard.
137
- Additional tool/skill pairs can be added under the same configuration key.
138
-
139
- ## Verification gate
140
-
141
- The gate recognises successful `write`, `edit`, `apply_patch`, and
142
- `str_replace_editor` calls. If a turn stops after a mutation without a recognised
143
- successful verification command, it emits one corrective steer.
144
-
145
- The default command pattern covers npm/pnpm/yarn/bun `test`, `typecheck`, `lint`,
146
- and `build`, plus pytest, vitest, jest, Cargo test, Go test, .NET test, Maven test,
147
- and Gradle test. Override it for project-specific commands:
148
-
149
- ```yaml
150
- - id: dsh-efm-integration-verification
151
- config:
152
- mutationTools:
153
- - write
154
- - edit
155
- - apply_patch
156
- verificationCommandPattern: '(?:^|\s)(?:just\s+test|make\s+check)\b'
157
- maxRemindersPerTurn: 1
158
- ```
159
-
160
- The reminder is advisory and limited to one continuation per turn by default.
161
-
162
- ## Legacy session repair
163
-
164
- Earlier releases shipped `execution-budget` and `reasoning-budget` modules; both
165
- were removed in 0.4.0. The reasoning module once wrote
166
- `dsh-efm-integration/reasoning-replay` events, and DSH refuses to load a Session
167
- whose event type is outside its static catalog unless the event carries
168
- `ignorable: true`.
169
-
170
- If DSH reports such an event as "not marked ignorable", stop DSH and repair the
171
- affected Session file or the whole sessions directory:
172
-
173
- ```powershell
174
- node scripts/repair-reasoning-replay.mjs "$env:USERPROFILE\.dsh\sessions" --dry-run
175
- node scripts/repair-reasoning-replay.mjs "$env:USERPROFILE\.dsh\sessions"
176
- ```
177
-
178
- The utility adds `ignorable: true` to legacy reasoning-replay events, creates a
179
- timestamped `.bak-*` backup, and does not renumber events. Use the `DSH_HOME`
180
- sessions path instead when `DSH_HOME` is customized.
181
-
182
- ## Command guard
183
-
184
- `command-guard` refuses a foreground shell call before execution when it waits with
185
- `sleep`/`Start-Sleep` for at least `maxSleepSeconds`, or scans a filesystem root.
186
- Calls marked `run_in_background: true` are allowed by default.
187
-
188
- ```yaml
189
- - id: dsh-efm-integration-command-guard
190
- config:
191
- maxSleepSeconds: 30
192
- denyRootScans: true
193
- allowBackground: true
194
- extraDenyPatterns: []
195
- ```
196
-
197
- The denial names a supported alternative: a background job with `job_output`, an
198
- explicit `timeoutMs`, or a narrower path.
199
-
200
- ## Clear archived Sessions
201
-
202
- The web sidebar includes **清空全部存档会话**. It counts the archived root
203
- Sessions and all of their descendant Sessions. Deleting them requires browser
204
- confirmation and the server-side header
205
- `x-dsh-efm-integration-confirm: DELETE_ALL_ARCHIVED`.
206
-
207
- Deletion removes:
208
-
209
- - JSONL Session log directories for archived roots and their descendants;
210
- - the Sessions' Workspace accounting;
211
- - their entries in the global archive set.
212
-
213
- The operation refuses the whole batch if any target is running or has a live
214
- Agent, if persistence is not JSONL, or if a stored path does not follow the
215
- per-Session `session-*` directory convention. Workspace source files and shared
216
- attachments are preserved. After success the page reloads so the sidebar reflects
217
- the new Session catalog.
218
-
219
- ## Language servers (LSP)
220
-
221
- DSH ships an LSP stack (`@deepseek-ai/dsh-lsp`, `@deepseek-ai/dsh-lsp-stdio`,
222
- `@deepseek-ai/dsh-tool-lsp`) but mounts none of it: a deployment must supply the
223
- servers and the configuration. This bundle owns that stack. The `lsp-servers`
224
- module mounts the `ctx.lsp` seam, one stdio provider per enabled server, and the
225
- model-facing `lsp` tool.
226
-
227
- The seam offers exactly four read-only operations — `goToDefinition`,
228
- `findReferences`, `goToImplementation`, and `hover`. DSH deliberately excludes
229
- diagnostics, symbol lists, rename, and formatting, so this bundle does not add
230
- them either. Use `verification` (or a compiler) for correctness checks.
231
-
232
- ### Sidebar page
233
-
234
- The web sidebar includes **语言服务器**. It lists each built-in preset, whether its
235
- executable was found, and which launch line will be used, and lets you enable or
236
- disable any preset. Changes are written to
237
- `$DSH_HOME/plugins/dsh-efm-integration/lsp-servers.json` and take effect for
238
- subsequent queries without restarting DSH.
239
-
240
- | Preset | Extensions | Install |
241
- | --- | --- | --- |
242
- | `typescript` | `.ts .tsx .mts .cts .js .jsx .mjs .cjs` | `npm install -g typescript-language-server typescript` |
243
- | `python` | `.py .pyi` | `pip install pyright`, `npm install -g pyright`, or `pip install python-lsp-server` |
244
- | `cpp` | `.c .h .cpp .cc .cxx .hpp .hh .hxx` | put `clangd` on `PATH` |
245
- | `java` | `.java` | Eclipse JDT LS with `JDTLS_HOME` (and `JAVA_HOME`), or `jdtls` on `PATH` |
246
- | `rust` | `.rs` | `rustup component add rust-analyzer` |
247
- | `go` | `.go` | `go install golang.org/x/tools/gopls@latest` |
248
-
249
- No preset is enabled by default. Language-server processes are reclaimed when DSH
250
- exits; the page shows a restart hint instead of killing processes, because
251
- `dsh-lsp-stdio` owns the pooled servers and a hard kill would leave them running.
252
-
253
- ### Configuration
254
-
255
- ```yaml
256
- - id: dsh-efm-integration-lsp-servers
257
- config:
258
- # Presets to start enabled when the store has no entry for them yet.
259
- presets: []
260
- # `lazy` keeps the lsp tool out of the model's tool list until a provider is
261
- # live; `always` mounts it permanently.
262
- toolMount: lazy
263
- # Refuse sidebar entries that name an arbitrary executable.
264
- allowCustomServers: false
265
- # Pin a launch line instead of probing PATH.
266
- launchOverrides:
267
- typescript:
268
- command: node
269
- args: ['C:/Users/you/AppData/Roaming/npm/node_modules/typescript-language-server/lib/cli.mjs', '--stdio']
270
- tool:
271
- maxLocations: 100
272
- maxResultChars: 16000
273
- timeoutMs: 60000
274
- ```
275
-
276
- ### Security boundary
277
-
278
- The management route requires DSH authentication, an **owner** principal (API
279
- tokens are refused), a same-origin request, and the header
280
- `x-dsh-efm-integration-confirm: LSP_SERVER_CHANGE`.
281
-
282
- A language server runs with the filesystem and process authority of the mounted
283
- execution world, so the page cannot supply command lines unless
284
- `allowCustomServers` is turned on in the plugin config. Even then, entries that
285
- name a shell or script host (`cmd`, `powershell`, `pwsh`, `sh`, `bash`, `wscript`,
286
- `mshta`, `rundll32`), contain shell metacharacters, or span multiple lines are
287
- refused. Preset entries can never carry a command: they reference a built-in
288
- preset id only.
289
-
290
- ### Windows note
291
-
292
- The harness spawns without a shell, so an npm `.cmd` or `.ps1` shim cannot be
293
- launched directly, and PATH lookups only accept `.exe`/`.com` targets. Presets
294
- therefore read each installed package's own `package.json#bin` to find its
295
- JavaScript entry point and run it with the harness's Node binary, searching both
296
- every PATH directory and the sibling `lib/node_modules` of a `bin` directory.
297
- `launchOverrides` is the fallback when a server lives outside those locations.
298
-
299
- ## MCP tool loading
300
-
301
- DSH's MCP client supports deferred tool loading, but this bundle does not rewrite
302
- MCP server rows it does not own. To reduce MCP context, set `toolLoading:
303
- on-demand` on each large or infrequently used server:
304
-
305
- ```yaml
306
- - id: mcp
307
- config:
308
- servers:
309
- github:
310
- transport: stdio
311
- command: npx
312
- args: ['-y', '@modelcontextprotocol/server-github']
313
- toolLoading: on-demand
314
- ```
315
-
316
- Existing server entries keep DSH's default unless explicitly overridden. Keep
317
- credentials in DSH's credential provider rather than in this bundle or its files.
318
-
319
- ## Development
320
-
321
- ```powershell
322
- pnpm install # runs `prepare` and builds lib/
323
- pnpm test # all tests
324
- pnpm run typecheck # src/ and tests/
325
- pnpm run build # src/ -> lib/
326
- ```
327
-
328
- Run one test file:
329
-
330
- ```powershell
331
- pnpm exec vitest run tests/skill-guard.test.ts
332
- ```
333
-
334
- `lib/` is generated and not committed. `client.js` is maintained by hand; the
335
- client tests execute it directly in a VM. Before packaging, build first and then
336
- inspect the tarball:
337
-
338
- ```powershell
339
- pnpm pack --pack-destination .pack
340
- tar -tzf .pack/dsh-efm-integration-<version>.tgz
341
- ```
342
-
343
- The package should contain `lib/`, `client.js`, `cordis.patch.yml`, `skills/`,
344
- `scripts/`, `README.md`, `README.zh.md`, and `package.json`.
345
-
346
- ## License
347
-
348
- MIT
1
+ # dsh-efm-integration
2
+
3
+ English | [简体中文](README.zh.md)
4
+
5
+ `dsh-efm-integration` is a DeepSeek Harness (DSH) plugin bundle that adds coding
6
+ discipline, skill routing, and archived-session maintenance to the
7
+ same underlying model. It does not replace the model, fork DSH, or modify the
8
+ upstream DeepSeek Harness checkout.
9
+
10
+ ## What it adds
11
+
12
+ | Module | Behavior |
13
+ | --- | --- |
14
+ | `prompt` | Adds an action-first coding contract to the system prompt. |
15
+ | `skill-router` | Publishes `whenToUse` routing hints and injects `always-load` or resident skill bodies, deduplicating unchanged content. |
16
+ | `skill-guard` | Denies configured tools until their required skills have been loaded. |
17
+ | `command-guard` | Refuses long foreground sleeps and filesystem-root scans before execution. |
18
+ | `bundled-skill` | Ships the `powershell-usage` skill and exposes it without a user-directory copy. |
19
+ | `archive-cleaner` | Adds a sidebar page that permanently deletes archived Sessions and their descendants. |
20
+ | `lsp-servers` | Owns the DSH LSP stack and adds a sidebar page to enable or disable language servers without restarting. |
21
+
22
+ All host plugins are mounted by `cordis.patch.yml`. `client.js` provides the web
23
+ sidebar pages. The bundle's `dsh.bundle.patch` and `dsh.client` fields tell DSH how
24
+ to load both halves.
25
+
26
+ ## Requirements
27
+
28
+ - DSH `>=0.2.2-rc.5 <0.3.0`
29
+ - Node.js `>=24.9.0`
30
+ - pnpm `10.18.3` when building from source
31
+
32
+ ## Install
33
+
34
+ From npm (the published package, no build needed):
35
+
36
+ ```sh
37
+ dsh plugin --profile web add dsh-efm-integration
38
+ ```
39
+
40
+ `dsh plugin add` runs pnpm under the hood, so this resolves against the registry
41
+ your profile's pnpm uses. A freshly published version may take a while to reach
42
+ the npmmirror mirror; check with `pnpm view dsh-efm-integration version` or point
43
+ the profile at the official registry.
44
+
45
+ From a local checkout:
46
+
47
+ ```sh
48
+ dsh plugin --profile web add /absolute/path/to/dsh-efm-integration
49
+ ```
50
+
51
+ From a Git repository:
52
+
53
+ ```sh
54
+ dsh plugin --profile web add github:eyeofflame/dsh-efm-integration
55
+ ```
56
+
57
+ Installing from a source checkout can run the package's `prepare` script, which
58
+ builds `lib/` with TypeScript. Review the source before allowing package build
59
+ scripts to execute.
60
+
61
+ Restart DSH, then inspect the composed profile:
62
+
63
+ ```sh
64
+ dsh --profile web --dump-config
65
+ ```
66
+
67
+ The profile should contain the `dsh-efm-integration-client-anchor` row and the
68
+ other `dsh-efm-integration-*` plugin rows from `cordis.patch.yml`.
69
+
70
+ ## System prompt
71
+
72
+ By default the `prompt` module appends one section — the coding-agent execution
73
+ contract — to the system prompt DSH assembles. To send a complete system prompt
74
+ of your own instead, set exactly one of `prompt` (inline text) or `promptFile`
75
+ (a UTF-8 file path) on the plugin row:
76
+
77
+ ```yaml
78
+ - id: dsh-efm-integration-prompt
79
+ name: 'dsh-efm-integration/prompt'
80
+ config:
81
+ promptFile: 'D:/prompts/system.md'
82
+ ```
83
+
84
+ The configured text then **replaces every system-prompt section**: DSH's
85
+ first-party guidance, the harness identity opener, and this bundle's execution
86
+ contract are all dropped. Three things are deliberately unaffected:
87
+
88
+ - **Tool schemas** are still assembled and sent, so the model keeps its tools.
89
+ - **Runtime context** such as the current-directory snapshot is delivered as
90
+ user-role context and is not part of the replaced text.
91
+ - **The text is not interpolated.** `{{…}}` stays literal, so a prompt that
92
+ documents template syntax cannot break assembly.
93
+
94
+ Setting both keys, an empty `prompt`, a missing `promptFile`, or an empty file
95
+ fails at plugin load time. Sections from other plugins (skills, MCP
96
+ instructions, LSP guidance) are dropped as well, so a replacement prompt is
97
+ responsible for any guidance the model still needs.
98
+
99
+ ### Custom prompt sidebar and pure mode
100
+
101
+ The **系统提示词** sidebar page saves a replacement prompt at runtime. It is
102
+ stored under `$DSH_HOME/plugins/dsh-efm-integration/system-prompt.json` and
103
+ takes effect from the next model step without restarting DSH. **恢复默认**
104
+ deletes the saved file and restores the bundled contract. Text is limited to
105
+ 128 KiB (UTF-8).
106
+
107
+ The page also has an **agent preset** selector. The saved text can target one
108
+ DSH preset (`standard`, `minimal`, …) or **全部预设** (all presets, the original
109
+ global behavior). Only sessions using the target preset receive the replacement
110
+ and its pure-mode effects; other presets keep their own prompt, runtime context,
111
+ tools, and plugin injections. The selector lists the presets DSH currently
112
+ declares, hiding broken ones. A saved target that later disappears is reported
113
+ as unavailable and does not silently become global. Older single-prompt files
114
+ are migrated to the all-presets target.
115
+
116
+ A saved prompt activates **pure mode** for its target:
117
+
118
+ - The saved text becomes the only system prompt. Harness identity, skill
119
+ routing, MCP instructions, tool guidance, and other plugins' sections are not
120
+ sent.
121
+ - `skill-router` stops injecting user-role messages for those sessions.
122
+ - Optional runtime-context snapshots (for example the current directory) are
123
+ suppressed for those sessions.
124
+ - Tools are denied for agents using the target preset (or for every agent with
125
+ the all-presets target), so the model receives no tool schemas and cannot
126
+ execute tools.
127
+
128
+ Deployment configuration wins: if `prompt`/`promptFile` is set on the plugin
129
+ row, the page is read-only and the configured replacement keeps its original
130
+ global semantics (tools and runtime context remain). The management route
131
+ requires an owner principal, a same-origin request, and the header
132
+ `x-dsh-efm-integration-confirm: SYSTEM_PROMPT_CHANGE`.
133
+
134
+ Pure mode has three limits: DSH records prompt changes as `system/message`
135
+ events in the Session; tools registered directly in an agent's own scope are
136
+ not affected by the global denial, so absolute zero tools cannot be guaranteed;
137
+ and a step already in progress may have resolved its tool set. Do not put
138
+ secrets in the saved text — it is model-visible and logged.
139
+
140
+ ## Skill routing
141
+
142
+ The stock DSH catalog exposes a skill's `name` and `description`. This bundle adds
143
+ a routing supplement containing `whenToUse`, which is often more specific than the
144
+ short description.
145
+
146
+ Keep a skill active for the whole session with frontmatter:
147
+
148
+ ```yaml
149
+ metadata:
150
+ always-load: true
151
+ ```
152
+
153
+ Or configure resident skills explicitly:
154
+
155
+ ```yaml
156
+ - id: dsh-efm-integration-skill-router
157
+ config:
158
+ residentSkills:
159
+ - engineer-style
160
+ - project-conventions
161
+ maxTriggerChars: 500
162
+ ```
163
+
164
+ Resident content and the routing supplement are deduplicated by digest against
165
+ visible session history, so unchanged instructions are not injected again on the
166
+ next step.
167
+
168
+ ## Bundled PowerShell skill
169
+
170
+ `powershell-usage` is packaged under `skills/powershell-usage/`, including its
171
+ syntax and version-difference references. It is marked `always-load`, so its
172
+ instructions are available before the first tool decision.
173
+
174
+ ## Skill guard
175
+
176
+ `skill-guard` enforces prerequisites at `tools/pre-execute`. The default bundle
177
+ rule requires `powershell-usage` before the `pwsh` tool:
178
+
179
+ ```yaml
180
+ requiredSkillsByTool:
181
+ pwsh:
182
+ - powershell-usage
183
+ ```
184
+
185
+ A denied call receives the exact skill name and must retry after loading it. A
186
+ successful `skill` call, an explicit user skill invocation, a resident skill
187
+ injection, or a matching event in resumed session history satisfies the guard.
188
+ Additional tool/skill pairs can be added under the same configuration key.
189
+
190
+ ## Legacy session repair
191
+
192
+ Earlier releases shipped `execution-budget` and `reasoning-budget` modules; both
193
+ were removed in 0.4.0. The reasoning module once wrote
194
+ `dsh-efm-integration/reasoning-replay` events, and DSH refuses to load a Session
195
+ whose event type is outside its static catalog unless the event carries
196
+ `ignorable: true`.
197
+
198
+ If DSH reports such an event as "not marked ignorable", stop DSH and repair the
199
+ affected Session file or the whole sessions directory:
200
+
201
+ ```powershell
202
+ node scripts/repair-reasoning-replay.mjs "$env:USERPROFILE\.dsh\sessions" --dry-run
203
+ node scripts/repair-reasoning-replay.mjs "$env:USERPROFILE\.dsh\sessions"
204
+ ```
205
+
206
+ The utility adds `ignorable: true` to legacy reasoning-replay events, creates a
207
+ timestamped `.bak-*` backup, and does not renumber events. Use the `DSH_HOME`
208
+ sessions path instead when `DSH_HOME` is customized.
209
+
210
+ ## Command guard
211
+
212
+ `command-guard` refuses a foreground shell call before execution when it waits with
213
+ `sleep`/`Start-Sleep` for at least `maxSleepSeconds`, or scans a filesystem root.
214
+ Calls marked `run_in_background: true` are allowed by default.
215
+
216
+ ```yaml
217
+ - id: dsh-efm-integration-command-guard
218
+ config:
219
+ maxSleepSeconds: 30
220
+ denyRootScans: true
221
+ allowBackground: true
222
+ extraDenyPatterns: []
223
+ ```
224
+
225
+ The denial names a supported alternative: a background job with `job_output`, an
226
+ explicit `timeoutMs`, or a narrower path.
227
+
228
+ ## Clear archived Sessions
229
+
230
+ The web sidebar includes **清空全部存档会话**. It counts the archived root
231
+ Sessions and all of their descendant Sessions. Deleting them requires browser
232
+ confirmation and the server-side header
233
+ `x-dsh-efm-integration-confirm: DELETE_ALL_ARCHIVED`.
234
+
235
+ Deletion removes:
236
+
237
+ - JSONL Session log directories for archived roots and their descendants;
238
+ - the Sessions' Workspace accounting;
239
+ - their entries in the global archive set.
240
+
241
+ The operation refuses the whole batch if any target is running or has a live
242
+ Agent, if persistence is not JSONL, or if a stored path does not follow the
243
+ per-Session `session-*` directory convention. Workspace source files and shared
244
+ attachments are preserved. After success the page reloads so the sidebar reflects
245
+ the new Session catalog.
246
+
247
+ ## Language servers (LSP)
248
+
249
+ DSH ships an LSP stack (`@deepseek-ai/dsh-lsp`, `@deepseek-ai/dsh-lsp-stdio`,
250
+ `@deepseek-ai/dsh-tool-lsp`) but mounts none of it: a deployment must supply the
251
+ servers and the configuration. This bundle owns that stack. The `lsp-servers`
252
+ module mounts the `ctx.lsp` seam, one stdio provider per enabled server, and the
253
+ model-facing `lsp` tool.
254
+
255
+ The seam offers exactly four read-only operations — `goToDefinition`,
256
+ `findReferences`, `goToImplementation`, and `hover`. DSH deliberately excludes
257
+ diagnostics, symbol lists, rename, and formatting, so this bundle does not add
258
+ them either. Use a compiler for correctness checks.
259
+
260
+ ### Sidebar page
261
+
262
+ The web sidebar includes **语言服务器**. It lists each built-in preset, whether its
263
+ executable was found, and which launch line will be used, and lets you enable or
264
+ disable any preset. Changes are written to
265
+ `$DSH_HOME/plugins/dsh-efm-integration/lsp-servers.json` and take effect for
266
+ subsequent queries without restarting DSH.
267
+
268
+ | Preset | Extensions | Install |
269
+ | --- | --- | --- |
270
+ | `typescript` | `.ts .tsx .mts .cts .js .jsx .mjs .cjs` | `npm install -g typescript-language-server typescript` |
271
+ | `python` | `.py .pyi` | `pip install pyright`, `npm install -g pyright`, or `pip install python-lsp-server` |
272
+ | `cpp` | `.c .h .cpp .cc .cxx .hpp .hh .hxx` | put `clangd` on `PATH` |
273
+ | `java` | `.java` | Eclipse JDT LS with `JDTLS_HOME` (and `JAVA_HOME`), or `jdtls` on `PATH` |
274
+ | `rust` | `.rs` | `rustup component add rust-analyzer` |
275
+ | `go` | `.go` | `go install golang.org/x/tools/gopls@latest` |
276
+
277
+ No preset is enabled by default. Language-server processes are reclaimed when DSH
278
+ exits; the page shows a restart hint instead of killing processes, because
279
+ `dsh-lsp-stdio` owns the pooled servers and a hard kill would leave them running.
280
+
281
+ ### Configuration
282
+
283
+ ```yaml
284
+ - id: dsh-efm-integration-lsp-servers
285
+ config:
286
+ # Presets to start enabled when the store has no entry for them yet.
287
+ presets: []
288
+ # `lazy` keeps the lsp tool out of the model's tool list until a provider is
289
+ # live; `always` mounts it permanently.
290
+ toolMount: lazy
291
+ # Refuse sidebar entries that name an arbitrary executable.
292
+ allowCustomServers: false
293
+ # Pin a launch line instead of probing PATH.
294
+ launchOverrides:
295
+ typescript:
296
+ command: node
297
+ args: ['C:/Users/you/AppData/Roaming/npm/node_modules/typescript-language-server/lib/cli.mjs', '--stdio']
298
+ tool:
299
+ maxLocations: 100
300
+ maxResultChars: 16000
301
+ timeoutMs: 60000
302
+ ```
303
+
304
+ ### Security boundary
305
+
306
+ The management route requires DSH authentication, an **owner** principal (API
307
+ tokens are refused), a same-origin request, and the header
308
+ `x-dsh-efm-integration-confirm: LSP_SERVER_CHANGE`.
309
+
310
+ A language server runs with the filesystem and process authority of the mounted
311
+ execution world, so the page cannot supply command lines unless
312
+ `allowCustomServers` is turned on in the plugin config. Even then, entries that
313
+ name a shell or script host (`cmd`, `powershell`, `pwsh`, `sh`, `bash`, `wscript`,
314
+ `mshta`, `rundll32`), contain shell metacharacters, or span multiple lines are
315
+ refused. Preset entries can never carry a command: they reference a built-in
316
+ preset id only.
317
+
318
+ ### Windows note
319
+
320
+ The harness spawns without a shell, so an npm `.cmd` or `.ps1` shim cannot be
321
+ launched directly, and PATH lookups only accept `.exe`/`.com` targets. Presets
322
+ therefore read each installed package's own `package.json#bin` to find its
323
+ JavaScript entry point and run it with the harness's Node binary, searching both
324
+ every PATH directory and the sibling `lib/node_modules` of a `bin` directory.
325
+ `launchOverrides` is the fallback when a server lives outside those locations.
326
+
327
+ ## MCP tool loading
328
+
329
+ DSH's MCP client supports deferred tool loading, but this bundle does not rewrite
330
+ MCP server rows it does not own. To reduce MCP context, set `toolLoading:
331
+ on-demand` on each large or infrequently used server:
332
+
333
+ ```yaml
334
+ - id: mcp
335
+ config:
336
+ servers:
337
+ github:
338
+ transport: stdio
339
+ command: npx
340
+ args: ['-y', '@modelcontextprotocol/server-github']
341
+ toolLoading: on-demand
342
+ ```
343
+
344
+ Existing server entries keep DSH's default unless explicitly overridden. Keep
345
+ credentials in DSH's credential provider rather than in this bundle or its files.
346
+
347
+ ## Development
348
+
349
+ ```powershell
350
+ pnpm install # runs `prepare` and builds lib/
351
+ pnpm run build # src/ -> lib/
352
+ ```
353
+
354
+ `lib/` is generated and not committed. `client.js` is maintained by hand. Before
355
+ packaging, build first and then inspect the tarball:
356
+
357
+ ```powershell
358
+ pnpm pack --pack-destination .pack
359
+ tar -tzf .pack/dsh-efm-integration-<version>.tgz
360
+ ```
361
+
362
+ The package should contain `lib/`, `client.js`, `cordis.patch.yml`, `skills/`,
363
+ `scripts/`, `README.md`, `README.zh.md`, and `package.json`.
364
+
365
+ ## License
366
+
367
+ MIT