@bruc3van/dsh-doctor 0.5.2 → 0.5.4

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
@@ -2,243 +2,244 @@
2
2
 
3
3
  [中文](README.md) | English
4
4
 
5
- DSH Doctor is a diagnostic and recovery-decision tool for DSH upgrade incidents. For each plugin, it explains the incompatibility, the configuration layer that caused or amplified it, the preferred repair, and whether temporary isolation or removal can be proven safe enough to offer.
5
+ DSH Doctor helps an agent diagnose and upgrade DeepSeek Harness plugins: identify API changes between releases, modify code where the migration is known, point out semantic changes that need developer judgment, then rebuild and verify the plugin.
6
6
 
7
- This is a community-maintained third-party tool, not an official DeepSeek project. Normal diagnosis is read-only and never loads or executes inspected plugin code.
7
+ The current focus is:
8
8
 
9
- ## Install
10
-
11
- Node.js `22.19+` or `24+` is required:
12
-
13
- ```sh
14
- npm install --global @bruc3van/dsh-doctor
15
- dsh-doctor diagnose
16
- ```
17
-
18
- Or run without installing:
19
-
20
- ```sh
21
- npx @bruc3van/dsh-doctor diagnose
9
+ ```text
10
+ DSH 0.1.1 → DSH 0.1.2
22
11
  ```
23
12
 
24
- The default target is `$DSH_HOME/profiles/web`, falling back to `~/.dsh`. Use `--dsh-command /path/to/dsh` for a special installation or `--harness-root /path/to/deepseek-harness` for a source checkout.
13
+ The project also diagnoses DSH profiles and installed plugins, checks for compatible versions, and performs safety checks before quarantine or removal.
25
14
 
26
- ---
15
+ > This is a community-maintained third-party project, not an official DeepSeek project. The current catalog uses `dsh-v0.1.1-rc.2` and `dsh-v0.1.2-alpha.2` as the reference points for the 0.1.1-to-0.1.2 changes. An agent should still check actual differences when a plugin uses another patch or prerelease.
27
16
 
28
- ## Plugin migration: 0.1.1 0.1.2
17
+ ## Upgrade a plugin with the skill
29
18
 
30
- ### migrate commands
31
-
32
- Doctor ships a versioned `dsh-v0.1.1-rc.2 → dsh-v0.1.2-alpha.2` migration catalog and exposes three auditable stages:
19
+ Install the repository's [`dsh-plugin-upgrade`](skills/dsh-plugin-upgrade/SKILL.md) skill:
33
20
 
34
21
  ```sh
35
- # Stage 1: read-only analysis of source, type imports, manifest, client graph, and build artifacts
36
- dsh-doctor migrate analyze /path/to/plugin \
37
- --from dsh-v0.1.1-rc.2 \
38
- --to dsh-v0.1.2-alpha.2 \
39
- --harness-root /path/to/deepseek-harness
22
+ npx skills add bruc3van/dsh-doctor
23
+ ```
40
24
 
41
- # Stage 2: preview exact rewrites; add --yes to write and create timestamped backups
42
- dsh-doctor migrate apply /path/to/plugin --safe \
43
- --harness-root /path/to/deepseek-harness
44
- dsh-doctor migrate apply /path/to/plugin --safe --yes \
45
- --harness-root /path/to/deepseek-harness
25
+ Then ask the agent from inside the plugin repository:
46
26
 
47
- # Stage 3: static, build, and isolated runtime verification in order
48
- dsh-doctor migrate verify /path/to/plugin --level static \
49
- --harness-root /path/to/deepseek-harness
50
- dsh-doctor migrate verify /path/to/plugin --level build --yes \
51
- --harness-root /path/to/deepseek-harness
52
- dsh-doctor migrate verify /path/to/plugin --level runtime --yes \
53
- --harness-root /path/to/deepseek-harness
27
+ ```text
28
+ Upgrade this plugin from DSH 0.1.1 to DSH 0.1.2.
29
+ Analyze compatibility first, modify the code, then complete build and runtime verification.
54
30
  ```
55
31
 
56
- Run `dsh-doctor migrations list` to confirm the CLI contains this exact version pair before starting. Without a local install, `npx --package=@bruc3van/dsh-doctor dsh-doctor migrations list` works the same.
32
+ An upgrade request does not itself authorize dropping the old runtime. If the developer has not said, the skill explicitly asks whether the same upgraded plugin release must still support DSH 0.1.1 before any migration write, dependency installation, build, or runtime command. When compatibility must be preserved, the agent designs a dual-version approach first and verifies 0.1.1 and 0.1.2 separately; one successful 0.1.2 run is not dual-version evidence.
57
33
 
58
- ### Stage details
34
+ The skill reminds the agent to work in this order:
59
35
 
60
- **analyze**: Uses the TypeScript AST so it sees type-only imports that disappear from JavaScript bundles. Also checks package metadata, client graph declarations, and build artifacts. A clean bundle alone does not imply compatibility.
36
+ 1. inspect the plugin root, Harness checkout, package manager, and available DSH Doctor;
37
+ 2. analyze source, type imports, dependencies, manifest, client graph, patches, and build output;
38
+ 3. confirm whether the upgraded release targets only 0.1.2 or must remain compatible with 0.1.1;
39
+ 4. preview and apply code changes that are known to be equivalent under the selected compatibility strategy;
40
+ 5. use the new API owners to handle semantic changes that require understanding the plugin;
41
+ 6. rebuild the plugin and run static, build, and isolated runtime verification, covering both versions in dual-version mode;
42
+ 7. report the compatibility intent, changed files, remaining work, backups, and the verification level actually reached.
61
43
 
62
- **apply --safe**: Rewrites only catalog-confirmed exact-equivalent symbols, pins non-removed DSH development dependencies to the target version, and creates timestamped backups. It may add dependencies required by exact symbol moves but does not automatically change existing peer ranges. Session, Workspace, Conversation, and pending-interaction ownership changes are left as `MIG_SEMANTIC_API_CHANGE` and are never mechanically replaced.
44
+ `npx skills add` installs agent instructions only. It does not install DSH Doctor globally. The skill checks the local CLI and npm registry first. If the local version is unsuitable, it uses a pinned `npx` version by default and does not change the global npm installation.
63
45
 
64
- **verify**:
46
+ After verification, the agent can follow the plugin repository's existing versioning and release process if requested. The skill itself does not commit or publish anything automatically.
65
47
 
66
- | Level | What it does |
67
- |---|---|
68
- | `static` | Uses the TypeScript AST to inspect source/imports, manifest, client graph, and build artifacts without running project scripts |
69
- | `build` | Executes plugin build scripts and verifies the artifact (`build` or `pack:check` must succeed; `test`/`typecheck` alone is insufficient proof of a publishable artifact) |
70
- | `runtime` | Packs the real plugin tarball, installs it under a temporary `DSH_HOME` via the target CLI into a fresh web profile, verifies CLI version, profile manifest, installed package, activated bundle, effective config, and performs an activation smoke; never touches the normal `~/.dsh` |
48
+ ## How it works
71
49
 
72
- The highest achievable gate is `analyzed` → `source-migrated` → `artifact-verified` → `runtime-verified`. `runtime-verified` still does not prove real UI, lifecycle, or business behavior. Failed workspaces are retained and reported; successful ones are cleaned up by default.
50
+ DSH Doctor has three parts:
73
51
 
74
- ### Key API changes
52
+ - **Skill**: tells the agent which steps to follow, which actions need confirmation, and what to report;
53
+ - **CLI**: scans the plugin, lists problems, changes deterministic code, and runs verification;
54
+ - **Migration catalog**: records known package, API, Service, configuration, and behavior changes between the two DSH versions.
75
55
 
76
- `@deepseek-ai/dsh-client-runtime` was removed with **no aggregate replacement**. Capabilities migrate to:
56
+ The workflow is:
77
57
 
78
- | Concern | 0.1.2 owner | Migration |
79
- |---|---|---|
80
- | store engine and equality helpers | `dsh-client-store` | exact (catalog-listed symbols) |
81
- | Cordis client context type | `@deepseek-ai/cordis` `Context` | exact; preserve local aliases |
82
- | session control / list / commands | `dsh-api-session-controller/client` | semantic (developer judgment required) |
83
- | workspace state / commands | `dsh-api-workspace-controller/client` | semantic |
84
- | conversation assembly | `dsh-client-ui-conversation/client` | semantic |
85
- | pending-interaction state | domain UI packages aggregated by `ui-session` | semantic |
58
+ ```text
59
+ analyze
60
+ change deterministic code
61
+ agent handles semantic changes
62
+ rebuild
63
+ static verification
64
+ temporary-profile installation and activation
65
+ publish through the plugin's own release process
66
+ ```
86
67
 
87
- `@deepseek-ai/dsh-host-apiproxy` was also removed with no compatible substitute. Browser operations use their natural generated Remote owners through API Remotes/API Gateway contributions.
68
+ The CLI only auto-edits migrations marked `exact` by the catalog. Ownership and lifecycle changes involving Session, Workspace, Conversation, and pending interactions are reported as `MIG_SEMANTIC_API_CHANGE`. The agent must handle them in the context of the plugin instead of applying a mechanical replacement.
88
69
 
89
- ### dsh-plugin-upgrade skill
70
+ ## Why versioned rules are needed
90
71
 
91
- The package ships the [`dsh-plugin-upgrade` skill](skills/dsh-plugin-upgrade/SKILL.md) so coding agents (such as Claude Code) can drive the full migration workflow without collapsing any safety gate. The skill triggers when a plugin developer asks for migration, compatibility assessment, API replacement, peer dependency updates, artifact rebuilds, or DSH 0.1.2 runtime verification.
72
+ DSH 0.1.2 changes more than package versions:
92
73
 
93
- Install it directly from the GitHub repository into a supported coding agent:
74
+ - `@deepseek-ai/dsh-client-runtime` was removed and has no single aggregate replacement;
75
+ - store features moved to `dsh-client-store`;
76
+ - Session, Workspace, Conversation, and pending interactions moved to separate controllers or UI packages;
77
+ - `@deepseek-ai/dsh-host-apiproxy` was removed, so browser calls move to the appropriate business Remote;
78
+ - client graph, platform externals, exports, and some profile patch targets also changed.
94
79
 
95
- ```sh
96
- npx skills add bruc3van/dsh-doctor
97
- ```
80
+ The migration catalog stores source/target tags and Git commits together with package, symbol, Service, and configuration rules. With `--harness-root`, the CLI verifies the commits behind both tags and compares entry ids in the target web profile. This gives the agent concrete version differences instead of making it guess the new API.
98
81
 
99
- The repository currently exposes one skill, so the `skills` CLI discovers and installs `dsh-plugin-upgrade`; add `--skill dsh-plugin-upgrade` to select it explicitly. This installs the agent skill, not a global DSH Doctor CLI. The skill checks the local CLI version and target catalog, performs a read-only registry update check with `npm view`, and pins one exact npx version for all three phases when the local CLI is missing, outdated, or lacks the catalog. A global install or update always requires explicit user authorization.
82
+ ## Coverage
100
83
 
101
- ---
84
+ | Area | How Doctor and the agent handle it |
85
+ |---|---|
86
+ | JS/TS imports, including type-only, aliased, and mixed imports | Analyzed with the TypeScript AST; symbols with a known equivalent can be rewritten |
87
+ | Removed or added DSH packages | Checked in source and manifest; dependencies are updated only when no remaining reference blocks the change |
88
+ | DSH/Cordis version ranges | Checks dependencies, devDependencies, and peerDependencies; existing peer ranges are not widened automatically |
89
+ | Session, Workspace, Conversation, and other semantic changes | Reports the new owner and reason; the agent modifies the business code |
90
+ | `dsh.client` and client exports | Checks inject, external, platform, immediately, and `exports["./client"]` |
91
+ | Harness patch targets | Compares old and new entries when an exact Harness checkout is available |
92
+ | Build output | Scans `lib`, `dist`, `build`, and `out` for old APIs |
93
+ | Plugin build | Runs existing typecheck, build, test, and pack:check scripts; build or pack:check is required for artifact verification |
94
+ | Installation and activation | Packs the real tarball and installs it into a fresh web profile under a temporary `DSH_HOME` |
95
+ | UI and business behavior | Not decided by Doctor; the agent or developer runs plugin-specific checks |
102
96
 
103
- ## Diagnosis
97
+ Source analysis uses the TypeScript AST and is cross-checked against the manifest, client graph, and build output. A bundle without an old string does not prove that source code is compatible, and a successful compile does not prove that the published artifact or runtime is compatible.
104
98
 
105
- ### Diagnosis model
99
+ ## Safety
106
100
 
107
- `diagnose` composes the configuration from an empty tree in the same order as current DSH:
101
+ - `diagnose`, `migrate analyze`, and static verification are read-only and do not load or execute the inspected plugin;
102
+ - `migrate apply` requires `--safe`; without `--yes`, it only previews changes;
103
+ - only `exact` migrations are auto-edited; semantic changes are not guessed;
104
+ - SHA-256 is checked before writing, so a file changed after preview is rejected;
105
+ - existing files receive timestamped backups and are replaced atomically through a temporary file;
106
+ - build and runtime verification execute plugin scripts and therefore require explicit `--yes`;
107
+ - runtime verification uses a temporary `DSH_HOME`, not the normal `~/.dsh`;
108
+ - JSON, baselines, and recovery snapshots redact plugin configuration and common secret/token/password/key fields;
109
+ - global CLI installation, persistent quarantine, plugin removal, and publishing are never performed automatically by the skill.
108
110
 
109
- ```text
110
- bundle layers → profile cordis.patch.yml → home cordis.patch.yml → CLI overlays
111
- ```
112
-
113
- The JSON report retains `currentDefaultTree`, `currentEffectiveTree`, field-level provenance, replaced sources, and paths removed by whole-`config` replacement. It diagnoses:
111
+ ## Use the migration CLI manually
114
112
 
115
- - stale patches, missing targets, wrong name assertions;
116
- - duplicate entry ids and duplicate plugin mounts;
117
- - higher-layer disabling, structural replacement, whole group/config overrides;
118
- - bundle declaration conflicts with profile activation state;
119
- - plugin versions, artifacts, client contracts, dependencies, and runtime issues.
113
+ Node.js `^22.19.0` or `>=24.0.0` is required.
120
114
 
121
- Every `pluginDiagnoses[]` object keeps current `status` separate from `recovery`. Being removable does not make an incompatible plugin compatible.
115
+ First confirm that the CLI contains the required migration:
122
116
 
123
117
  ```sh
124
- dsh-doctor diagnose
125
- dsh-doctor diagnose --json
126
- dsh-doctor diagnose --check-updates
118
+ npx --yes --package=@bruc3van/dsh-doctor@0.5.4 \
119
+ dsh-doctor migrations list
127
120
  ```
128
121
 
129
- Only `--check-updates` and `recover` contact the npm registry. Offline diagnosis reports `update.status: "not-checked"` and never turns "not checked" into "no compatible version."
122
+ ### 1. Analyze
130
123
 
131
- ---
132
-
133
- ## Recovery decisions
124
+ ```sh
125
+ dsh-doctor migrate analyze /path/to/plugin \
126
+ --from dsh-v0.1.1-rc.2 \
127
+ --to dsh-v0.1.2-alpha.2 \
128
+ --harness-root /path/to/deepseek-harness \
129
+ --json
130
+ ```
134
131
 
135
- ### Compatible-version search
132
+ Analysis checks source, dependencies, manifest, client graph, patch targets, and existing build output without executing plugin code.
136
133
 
137
- Doctor checks all published manifests instead of trusting `latest`, then selects the highest version whose declared peer ranges accept the resolvable active DSH packages. This is a manifest-declared candidate only, not proof from a real startup or UI test.
134
+ ### 2. Apply
138
135
 
139
136
  ```sh
140
- dsh-doctor recover @scope/plugin --action check-update
141
- dsh-doctor recover @scope/plugin --action update # preview
142
- dsh-doctor recover @scope/plugin --action update --yes # exact version
137
+ # Preview
138
+ dsh-doctor migrate apply /path/to/plugin --safe \
139
+ --harness-root /path/to/deepseek-harness --json
140
+
141
+ # Write after confirmation
142
+ dsh-doctor migrate apply /path/to/plugin --safe --yes \
143
+ --harness-root /path/to/deepseek-harness --json
143
144
  ```
144
145
 
145
- ### Quarantine
146
+ Apply can split mixed imports, move exact symbols, leave semantic symbols in place, and update development dependencies when the change is known. Every changed file receives a backup.
146
147
 
147
- When no compatible release is available, generate and test a temporary overlay first:
148
+ ### 3. Verify
148
149
 
149
150
  ```sh
150
- dsh-doctor recover @scope/plugin --action quarantine
151
- dsh-doctor recover @scope/plugin --action quarantine --output ./plugin-quarantine.yml
152
- dsh --profile web --patch ./plugin-quarantine.yml
151
+ dsh-doctor migrate verify /path/to/plugin --level static \
152
+ --harness-root /path/to/deepseek-harness --json
153
+ dsh-doctor migrate verify /path/to/plugin --level build --yes \
154
+ --harness-root /path/to/deepseek-harness --json
155
+ dsh-doctor migrate verify /path/to/plugin --level runtime --yes \
156
+ --harness-root /path/to/deepseek-harness --json
153
157
  ```
154
158
 
155
- Doctor only generates an overlay when every active entry is precisely mapped, has a unique non-empty id and an exact name assertion, and the bundle does not rewrite entries owned by another layer. Core bundles, declared client dependents, and plugins statically detected as runtime Service providers with unproven dependents require manual review. The overlay disables all known active entries, causing both host and client sources to exit composition.
159
+ | Level | What it checks |
160
+ |---|---|
161
+ | `static` | Rechecks source, manifest, client graph, patches, and artifacts |
162
+ | `build` | Runs the plugin's existing build/test scripts and scans the output again |
163
+ | `runtime` | Packs the real tarball and checks the target DSH version, installed package, bundle, and effective configuration in a temporary profile |
156
164
 
157
- After testing the overlay, persistence is separately gated:
165
+ Verification states are:
158
166
 
159
- ```sh
160
- # Preview the exact diff first
161
- dsh-doctor recover @scope/plugin --action persist-quarantine --verified
162
-
163
- # Write to profile/cordis.patch.yml after explicit confirmation
164
- dsh-doctor recover @scope/plugin --action persist-quarantine --verified --yes
167
+ ```text
168
+ analyzed source-migrated artifact-verified → runtime-verified
165
169
  ```
166
170
 
167
- Persistence appends the final winning profile-layer disable override and refuses the write when a home or CLI overlay would still outrank it. It then recomposes the configuration and verifies every exact target is disabled; failed verification returns a nonzero exit code. The write rechecks SHA-256 and atomically replaces the profile patch. An existing patch gets a `.dsh-doctor-<timestamp>.bak`; a first-time file gets a `.rollback.json` containing its target and created-content hash, enabling deletion rollback only while the file is unchanged.
171
+ `runtime-verified` means that packing, installation, and basic activation passed. It does not replace real UI, Service lifecycle, and business-flow testing.
168
172
 
169
- Preview and explicitly restore that backup or rollback record:
173
+ ## Diagnose DSH and installed plugins
174
+
175
+ Global installation:
170
176
 
171
177
  ```sh
172
- dsh-doctor recover @scope/plugin --action rollback-quarantine \
173
- --backup /path/to/cordis.patch.yml.dsh-doctor-...bak
174
- dsh-doctor recover @scope/plugin --action rollback-quarantine \
175
- --backup /path/to/cordis.patch.yml.dsh-doctor-...bak --yes
178
+ npm install --global @bruc3van/dsh-doctor
179
+ dsh-doctor diagnose
176
180
  ```
177
181
 
178
- Doctor only accepts timestamped recovery files belonging to the selected profile patch.
179
-
180
- ### Safe removal
181
-
182
- Removal is always explicit and can never be inferred by legacy `--fix --yes`:
182
+ Temporary use:
183
183
 
184
184
  ```sh
185
- dsh-doctor recover @scope/plugin --action remove # impact preview
186
- dsh-doctor recover @scope/plugin --action remove --yes
185
+ npx @bruc3van/dsh-doctor diagnose
187
186
  ```
188
187
 
189
- Automatic removal requires a direct profile dependency, a readable lockfile, a non-core bundle, no manual mount or dangling patch that would remain, and a working current DSH CLI. Before the official command runs, Doctor saves a redacted diagnostic snapshot and quarantine overlay:
188
+ The default target is `$DSH_HOME/profiles/web`, falling back to `~/.dsh`.
190
189
 
191
190
  ```sh
192
- dsh plugin --profile web remove @scope/plugin
191
+ dsh-doctor diagnose
192
+ dsh-doctor diagnose --json
193
+ dsh-doctor diagnose --check-updates
193
194
  ```
194
195
 
195
- It then re-diagnoses dependency, bundle-layer, and active-entry absence and reports the exact rollback install command. Static analysis cannot prove the absence of dynamic Service dependencies, external data, or regressions in every real workflow. Restart the profile and validate its main functions after any bundle update or removal.
196
+ Diagnosis composes configuration in DSH order:
196
197
 
197
- ---
198
+ ```text
199
+ bundle layers → profile cordis.patch.yml → home cordis.patch.yml → CLI overlays
200
+ ```
198
201
 
199
- ## Baselines
202
+ It checks plugin versions and peers, Node engines, installation and lockfile state, bundles and patches, client contracts, duplicate mounts, higher-layer overrides, and DSH CLI/Harness version drift. Normal diagnosis does not use the network. Only `--check-updates` and recovery operations contact the npm registry.
200
203
 
201
- Save a baseline before upgrading, then compare plugin versions, compatibility state, Harness state, and finding changes afterwards:
204
+ ## Recovery operations
202
205
 
203
206
  ```sh
204
- dsh-doctor baseline create
205
- dsh-doctor baseline compare
207
+ # Check and install the highest manifest-declared compatible version
208
+ dsh-doctor recover @scope/plugin --action check-update
209
+ dsh-doctor recover @scope/plugin --action update
210
+ dsh-doctor recover @scope/plugin --action update --yes
206
211
 
207
- # Custom path
208
- dsh-doctor baseline create --output ./before-upgrade.json
209
- dsh-doctor baseline compare --output ./before-upgrade.json
210
- ```
212
+ # Create a temporary quarantine overlay
213
+ dsh-doctor recover @scope/plugin --action quarantine \
214
+ --output ./plugin-quarantine.yml
211
215
 
212
- The default baseline is `.dsh-doctor/baseline.json` inside the profile. It supplements current evidence and is never required for diagnosis.
216
+ # Persist it only after testing the temporary overlay
217
+ dsh-doctor recover @scope/plugin --action persist-quarantine --verified
218
+ dsh-doctor recover @scope/plugin --action persist-quarantine --verified --yes
213
219
 
214
- ## Legacy confirmed repairs
220
+ # Removal is always separate
221
+ dsh-doctor recover @scope/plugin --action remove
222
+ dsh-doctor recover @scope/plugin --action remove --yes
223
+ ```
215
224
 
216
- `--fix` and `--repair` remain compatible with deterministic 0.1.x install, update, and bundle-manifest repairs. They never quarantine or remove a plugin. File actions are hash-checked, backed up, and atomically replaced; commands use fixed argv and the selected `DSH_HOME`.
225
+ Before quarantine or removal, Doctor checks entry ownership, configuration layers, direct dependencies, core bundles, lockfile state, manual mounts, and known client dependents. Static checks cannot prove dynamic Service dependencies or external data safety, so restart the profile and test its main features afterwards.
226
+
227
+ You can also save and compare a baseline around an upgrade:
217
228
 
218
229
  ```sh
219
- dsh-doctor --fix
220
- dsh-doctor --fix --yes --json
230
+ dsh-doctor baseline create
231
+ dsh-doctor baseline compare
221
232
  ```
222
233
 
223
- ---
224
-
225
234
  ## Output and exit codes
226
235
 
227
- Text output supports Chinese and English. `--json` keeps stable English codes and complete non-secret evidence; plugin `config` values and other common secret fields are replaced with `[REDACTED]`.
236
+ Text output supports Chinese and English. `--json` uses stable English codes and keeps redacted structured evidence.
228
237
 
229
238
  | Exit code | Meaning |
230
239
  |---|---|
231
- | `0` | No blocking error, or an explicit action passed static verification |
232
- | `1` | A possible startup blocker remains, or recovery verification is incomplete |
233
- | `2` | Argument, environment, or action execution failure |
234
-
235
- ## Security boundaries
236
-
237
- - Does not execute third-party plugins or evaluate `!!js`; diagnosis parses configuration structure but redacts every plugin `config` value plus other common secret fields from JSON, baselines, and recovery snapshots; text reports do not print configuration values.
238
- - Registry compatibility is declarative only; it does not prove a real startup or UI test.
239
- - Dynamic Service dependencies, external side effects, real UI behavior, and business workflows require user validation.
240
- - Precise patch edits only operate on structures Doctor can safely parse and locate; ambiguous cases are refused automatically.
241
- - After adding, updating, or removing a bundle, a running profile does not automatically change its bundle set — a restart is required.
240
+ | `0` | No blocker remains, or the action completed and passed its verification |
241
+ | `1` | Compatibility issues, semantic migration, or verification work remains |
242
+ | `2` | Argument, environment, or action-execution failure |
242
243
 
243
244
  ## Development
244
245
 
@@ -248,4 +249,6 @@ npm run check
248
249
  npm pack --dry-run
249
250
  ```
250
251
 
251
- Publishing uses GitHub Actions OIDC and npm provenance. Local implementation and verification do not commit, tag, or publish automatically.
252
+ Tests cover the CLI, configuration composition, diagnosis, redaction, backups and write protection, AST migration, build gates, isolated runtime verification, and recovery operations. CI tests Node.js `22.19` and `24` on macOS, Ubuntu, and Windows.
253
+
254
+ Local development, the skill, and the CLI never commit, tag, or publish automatically.
package/README.md CHANGED
@@ -2,245 +2,246 @@
2
2
 
3
3
  中文 | [English](README.en.md)
4
4
 
5
- DSH Doctor 是面向 DSH 升级事故的诊断与恢复决策工具。它按插件回答:哪里不兼容、哪层配置造成或放大问题、首选修复是什么,以及暂时修不好时能否安全隔离或删除。
5
+ DSH Doctor 帮助 Agent 诊断和升级 DeepSeek Harness 插件:识别新旧版本之间的 API 变化,修改可以确定迁移的代码,提示需要开发者判断的语义变化,重新构建并验证插件。
6
6
 
7
- 这是社区维护的第三方工具,不属于 DeepSeek 官方项目。普通诊断完全只读,也不会加载或执行待检查插件的代码。
7
+ 当前主要面向:
8
8
 
9
- ## 安装
10
-
11
- 需要 Node.js `22.19+` 或 `24+`:
12
-
13
- ```sh
14
- npm install --global @bruc3van/dsh-doctor
15
- dsh-doctor diagnose
16
- ```
17
-
18
- 也可以临时运行:
19
-
20
- ```sh
21
- npx @bruc3van/dsh-doctor diagnose
9
+ ```text
10
+ DSH 0.1.1 → DSH 0.1.2
22
11
  ```
23
12
 
24
- 默认检查 `$DSH_HOME/profiles/web`;未设置 `DSH_HOME` 时使用 `~/.dsh`。特殊安装可用 `--dsh-command /path/to/dsh` 指定实际 CLI,源码工作区可用 `--harness-root /path/to/deepseek-harness`。
13
+ 项目同时提供 DSH profile 和插件的诊断、兼容版本检查、隔离与删除前检查。
25
14
 
26
- ---
15
+ > 这是社区维护的第三方工具,不属于 DeepSeek 官方项目。当前 catalog 以 `dsh-v0.1.1-rc.2` 和 `dsh-v0.1.2-alpha.2` 为基准记录 0.1.1 到 0.1.2 的变化;插件使用其他 patch 或预发布版本时,Agent 仍需核对实际差异。
27
16
 
28
- ## 插件迁移:0.1.1 0.1.2
17
+ ## 使用 Skill 升级插件
29
18
 
30
- ### migrate 命令
31
-
32
- Doctor 内置 `dsh-v0.1.1-rc.2 → dsh-v0.1.2-alpha.2` 的版本化迁移目录,并把升级拆成三个可审计阶段:
19
+ 安装仓库中的 [`dsh-plugin-upgrade`](skills/dsh-plugin-upgrade/SKILL.md) Skill:
33
20
 
34
21
  ```sh
35
- # 阶段 1:只读分析源码、类型导入、manifest、client graph 与构建产物
36
- dsh-doctor migrate analyze /path/to/plugin \
37
- --from dsh-v0.1.1-rc.2 \
38
- --to dsh-v0.1.2-alpha.2 \
39
- --harness-root /path/to/deepseek-harness
22
+ npx skills add bruc3van/dsh-doctor
23
+ ```
40
24
 
41
- # 阶段 2:预览精确改写;加 --yes 才写入并创建时间戳备份
42
- dsh-doctor migrate apply /path/to/plugin --safe \
43
- --harness-root /path/to/deepseek-harness
44
- dsh-doctor migrate apply /path/to/plugin --safe --yes \
45
- --harness-root /path/to/deepseek-harness
25
+ 然后在插件仓库中告诉 Agent:
46
26
 
47
- # 阶段 3:依次完成静态、构建和隔离运行时验证
48
- dsh-doctor migrate verify /path/to/plugin --level static \
49
- --harness-root /path/to/deepseek-harness
50
- dsh-doctor migrate verify /path/to/plugin --level build --yes \
51
- --harness-root /path/to/deepseek-harness
52
- dsh-doctor migrate verify /path/to/plugin --level runtime --yes \
53
- --harness-root /path/to/deepseek-harness
27
+ ```text
28
+ 请把当前插件从 DSH 0.1.1 升级到 DSH 0.1.2。
29
+ 先分析兼容问题,再修改代码,最后完成构建和运行时验证。
54
30
  ```
55
31
 
56
- 可用 `dsh-doctor migrations list` 确认当前 CLI 包含所需版本对;如未安装,`npx --package=@bruc3van/dsh-doctor dsh-doctor migrations list` 也可完成确认。
32
+ 升级请求本身不代表可以放弃旧版。若开发者没有说明,Skill 会在任何迁移写入、依赖安装、构建或运行时命令前,显式询问升级后的同一插件版本是否还要兼容 DSH 0.1.1。选择保留兼容时,Agent 会先设计双版本适配方式,并分别验证 0.1.1 0.1.2;不能用一次 0.1.2 验证代替双版本结论。
57
33
 
58
- ### 各阶段说明
34
+ Skill 会提醒 Agent 按下面的顺序工作:
59
35
 
60
- **analyze**:使用 TypeScript AST 扫描,能识别不会出现在 JavaScript bundle 中的 `import type`;同时检查 package 元数据、client graph 声明和构建产物,不因 bundle 干净就推断兼容。
36
+ 1. 检查插件目录、Harness checkout、包管理器和可用的 DSH Doctor;
37
+ 2. 分析源码、类型导入、依赖、manifest、client graph、patch 和构建产物;
38
+ 3. 确认升级后是仅支持 0.1.2,还是同一版本继续兼容 0.1.1;
39
+ 4. 预览并应用可以确定等价、且符合所选兼容策略的代码修改;
40
+ 5. 根据新的 API 所有者处理需要理解业务的语义迁移;
41
+ 6. 重新构建插件,并依次做静态、构建和隔离运行时验证;双版本模式分别验证两端;
42
+ 7. 报告兼容目标、修改内容、剩余问题、备份和实际达到的验证等级。
61
43
 
62
- **apply --safe**:只迁移 catalog 标记为精确等价的符号,将非移除的 DSH 开发依赖固定到目标版本,并创建时间戳备份。可能补充精确符号迁移所需的新依赖,但不会自动修改已有 peer 范围。Session、Workspace、Conversationpending interaction 属于所有权及生命周期变化,保留为 `MIG_SEMANTIC_API_CHANGE`,不做机械替换。
44
+ `npx skills add` 只安装 Agent 指令,不会安装全局 DSH Doctor。Skill 会先检查本地 CLInpm registry;本地版本不合适时,默认使用固定版本的 `npx`,不会自行修改全局 npm 安装。
63
45
 
64
- **verify**:
46
+ 验证完成后,可以再让 Agent 按插件仓库原有的版本和发布流程提交、打 tag、发布。Skill 本身不会自动提交或发布。
65
47
 
66
- | 级别 | 执行内容 |
67
- |---|---|
68
- | `static` | 使用 TypeScript AST 检查源码/import、manifest、client graph 与构建产物,不执行项目脚本 |
69
- | `build` | 执行插件构建脚本,验证产物(需 `build` 或 `pack:check` 成功;仅有 `test`/`typecheck` 不足以证明发布产物) |
70
- | `runtime` | 打真实 tarball,在临时 `DSH_HOME` 中通过目标 CLI 安装到全新 web profile,核验 CLI 版本、profile manifest、已安装包、bundle 激活与有效配置,执行激活 smoke;不触碰普通用户的 `~/.dsh` |
48
+ ## 工作方式
71
49
 
72
- 最高状态为 `analyzed` → `source-migrated` → `artifact-verified` → `runtime-verified`。`runtime-verified` 仍不能替代真实 UI、生命周期与业务行为的验证。失败现场会保留并报告路径;成功后默认清理。
50
+ DSH Doctor 由三部分组成:
73
51
 
74
- ### 主要 API 变化
52
+ - **Skill**:告诉 Agent 升级步骤、哪些操作需要确认,以及最后应该报告什么;
53
+ - **CLI**:扫描插件、生成问题清单、修改确定性代码,并执行分级验证;
54
+ - **Migration catalog**:记录两个 DSH 版本之间已确认的包、API、Service、配置和行为变化。
75
55
 
76
- `@deepseek-ai/dsh-client-runtime` 已移除,**没有聚合替代包**,各能力迁往:
56
+ 完整流程是:
77
57
 
78
- | 原能力 | 0.1.2 归属 | 迁移方式 |
79
- |---|---|---|
80
- | store 引擎与 equality helpers | `dsh-client-store` | 精确(catalog 已列举符号) |
81
- | Cordis 客户端 context 类型 | `@deepseek-ai/cordis` `Context` | 精确;保留本地别名 |
82
- | session 控制/列表/命令 | `dsh-api-session-controller/client` | 语义(需开发者判断) |
83
- | workspace 状态/命令 | `dsh-api-workspace-controller/client` | 语义 |
84
- | conversation 组装 | `dsh-client-ui-conversation/client` | 语义 |
85
- | pending interaction 状态 | ui-session 聚合的各 UI 包 | 语义 |
86
-
87
- `@deepseek-ai/dsh-host-apiproxy` 也已移除,无兼容替代,浏览器操作改用 API Remotes/API Gateway 原生 Remote 所有者。
58
+ ```text
59
+ 分析问题
60
+ 修改确定性代码
61
+ Agent 处理语义变化
62
+ 重新构建
63
+ 静态验证
64
+ 临时 profile 安装与激活验证
65
+ 按插件自己的流程发布
66
+ ```
88
67
 
89
- ### dsh-plugin-upgrade skill
68
+ CLI 只自动修改 catalog 标记为 `exact` 的迁移。Session、Workspace、Conversation、pending interaction 等所有权和生命周期变化会标记为 `MIG_SEMANTIC_API_CHANGE`,由 Agent 结合插件代码处理,不会机械替换。
90
69
 
91
- 包内同时提供 [`dsh-plugin-upgrade` skill](skills/dsh-plugin-upgrade/SKILL.md),供编码 Agent(如 Claude Code)驱动完整迁移流程,确保不折叠任何安全阶段门控。Skill 描述触发条件:插件开发者寻求迁移、兼容性评估、API 替换、peer 依赖更新、产物重建或 DSH 0.1.2 运行时验证。
70
+ ## 为什么需要版本化规则
92
71
 
93
- 可直接从 GitHub 仓库安装到本机支持的编码 Agent:
72
+ DSH 0.1.2 不只是包版本变化,一些能力被拆分到了新的所有者:
94
73
 
95
- ```sh
96
- npx skills add bruc3van/dsh-doctor
97
- ```
74
+ - `@deepseek-ai/dsh-client-runtime` 已移除,没有一个新的聚合包可以直接替换;
75
+ - store 能力迁移到 `dsh-client-store`;
76
+ - Session、Workspace、Conversation 和 pending interaction 分别由新的 controller 或 UI 包负责;
77
+ - `@deepseek-ai/dsh-host-apiproxy` 已移除,浏览器调用需要迁移到对应业务 Remote;
78
+ - client graph、platform external、exports 和部分 profile patch target 也发生了变化。
98
79
 
99
- 仓库当前只提供一个 skill,`skills` CLI 会发现并安装 `dsh-plugin-upgrade`;需要显式选择时可加 `--skill dsh-plugin-upgrade`。该命令只安装 Agent skill,不会全局安装 DSH Doctor CLI。Skill 会检查本地 CLI 版本和目标 catalog,通过只读 `npm view` 检查 registry 更新;本地 CLI 缺失、过期或缺少 catalog 时,默认固定一个精确版本并通过 `npx` 完成三阶段。全局安装或更新始终需要用户明确授权。
80
+ Migration catalog 保存 source/target tag Git commit,并记录 package、symbol、Service 和配置规则。提供 `--harness-root` 时,CLI 还会确认两个 tag 对应的 commit,并比较目标 web profile 中的 entry id。这样 Agent 可以基于明确的版本差异修改代码,而不是猜测新 API。
100
81
 
101
- ---
82
+ ## 覆盖范围
102
83
 
103
- ## 诊断
84
+ | 检查内容 | Doctor/Agent 如何处理 |
85
+ |---|---|
86
+ | JS/TS import,包括 `import type`、别名和混合 import | 使用 TypeScript AST 分析;确定等价的 symbol 可自动改写 |
87
+ | 移除或新增的 DSH 包 | 检查源码和 manifest;没有残留引用时更新依赖 |
88
+ | DSH/Cordis 版本范围 | 检查 dependencies、devDependencies 和 peerDependencies;不自动扩大已有 peer 范围 |
89
+ | Session、Workspace、Conversation 等语义变化 | 报告新 owner 和变化原因,由 Agent 修改业务代码 |
90
+ | `dsh.client` 和 client export | 检查 inject、external、platform、immediately 和 `exports["./client"]` |
91
+ | Harness patch target | 有精确 Harness checkout 时比较新旧 entry |
92
+ | 构建产物 | 检查 `lib`、`dist`、`build`、`out` 中是否仍包含旧 API |
93
+ | 插件构建 | 运行项目已有的 typecheck、build、test、pack:check;必须有 build 或 pack:check 才算产物已验证 |
94
+ | 安装和激活 | 打包真实 tarball,安装到临时 `DSH_HOME` 的新 web profile 中验证 |
95
+ | UI 和业务行为 | Doctor 不自动判断;需要 Agent 或开发者执行插件自己的测试 |
104
96
 
105
- ### 诊断模型
97
+ 源码分析使用 TypeScript AST,并同时检查 manifest、client graph 和构建产物。因此,bundle 中没有旧字符串并不代表源码已经兼容,源码编译通过也不代表发布产物和运行时已经兼容。
106
98
 
107
- `diagnose` 从空树开始,按当前 DSH 的正式顺序组合配置:
99
+ ## 安全性
108
100
 
109
- ```text
110
- bundle layers profile cordis.patch.yml home cordis.patch.yml → CLI overlays
111
- ```
101
+ - `diagnose`、`migrate analyze` 和静态验证只读,不加载或执行待检查插件;
102
+ - `migrate apply` 必须带 `--safe`,没有 `--yes` 时只展示将要修改的内容;
103
+ - 只有 `exact` 迁移会自动改代码,语义变化不会自动猜测;
104
+ - 写入前检查文件 SHA-256,预览后文件发生变化会拒绝写入;
105
+ - 修改已有文件前创建时间戳备份,并使用临时文件原子替换;
106
+ - build 和 runtime 会执行插件脚本,因此必须显式使用 `--yes`;
107
+ - runtime 使用临时 `DSH_HOME`,不会安装到正常的 `~/.dsh`;
108
+ - JSON、baseline 和恢复快照会脱敏插件配置和常见 secret/token/password/key 字段;
109
+ - 全局 CLI 安装、持久隔离、删除插件和发布都不会由 Skill 自动执行。
112
110
 
113
- JSON 同时保留 `currentDefaultTree`、`currentEffectiveTree`、字段级来源、被替换来源和 `config` 整体替换时丢失的字段路径。重点识别:
111
+ ## 手动使用迁移 CLI
114
112
 
115
- - patch、缺失 target、错误 name assertion;
116
- - 重复 entry id、重复插件 mount;
117
- - 高层禁用、结构替换、group/config 整体覆盖;
118
- - bundle 声明与 profile 激活状态冲突;
119
- - 插件版本、产物、client contract、依赖与运行环境问题。
113
+ 需要 Node.js `^22.19.0` `>=24.0.0`。
120
114
 
121
- 每个 `pluginDiagnoses[]` 都把当前 `status` 与可选 `recovery` 分开。插件即使能够隔离或删除,也不会因此被标记为已经兼容。
115
+ 先确认 CLI 包含需要的迁移:
122
116
 
123
117
  ```sh
124
- dsh-doctor diagnose
125
- dsh-doctor diagnose --json
126
- dsh-doctor diagnose --check-updates
118
+ npx --yes --package=@bruc3van/dsh-doctor@0.5.4 \
119
+ dsh-doctor migrations list
127
120
  ```
128
121
 
129
- 只有 `--check-updates` 和 `recover` 会访问 npm registry。离线诊断只报告 `update.status: "not-checked"`,绝不会把"未检查"写成"没有兼容版本"。
130
-
131
- ---
122
+ ### 1. 分析
132
123
 
133
- ## 恢复决策
124
+ ```sh
125
+ dsh-doctor migrate analyze /path/to/plugin \
126
+ --from dsh-v0.1.1-rc.2 \
127
+ --to dsh-v0.1.2-alpha.2 \
128
+ --harness-root /path/to/deepseek-harness \
129
+ --json
130
+ ```
134
131
 
135
- ### 兼容版本检查
132
+ 分析会检查源码、依赖、manifest、client graph、patch target 和已有构建产物,不执行插件代码。
136
133
 
137
- Doctor 会检查所有已发布版本的 manifest,而不是只看 `latest`,并选出声明兼容当前可解析 DSH package 版本的最高版本。结论仅表示"manifest 声明兼容的候选版本",不代表已经通过真实启动或 UI 验证。
134
+ ### 2. 修改
138
135
 
139
136
  ```sh
140
- dsh-doctor recover @scope/plugin --action check-update
141
- dsh-doctor recover @scope/plugin --action update # 只预览
142
- dsh-doctor recover @scope/plugin --action update --yes # 执行精确版本
137
+ # 预览
138
+ dsh-doctor migrate apply /path/to/plugin --safe \
139
+ --harness-root /path/to/deepseek-harness --json
140
+
141
+ # 确认后写入
142
+ dsh-doctor migrate apply /path/to/plugin --safe --yes \
143
+ --harness-root /path/to/deepseek-harness --json
143
144
  ```
144
145
 
145
- ### 临时与持久隔离
146
+ Apply 可以拆分混合 import、移动精确 symbol、保留语义 symbol,并更新确定可以调整的开发依赖。每个被修改的文件都会保留备份。
146
147
 
147
- 没有兼容版本时,默认先生成临时 overlay,再用实际 profile 验证其余功能:
148
+ ### 3. 验证
148
149
 
149
150
  ```sh
150
- dsh-doctor recover @scope/plugin --action quarantine
151
- dsh-doctor recover @scope/plugin --action quarantine --output ./plugin-quarantine.yml
152
- dsh --profile web --patch ./plugin-quarantine.yml
151
+ dsh-doctor migrate verify /path/to/plugin --level static \
152
+ --harness-root /path/to/deepseek-harness --json
153
+ dsh-doctor migrate verify /path/to/plugin --level build --yes \
154
+ --harness-root /path/to/deepseek-harness --json
155
+ dsh-doctor migrate verify /path/to/plugin --level runtime --yes \
156
+ --harness-root /path/to/deepseek-harness --json
153
157
  ```
154
158
 
155
- 只有所有活跃 entry 均能精确定位、都有唯一非空 id、name assertion 明确,且 bundle 没有改写其他来源 entry 时,Doctor 才会生成 overlay。核心 bundle、存在 client 依赖者或静态检测到提供运行时 Service 但无法证明依赖关系的插件都要求人工审查。overlay 会禁用插件所有已知活跃 entry,使 host 与 client 来源同时退出组合。
159
+ | 级别 | 验证内容 |
160
+ |---|---|
161
+ | `static` | 再次检查源码、manifest、client graph、patch 和产物 |
162
+ | `build` | 运行插件已有的构建与测试脚本,并在构建后重新扫描产物 |
163
+ | `runtime` | 打真实 tarball,在临时 profile 中验证目标 DSH 版本、安装包、bundle 和生效配置 |
156
164
 
157
- 验证完成后才可持久化:
165
+ 验证状态依次是:
158
166
 
159
- ```sh
160
- # 先预览精确差异
161
- dsh-doctor recover @scope/plugin --action persist-quarantine --verified
162
-
163
- # 明确确认后写入 profile/cordis.patch.yml
164
- dsh-doctor recover @scope/plugin --action persist-quarantine --verified --yes
167
+ ```text
168
+ analyzed → source-migrated → artifact-verified → runtime-verified
165
169
  ```
166
170
 
167
- 持久写入会追加 profile 层最终生效的禁用覆盖;如果 home 或 CLI overlay 等更高层仍会覆盖它,Doctor 会在写入前拒绝。写入后重新组合配置并逐个验证目标 entry 确实处于 disabled 状态;验证失败会返回非零退出码。写入前重新校验 SHA-256 并原子替换文件。已有 patch 会创建 `.dsh-doctor-<timestamp>.bak`;首次新建 patch 会创建 `.rollback.json`,其中记录目标文件和创建内容哈希,以便只在文件未被再次修改时执行删除式回滚。
171
+ `runtime-verified` 只表示插件能够完成打包、安装和基本激活,仍不能代替真实 UI、Service 生命周期和业务流程验证。
172
+
173
+ ## DSH 和已安装插件诊断
168
174
 
169
- 可先预览并显式恢复备份或回滚记录:
175
+ 全局安装:
170
176
 
171
177
  ```sh
172
- dsh-doctor recover @scope/plugin --action rollback-quarantine \
173
- --backup /path/to/cordis.patch.yml.dsh-doctor-...bak
174
- dsh-doctor recover @scope/plugin --action rollback-quarantine \
175
- --backup /path/to/cordis.patch.yml.dsh-doctor-...bak --yes
178
+ npm install --global @bruc3van/dsh-doctor
179
+ dsh-doctor diagnose
176
180
  ```
177
181
 
178
- Doctor 只接受属于当前 profile patch 的时间戳恢复文件。
179
-
180
- ### 安全删除
181
-
182
- 删除是独立动作,永远不会由通用 `--fix --yes` 推断:
182
+ 临时运行:
183
183
 
184
184
  ```sh
185
- dsh-doctor recover @scope/plugin --action remove # 只做影响预检
186
- dsh-doctor recover @scope/plugin --action remove --yes # 显式执行
185
+ npx @bruc3van/dsh-doctor diagnose
187
186
  ```
188
187
 
189
- 自动删除要求插件是 profile 直接依赖、不是模板/内置核心 bundle、lockfile 可读、没有会残留的手工 mount 或 dangling patch,并且当前 DSH CLI 可用。执行前会保存已脱敏的诊断快照和临时 quarantine overlay,再调用官方命令:
188
+ 默认检查 `$DSH_HOME/profiles/web`;未设置 `DSH_HOME` 时使用 `~/.dsh`。
190
189
 
191
190
  ```sh
192
- dsh plugin --profile web remove @scope/plugin
191
+ dsh-doctor diagnose
192
+ dsh-doctor diagnose --json
193
+ dsh-doctor diagnose --check-updates
193
194
  ```
194
195
 
195
- 成功后重新诊断并分别验证 dependency、bundle layer 和活跃 entry 已消失,同时保留原版本的精确回滚安装命令。静态检查无法证明不存在动态 Service 依赖、外部数据残留或所有真实业务流程都正常;完成后仍须重启 profile 并验证主要功能。
196
+ 诊断按 DSH 的顺序组合配置:
196
197
 
197
- ---
198
+ ```text
199
+ bundle layers → profile cordis.patch.yml → home cordis.patch.yml → CLI overlays
200
+ ```
198
201
 
199
- ## 历史基线
202
+ 它会检查插件版本和 peer、Node engines、安装与 lockfile、bundle 与 patch、client contract、重复 mount、高层配置覆盖,以及 DSH CLI/Harness 版本漂移。普通诊断不访问网络;只有 `--check-updates` 和 recovery 操作会访问 npm registry。
200
203
 
201
- 升级前保存基线,升级后比较插件版本、兼容状态、Harness 与 finding 变化:
204
+ ## 恢复操作
202
205
 
203
206
  ```sh
204
- dsh-doctor baseline create
205
- dsh-doctor baseline compare
207
+ # 检查和安装 manifest 声明兼容的最高版本
208
+ dsh-doctor recover @scope/plugin --action check-update
209
+ dsh-doctor recover @scope/plugin --action update
210
+ dsh-doctor recover @scope/plugin --action update --yes
206
211
 
207
- # 自定义基线路径
208
- dsh-doctor baseline create --output ./before-upgrade.json
209
- dsh-doctor baseline compare --output ./before-upgrade.json
210
- ```
212
+ # 生成临时隔离 overlay
213
+ dsh-doctor recover @scope/plugin --action quarantine \
214
+ --output ./plugin-quarantine.yml
211
215
 
212
- 默认基线位于 profile `.dsh-doctor/baseline.json`。基线用于差异归因,不是当前诊断的前提,也不会覆盖当前现场证据。
216
+ # 验证临时 overlay 后持久化
217
+ dsh-doctor recover @scope/plugin --action persist-quarantine --verified
218
+ dsh-doctor recover @scope/plugin --action persist-quarantine --verified --yes
213
219
 
214
- ## 旧版确认式修复
220
+ # 删除始终需要单独执行
221
+ dsh-doctor recover @scope/plugin --action remove
222
+ dsh-doctor recover @scope/plugin --action remove --yes
223
+ ```
215
224
 
216
- `--fix` / `--repair` 继续兼容 0.1.x 的确定性 install、update bundle manifest 修复,不会触发 quarantine、持久化隔离或删除。文件动作展示路径并创建备份,命令使用固定 argv、绑定当前 `DSH_HOME`,任一步失败都会停止后续动作。
225
+ Doctor 会在隔离和删除前检查 entry、配置层、直接依赖、核心 bundle、lockfile、手工 mount 和已知 client dependents。静态检查无法确认动态 Service 依赖和外部数据,操作后仍需重启 profile 并验证主要功能。
226
+
227
+ 升级前后也可以保存和比较基线:
217
228
 
218
229
  ```sh
219
- dsh-doctor --fix
220
- dsh-doctor --fix --yes --json
230
+ dsh-doctor baseline create
231
+ dsh-doctor baseline compare
221
232
  ```
222
233
 
223
- ---
224
-
225
234
  ## 输出与退出码
226
235
 
227
- 文本支持中文和英文,优先级为 `--lang`、`DSH_DOCTOR_LANG`、DSH 设置和系统 locale。`--json` 始终保留稳定英文 code 和完整的非秘密证据;插件 `config` 值和其他常见秘密字段会替换为 `[REDACTED]`。
236
+ 文本支持中文和英文,`--json` 使用稳定英文 code 并保留脱敏后的结构化证据。
228
237
 
229
238
  | 退出码 | 含义 |
230
239
  |---|---|
231
- | `0` | 没有阻断错误,或显式动作成功且静态验证通过 |
232
- | `1` | 仍有可能阻断启动的问题,或恢复后静态状态不完整 |
233
- | `2` | 参数、运行环境或动作执行失败 |
234
-
235
- ## 安全边界
240
+ | `0` | 没有阻断错误,或操作完成并通过对应验证 |
241
+ | `1` | 仍有兼容问题、语义迁移或验证未完成 |
242
+ | `2` | 参数、运行环境或操作执行失败 |
236
243
 
237
- - 不执行第三方插件,不求值 `!!js`;诊断会解析配置结构,但 JSON、baseline 和恢复快照会脱敏所有插件 `config` 值及其他常见秘密字段,文本报告也不打印配置值;
238
- - registry 结果只证明 manifest 声明,不证明真实运行兼容;
239
- - 动态 Service 依赖、外部副作用、真实 UI 和业务流程需要用户验证;
240
- - patch 精确编辑只处理 Doctor 能安全解析和定位的结构;有歧义时拒绝自动操作;
241
- - 添加、更新或删除 bundle 后,运行中的 profile 不会自动改变 bundle 集合,必须重启。
242
-
243
- ## 从源码开发
244
+ ## 开发
244
245
 
245
246
  ```sh
246
247
  npm install
@@ -248,4 +249,6 @@ npm run check
248
249
  npm pack --dry-run
249
250
  ```
250
251
 
251
- 发布仍使用 GitHub Actions OIDC npm provenance;本地实现和验证不会自动提交、打 tag 或发布。
252
+ 测试覆盖 CLI、配置组合、诊断、脱敏、备份与写入保护、AST 迁移、构建门控、隔离运行时验证和恢复操作。CI macOS、Ubuntu Windows 上测试 Node.js `22.19` 与 `24`。
253
+
254
+ 本地开发、Skill 和 CLI 都不会自动提交代码、创建 tag 或发布版本。
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bruc3van/dsh-doctor",
3
- "version": "0.5.2",
4
- "description": "Diagnose DSH upgrades, migrate plugins with safe codemods, and verify recovery decisions",
3
+ "version": "0.5.4",
4
+ "description": "Help agents diagnose and upgrade DeepSeek Harness plugins from DSH 0.1.1 to 0.1.2",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "repository": {
@@ -1,12 +1,13 @@
1
1
  ---
2
2
  name: dsh-plugin-upgrade
3
- description: Upgrade a DeepSeek Harness plugin from dsh-v0.1.1-rc.2 to dsh-v0.1.2-alpha.2 with dsh-doctor. Use when a plugin developer asks to migrate, assess compatibility, replace removed dsh-client-runtime or dsh-host-apiproxy APIs, update DSH peer dependencies, rebuild artifacts, or verify a plugin against DSH 0.1.2. Produces an evidence-backed staged report and applies only catalog-confirmed exact rewrites automatically.
3
+ description: Help diagnose and upgrade a DeepSeek Harness plugin from DSH 0.1.1 to 0.1.2 with dsh-doctor, while deciding explicitly whether the upgraded release must remain compatible with DSH 0.1.1. Use when a plugin developer asks to assess compatibility, identify changed APIs, replace removed dsh-client-runtime or dsh-host-apiproxy usage, update DSH dependencies, modify plugin code, rebuild artifacts, or verify the plugin before releasing a new version. Apply only catalog-confirmed exact rewrites automatically, guide semantic code changes, and report what still needs developer verification. The current catalog uses dsh-v0.1.1-rc.2 and dsh-v0.1.2-alpha.2 as its reference points.
4
4
  ---
5
5
 
6
- # DSH plugin upgrade
6
+ # Upgrade a DSH 0.1.1 plugin to 0.1.2
7
7
 
8
- Upgrade one plugin at a time. Treat source migration, artifact verification, runtime activation, and business behavior as separate gates.
9
- This skill is intentionally bound to the `dsh-v0.1.1-rc.2` to `dsh-v0.1.2-alpha.2` catalog; do not reuse its mappings for another version pair.
8
+ Help the developer diagnose and modify one plugin at a time. Treat source migration, artifact verification, runtime activation, and business behavior as separate gates.
9
+
10
+ The current migration knowledge covers the DSH 0.1.1 to 0.1.2 transition. Its CLI catalog records `dsh-v0.1.1-rc.2` and `dsh-v0.1.2-alpha.2` as the exact reference points used to derive and verify known changes. Use those refs in dsh-doctor commands, but first record the plugin's actual DSH ranges and requested target. When another patch or prerelease is involved, use the catalog for known changes only and report that the additional version difference still needs review. Do not claim that the catalog proves an unlisted version combination.
10
11
 
11
12
  ## Inputs
12
13
 
@@ -14,21 +15,37 @@ Determine:
14
15
 
15
16
  - the plugin repository root;
16
17
  - the DSH Harness checkout when available;
18
+ - the plugin's actual DSH dependency and peer ranges, and the requested 0.1.2 target;
19
+ - whether the upgraded plugin must keep supporting DSH 0.1.1, target only DSH 0.1.2, or still needs that decision from the developer;
17
20
  - whether the developer authorizes writes and project command execution;
18
21
  - whether the developer authorizes a global CLI install or update;
19
22
  - the plugin's package manager and build scripts.
20
23
 
21
- Use these fixed refs unless the user explicitly requests a supported alternative:
24
+ Use these catalog reference points in the current CLI commands:
22
25
 
23
26
  - source: `dsh-v0.1.1-rc.2`
24
27
  - target: `dsh-v0.1.2-alpha.2`
25
28
 
26
- Read [cli-bootstrap.md](references/cli-bootstrap.md) before running any migration command, [migration-map.md](references/migration-map.md) before making semantic changes, and [verification.md](references/verification.md) before build or runtime verification.
29
+ Read [cli-bootstrap.md](references/cli-bootstrap.md) before running any migration command, [compatibility-strategy.md](references/compatibility-strategy.md) before proposing or writing changes, [migration-map.md](references/migration-map.md) before making semantic changes, and [verification.md](references/verification.md) before build or runtime verification.
27
30
 
28
31
  Before touching the plugin, inspect the local CLI and perform the read-only registry update check described in `cli-bootstrap.md`. Select one exact DSH Doctor version, verify it exposes this migration catalog, and keep the same invocation for analyze, apply, and verify. Prefer an exact-version `npx` fallback over changing the developer's global installation. Never globally install or update the CLI without explicit authorization.
29
32
 
30
33
  The examples below use `dsh-doctor` for readability. When bootstrap selected an npx invocation, substitute the complete pinned prefix, `npx --yes --package=@bruc3van/dsh-doctor@<selected-version> dsh-doctor`, in every phase.
31
34
 
35
+ ## Compatibility decision gate
36
+
37
+ An upgrade request does not say whether the developer accepts dropping DSH 0.1.1. Write authorization also does not answer that product decision. Do not infer the answer from the current peer range, the word "upgrade," or the fact that a 0.1.2-only rewrite is simpler.
38
+
39
+ You may inspect files, bootstrap the CLI, and run read-only analysis to collect evidence. Before any `migrate apply` preview, source or manifest edit, dependency install, build, or runtime command:
40
+
41
+ 1. record an explicit choice already present in the developer's request; or
42
+ 2. ask: **"Should the same upgraded plugin release continue to support DSH 0.1.1, or may it target DSH 0.1.2 only?"**
43
+
44
+ If the answer is unavailable or ambiguous, stop at `analyzed`, identify the compatibility decision as pending, and do not modify the plugin. Follow the selected path in [compatibility-strategy.md](references/compatibility-strategy.md):
45
+
46
+ - **0.1.2-only:** the catalog's exact rewrites may be applied after their normal preview and write confirmation.
47
+ - **dual-version:** treat every 0.1.2 rewrite as a candidate, not an automatically compatible change. Design and review an adapter or conditional entry/build approach before writing. If the same release cannot honestly support both versions, explain the conflict and ask whether separate releases are acceptable; that changes the compatibility intent and must not be presented as same-release dual compatibility.
48
+
32
49
  ## Phase 1: analyze
33
50
 
34
51
  Run from any directory:
@@ -54,6 +71,8 @@ Do not infer compatibility from a clean bundled artifact alone. The analyzer int
54
71
 
55
72
  ## Phase 2: apply exact changes
56
73
 
74
+ Enter this phase only after the compatibility decision gate is resolved. The commands below are the 0.1.2-target migration path. For dual-version work, first apply the additional constraints in `compatibility-strategy.md`; do not assume a catalog-safe codemod is safe for 0.1.1.
75
+
57
76
  Preview first:
58
77
 
59
78
  ```sh
@@ -88,6 +107,12 @@ On failure, preserve and report the temporary directory. On success, the CLI rem
88
107
 
89
108
  Runtime activation is not business-behavior proof. Finish with targeted manual or automated checks for visible UI, service lifecycle, event subscriptions, cleanup, configuration, and plugin-specific workflows.
90
109
 
110
+ For a dual-version result, verify the produced release against both the actual 0.1.1 and 0.1.2 environments. The catalog-driven `migrate verify` commands prove only the configured target side. Use the plugin's own build/test flow and an isolated 0.1.1 Harness profile for the legacy side, and name the evidence from each matrix row. A successful 0.1.2 runtime smoke must never be reported as dual-version compatibility.
111
+
112
+ ## Prepare for release when requested
113
+
114
+ Verification prepares the plugin for release but does not publish it. If the developer explicitly asks to release the upgraded plugin, first follow the repository's own release instructions and confirm that required semantic and behavior checks are complete. Then update the plugin version and changelog, inspect the packed artifact, and use the repository's existing commit, tag, publish, and registry-verification workflow. Do not commit, tag, or publish merely because the migration skill was installed or run.
115
+
91
116
  ## Report the outcome
92
117
 
93
118
  State the highest achieved gate exactly:
@@ -100,3 +125,5 @@ State the highest achieved gate exactly:
100
125
 
101
126
  Do not call the plugin compatible while errors, semantic tasks, stale artifacts, or required behavior checks remain. Include backups and retained temporary directories in the handoff.
102
127
  Also report the selected DSH Doctor version and source (`local`, exact-version `npx`, or explicitly authorized global install), the registry version observed at bootstrap, and whether update status was current, outdated, missing, or unknown.
128
+ Report the plugin's actual source/target version evidence separately from the catalog reference refs. State whether the plugin is ready for its normal release process; if a release was explicitly requested and completed, include the commit, tag, registry, and release verification evidence.
129
+ State the compatibility intent as one of `0.1.2-only`, `dual-version`, or `pending developer decision`. For `dual-version`, report build, artifact, runtime, and behavior evidence separately for 0.1.1 and 0.1.2; only call the release dual-compatible when every required row passes.
@@ -3,10 +3,11 @@
3
3
  "evals": [
4
4
  {
5
5
  "id": 1,
6
- "prompt": "检查这个只有后端 bundle 的 DSH 插件能否从 0.1.1-rc.2 升级到 0.1.2-alpha.2。它的 peerDependencies 仍是 ^0.1.1,不要改文件。",
7
- "expected_output": "Runs read-only migrate analysis, identifies target range mismatch, and does not claim runtime compatibility.",
6
+ "prompt": "检查这个只有后端 bundle 的 DSH 插件能否从 DSH 0.1.1 升级到 0.1.2。它的 peerDependencies 仍是 ^0.1.1,不要改文件。",
7
+ "expected_output": "Records the plugin's actual version ranges, uses the current exact-ref catalog as the analysis baseline, identifies target range mismatch, and does not claim runtime compatibility.",
8
8
  "expectations": [
9
9
  "Uses migrate analyze before proposing edits",
10
+ "Distinguishes the requested 0.1.1 to 0.1.2 upgrade from the catalog's exact reference refs",
10
11
  "Reports the exact verification status as analyzed",
11
12
  "Does not write files or execute build scripts"
12
13
  ]
@@ -14,9 +15,11 @@
14
15
  {
15
16
  "id": 2,
16
17
  "prompt": "把这个前端插件升级到 DSH 0.1.2。源码里有 import type { ClientContext, ISessions } from '@deepseek-ai/dsh-client-runtime/client',可以安全改的帮我改,其他的列出来。",
17
- "expected_output": "Safely moves ClientContext to Cordis while leaving ISessions as an explicit semantic migration task, with backup evidence.",
18
+ "expected_output": "Recognizes that write authorization does not decide whether 0.1.1 may be dropped, asks the compatibility question, and waits before applying changes; after a 0.1.2-only answer, safely moves ClientContext while leaving ISessions as a semantic task.",
18
19
  "expectations": [
19
20
  "Detects type-only imports from source rather than relying on the bundle",
21
+ "Explicitly asks whether the same release must preserve DSH 0.1.1 compatibility",
22
+ "Does not preview, apply, edit, install, build, or run the plugin until that decision is answered",
20
23
  "Uses migrate apply --safe and requires explicit confirmation for writes",
21
24
  "Does not mechanically rewrite the semantic ISessions contract"
22
25
  ]
@@ -24,9 +27,10 @@
24
27
  {
25
28
  "id": 3,
26
29
  "prompt": "完整升级这个混合前后端插件并验证,Harness 在 /workspace/deepseek-harness。构建失败也要把现场路径告诉我。",
27
- "expected_output": "Performs analyze, safe apply, semantic work, build and isolated runtime gates; reports the highest proven status and retained failure workspace.",
30
+ "expected_output": "Analyzes first, asks whether the same release must retain 0.1.1, and waits before safe apply or executable gates; after the decision, performs the selected migration and verification matrix and reports retained failure state.",
28
31
  "expectations": [
29
32
  "Uses the exact Harness refs and verifies the catalog commits",
33
+ "Treats legacy compatibility as an explicit product decision rather than inferring it from an upgrade request",
30
34
  "Runs static, build, then runtime verification in order",
31
35
  "Uses a temporary DSH_HOME and reports retained failure state",
32
36
  "Keeps business behavior verification separate from activation smoke"
@@ -35,13 +39,37 @@
35
39
  {
36
40
  "id": 4,
37
41
  "prompt": "帮我升级这个插件,但机器上的 dsh-doctor 是旧版,而且我没有授权修改全局 npm 包。请先检查有没有新版本,再继续迁移。",
38
- "expected_output": "Checks the registry read-only, selects one exact-version npx CLI with the required catalog, avoids global installation, and reports the selected version and update status.",
42
+ "expected_output": "Checks the registry read-only, selects one exact-version npx CLI with the required catalog, avoids global installation, asks for the unresolved compatibility intent, and reports the selected version and update status without starting writes or executable verification.",
39
43
  "expectations": [
40
44
  "Checks the local CLI version and exact migration catalog before use",
41
45
  "Uses npm view as a read-only registry update check",
42
46
  "Pins one resolved npx package version for all migration phases",
43
47
  "Does not install or update a global CLI without explicit authorization",
44
- "Reports local, registry, selected CLI, catalog, and update-status evidence"
48
+ "Reports local, registry, selected CLI, catalog, and update-status evidence",
49
+ "Stops at analyzed until the developer chooses 0.1.2-only or dual-version support"
50
+ ]
51
+ },
52
+ {
53
+ "id": 5,
54
+ "prompt": "升级这个插件到 DSH 0.1.2,但同一个 npm 版本还必须继续支持 0.1.1。可以修改代码并执行测试;如果单一产物做不到,先告诉我冲突和可选方案,不要自行放弃旧版。",
55
+ "expected_output": "Records an explicit dual-version requirement, assesses whether imports, manifests, graph declarations, and artifacts can coexist, selects or proposes an adapter/conditional-build/separate-release strategy, and verifies both version rows before claiming compatibility.",
56
+ "expectations": [
57
+ "Records the compatibility intent as dual-version without asking a redundant question",
58
+ "Treats 0.1.2 safe codemods as candidates that still require 0.1.1 review",
59
+ "Does not widen peer ranges or claim one-artifact support without installation and runtime evidence",
60
+ "Separately verifies build, artifact, runtime, and behavior evidence for DSH 0.1.1 and 0.1.2",
61
+ "Reports an exact incompatibility and asks before switching to separate releases or dropping 0.1.1"
62
+ ]
63
+ },
64
+ {
65
+ "id": 6,
66
+ "prompt": "这是一次 breaking release,只需要支持 DSH 0.1.2,不再兼容 0.1.1。先分析再按安全流程修改和验证。",
67
+ "expected_output": "Records the explicit 0.1.2-only intent without asking a redundant compatibility question, then follows analyze, safe preview/apply, semantic migration, and target verification gates.",
68
+ "expectations": [
69
+ "Records the compatibility intent as 0.1.2-only",
70
+ "Does not ask again whether 0.1.1 compatibility must be retained",
71
+ "Still separates write authorization from compatibility intent and follows preview and confirmation safeguards",
72
+ "Reports only the 0.1.2 verification evidence actually achieved"
45
73
  ]
46
74
  }
47
75
  ]
@@ -0,0 +1,51 @@
1
+ # Compatibility strategy
2
+
3
+ ## Decide before changing the plugin
4
+
5
+ Moving a plugin to 0.1.2 and preserving 0.1.1 are different deliverables. The 0.1.2 catalog describes target migrations; it does not prove that the resulting source, dependency graph, artifact, or manifest still works on 0.1.1.
6
+
7
+ Record one explicit intent:
8
+
9
+ | Intent | Meaning | Write policy |
10
+ | --- | --- | --- |
11
+ | `0.1.2-only` | The next plugin release may drop 0.1.1 | Follow the catalog migration after preview and authorization |
12
+ | `dual-version` | The same release must support both 0.1.1 and 0.1.2 | Design the compatibility mechanism and two-version verification matrix before editing |
13
+ | `pending developer decision` | The developer has not chosen | Read-only analysis only; stop before apply, edits, installs, build, or runtime execution |
14
+
15
+ Do not treat general write authorization as permission to drop an older runtime. If the request does not settle the choice, ask the developer directly.
16
+
17
+ ## Assess whether one release can support both
18
+
19
+ For `dual-version`, inventory each migration finding and determine whether the old and new owners coexist:
20
+
21
+ - static imports of packages that exist in only one DSH version;
22
+ - changed Service names, snapshot shapes, lifecycle, or event behavior;
23
+ - client graph `inject`, `external`, platform modules, and client exports;
24
+ - peer, optional peer, development, and bundled dependency ranges;
25
+ - patch targets and profile entries that differ between Harness versions;
26
+ - generated output that may capture version-specific imports.
27
+
28
+ Choose a repository-appropriate same-release mechanism based on evidence, such as a shared compatibility adapter with runtime feature detection or conditional version-specific entry points/builds inside the same package. Do not invent dynamic loading when the bundler or Harness activation model cannot support it. Do not publish a peer range that claims both versions until installation and runtime evidence supports that range.
29
+
30
+ The safe codemod is intentionally target-oriented. In dual-version mode, preview its changes only after the decision is recorded and review each proposed import and dependency edit against 0.1.1 before applying it. Semantic migrations always require the same cross-version review.
31
+
32
+ If the same release cannot load because required packages or static graph declarations are mutually exclusive, report the exact conflict. Ask the developer whether to change scope to separate plugin releases or accept a 0.1.2-only release. Neither alternative satisfies the original same-release `dual-version` intent.
33
+
34
+ ## Verify a two-version matrix
35
+
36
+ Use exact Harness versions or checkouts and keep evidence separate:
37
+
38
+ | Gate | DSH 0.1.1 | DSH 0.1.2 |
39
+ | --- | --- | --- |
40
+ | dependency installation and peer resolution | required | required |
41
+ | typecheck/build/test and packed artifact inspection | required | required |
42
+ | isolated profile install and activation smoke | required | required |
43
+ | plugin-specific UI, Service lifecycle, commands, settings, and cleanup | required where applicable | required where applicable |
44
+
45
+ The current migration catalog and `migrate verify` target 0.1.2. They do not independently certify the legacy row. Verify 0.1.1 with the plugin repository's supported scripts and an isolated profile using the actual 0.1.1 Harness CLI. Preserve failure workspaces and report the exact commands, versions, artifacts, logs, or screenshots for each row.
46
+
47
+ Use precise conclusions:
48
+
49
+ - `0.1.2 runtime-verified; 0.1.1 not tested` is not dual-compatible.
50
+ - Passing builds on both versions is not runtime or behavior proof.
51
+ - Claim `dual-version` compatibility only after all required matrix rows pass for the same release artifact or for the explicitly documented version-specific artifact strategy.