dsh-plugin-tool-management 0.21.2 → 0.21.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.
Files changed (122) hide show
  1. package/CHANGELOG.md +62 -1
  2. package/README.md +3 -5
  3. package/README_EN.md +3 -3
  4. package/docs/{update.md → UPDATE.md} +35 -33
  5. package/lib/approval-policy.js +2 -2
  6. package/lib/audit-log.js +1 -1
  7. package/lib/boot/reconcile.js +3 -3
  8. package/lib/client.js +469 -171
  9. package/lib/compat/capability-specs.js +13 -17
  10. package/lib/compat/host-contracts.js +2 -0
  11. package/lib/compat/host-probe.js +35 -38
  12. package/lib/compat/host-roots.js +86 -15
  13. package/lib/compat/preset-reach.js +75 -102
  14. package/lib/compat/probe.js +68 -117
  15. package/lib/compat/runtime-notes.js +1 -1
  16. package/lib/context-inject-contract.js +6 -5
  17. package/lib/context-inject-frame.js +113 -53
  18. package/lib/context-inject-select.js +13 -14
  19. package/lib/context-inject-surface.js +5 -3
  20. package/lib/context-inject.js +58 -44
  21. package/lib/desktop-cookie-prune.js +95 -0
  22. package/lib/diagnostics.js +3 -1
  23. package/lib/exports/transcript.js +4 -4
  24. package/lib/host-names.js +6 -6
  25. package/lib/http-api.js +35 -26
  26. package/lib/http-fence.js +6 -6
  27. package/lib/hub.js +12 -13
  28. package/lib/imports/parsers.js +25 -21
  29. package/lib/imports/upload.js +5 -1
  30. package/lib/index.js +274 -243
  31. package/lib/mcp/disabled-tools.js +1 -0
  32. package/lib/mcp/loader-token.js +4 -4
  33. package/lib/mcp/manager.js +93 -114
  34. package/lib/mcp/override-blocks.js +1 -1
  35. package/lib/mcp/patch-yaml.js +42 -31
  36. package/lib/mcp/restart-marker.js +1 -1
  37. package/lib/mcp/secret-guard.js +6 -6
  38. package/lib/mcp/state-section.js +110 -69
  39. package/lib/mcp/tool-visibility.js +21 -22
  40. package/lib/memories/archive-engine.js +29 -29
  41. package/lib/memories/archive.js +23 -3
  42. package/lib/memories/constants.js +40 -127
  43. package/lib/memories/discovery.js +11 -2
  44. package/lib/memories/index-io.js +26 -20
  45. package/lib/memories/projection.js +18 -19
  46. package/lib/memories/prompt-layer.js +3 -2
  47. package/lib/memories/service.js +41 -38
  48. package/lib/memories/snapshot.js +37 -29
  49. package/lib/op-registry.js +38 -18
  50. package/lib/ops/candidates.js +3 -2
  51. package/lib/ops/compat.js +10 -9
  52. package/lib/ops/ctx.js +1 -1
  53. package/lib/ops/memory.js +18 -18
  54. package/lib/ops/prompts.js +8 -8
  55. package/lib/ops/quick-prompts.js +1 -0
  56. package/lib/ops/scene-records.js +23 -24
  57. package/lib/ops/scene-sync.js +8 -7
  58. package/lib/ops/scope.js +144 -40
  59. package/lib/ops/sessions.js +10 -9
  60. package/lib/ops/snapshot.js +10 -9
  61. package/lib/ops/state-doctor.js +6 -6
  62. package/lib/ops/trash-retention.js +2 -1
  63. package/lib/ops/trash.js +6 -6
  64. package/lib/prompts/preset-id.js +1 -1
  65. package/lib/prompts/project-instructions.js +3 -3
  66. package/lib/prompts/quick-service.js +1 -0
  67. package/lib/prompts/service.js +13 -12
  68. package/lib/request-gate.js +26 -25
  69. package/lib/scene-linkage.js +6 -5
  70. package/lib/scene-prompt-sync.js +10 -9
  71. package/lib/scene-settings.js +1 -0
  72. package/lib/scenes/candidates.js +9 -10
  73. package/lib/scope/intent-store.js +1 -0
  74. package/lib/scope/intent.js +16 -15
  75. package/lib/scope/resolve.js +6 -6
  76. package/lib/scope/scope-overrides.js +17 -17
  77. package/lib/scope/store.js +1 -0
  78. package/lib/sessions/archive-schemas.js +9 -0
  79. package/lib/sessions/bridge.js +42 -56
  80. package/lib/sessions/history.js +6 -7
  81. package/lib/sessions/workspace.js +21 -23
  82. package/lib/settings-sidecars.js +1 -0
  83. package/lib/sidebar-settings.js +1 -0
  84. package/lib/skills/catalog.js +9 -10
  85. package/lib/skills/core-util.js +5 -0
  86. package/lib/skills/core.js +35 -22
  87. package/lib/skills/frontmatter.js +26 -14
  88. package/lib/skills/homes.js +2 -0
  89. package/lib/skills/import-pipeline.js +8 -1
  90. package/lib/skills/manager-state.js +30 -6
  91. package/lib/skills/official.js +14 -11
  92. package/lib/skills/readonly-discovery.js +1 -0
  93. package/lib/skills/service.js +19 -18
  94. package/lib/skills/skill-roots.js +25 -7
  95. package/lib/skills/skill-trash.js +14 -3
  96. package/lib/skills/system-trash.js +3 -1
  97. package/lib/skills/upload-pipeline.js +19 -3
  98. package/lib/slash-settings.js +1 -0
  99. package/lib/stale-write.js +9 -1
  100. package/lib/subagents/catalog.js +5 -5
  101. package/lib/subagents/child-preset.js +7 -10
  102. package/lib/subagents/persona-parse.js +9 -8
  103. package/lib/subagents/persona-write.js +1 -1
  104. package/lib/subagents/run-provider.js +13 -15
  105. package/lib/subagents/service.js +13 -12
  106. package/lib/subagents/tool-filter.js +1 -1
  107. package/lib/subagents/tools.js +41 -39
  108. package/lib/token-config.js +9 -9
  109. package/lib/tool-table-switch.js +3 -2
  110. package/lib/tools/deps.js +33 -13
  111. package/lib/tools/mcp.js +63 -36
  112. package/lib/tools/memory.js +51 -36
  113. package/lib/tools/prompt.js +32 -20
  114. package/lib/tools/remove.js +12 -11
  115. package/lib/tools/scene.js +39 -36
  116. package/lib/tools/skills.js +44 -45
  117. package/lib/tools/subagent.js +21 -22
  118. package/lib/tools/table.js +21 -20
  119. package/lib/trash-id.js +3 -2
  120. package/lib/trash-retention.js +4 -5
  121. package/lib/update-check.js +5 -1
  122. package/package.json +4 -3
@@ -1,33 +1,23 @@
1
1
  /**
2
- * Host capability probe — the single place that decides what this plugin may
3
- * do to the running host's data, and why not when it may not.
2
+ * 宿主能力探测 —— 唯一决定「本插件可以对运行中的宿主做什么、以及为什么不能」的地方。
4
3
  *
5
- * WHY THIS REPLACES THE TEXT-COMPARISON GATE
6
- * ------------------------------------------
7
- * The previous gate in `sessions/bridge.ts` compared each host method against
8
- * this plugin's own copy of the official prototype with
9
- * `Function.prototype.toString()`. That only ever answered one question —
10
- * "is the host running the same release I was written against?" — and it
11
- * answered it with a hard throw, so a harmless upstream refactor disabled
12
- * whole features. It also quietly assumed the plugin and the host load two
13
- * *different* copies of the same package.
4
+ * 为什么不用文本比对做闸门
5
+ * ------------------------
6
+ * `sessions/bridge.ts` 曾经拿每个宿主方法与本插件自己那份官方原型做
7
+ * `Function.prototype.toString()` 比对。它只能回答一个问题 ——「宿主跑的是不是我写代码时
8
+ * 那一版」—— 而且用硬抛错回答,于是一次无害的上游重构就能关掉整片功能。它还默认了插件与
9
+ * 宿主加载的是**两份不同**的同名包。
14
10
  *
15
- * The durable questions are different:
11
+ * 真正稳定的是另外三个问题:
16
12
  *
17
- * - IDENTITY: do the plugin and the host share the same physical module?
18
- * (If yes, `===`, `instanceof` and symbol lookups cross the boundary and
19
- * every "same implementation" concern disappears. Missing identity is a
20
- * deployment defect, reported as such, not something to guess around.)
21
- * - PRESENCE: does the live host object expose the members the adapter
22
- * calls? Members are checked as live values with their shape, because a
23
- * host may have been upgraded, proxied, or replaced wholesale.
24
- * - BEHAVIOUR: for anything that can be observed without mutating host
25
- * state, call it and look at the result — a getter that no longer returns
26
- * a Map is a fact, a version string is a hint.
13
+ * - 身份:插件与宿主是不是同一个物理模块?是则 `===`、`instanceof`、symbol 查找都跨得过
14
+ * 边界,「是不是同一份实现」这个疑问整体消失。身份不成立是部署缺陷,如实报出来,不绕。
15
+ * - 存在:活宿主对象上有没有适配器要调的那些成员?按活值与形状检查 —— 宿主可能被升级、
16
+ * 代理或整体替换过。
17
+ * - 行为:凡是不改宿主状态就能观察的,调一次看结果 —— getter 不再返回 `Map` 是事实,
18
+ * 版本号只是线索。
27
19
  *
28
- * Every answer is reported per capability instead of collapsing into one
29
- * boolean, so a caller can degrade exactly the feature that lost support and
30
- * leave the rest working.
20
+ * 结论按**能力**逐项报告,不压成一个布尔值:调用方可以只降级失去支持的那一项,其余照常。
31
21
  */
32
22
  import { createRequire } from 'node:module';
33
23
  import { existsSync, readFileSync } from 'node:fs';
@@ -36,7 +26,7 @@ import { fileURLToPath } from 'node:url';
36
26
  import { CAPABILITY_SPECS } from './capability-specs.js';
37
27
  import { BARE_HOST_MODULE_CONTRACTS } from './host-contracts.js';
38
28
  import { isAsarPath, isFn, OWNER_CLASSES, realPathWithReason, referencePrototypes, provideHostRootCandidates, safeResolve, textMatchOf, versionOf, versionOfPackageAt, } from './host-probe.js';
39
- // 宿主安装根的发现与「该走哪条恢复路」的判定 2026-10-01 整段搬到 ./host-roots.js,正文一字
29
+ // 宿主安装根的发现与「该走哪条恢复路」的判定 整段搬到 ./host-roots.js,正文一字
40
30
  // 未改(moved-verify 逐字对拍)。probe.js 的公开面照旧:搬走的那 12 件全部从这里再出口 ——
41
31
  // index.ts / ops/compat.ts / sessions/bridge.ts 都按 ./compat/probe.js 引它们,少一件 equiv
42
32
  // 对拍就报「导出面丢失」。
@@ -47,13 +37,12 @@ import { hostRootCandidates, IDENTITY_PACKAGES, routeFor, VERIFIED_HOST_VERSION
47
37
  // capability-specs.ts 不能反向 import 本文件(probe → specs → probe 成环)。所以在这里把
48
38
  // 函数本体注入 host-probe.ts:它只调用、不 import,加载顺序天然正确(本文件先被求值)。
49
39
  provideHostRootCandidates(hostRootCandidates);
50
- /** Packages whose physical module identity matters to this plugin. */
51
40
  /**
52
41
  * 本插件是不是从**源码检出**跑起来的(仓库里那份,`scripts/host-deps.mjs` 就躺在旁边)。
53
42
  *
54
43
  * 用来决定「两份拷贝」那条阻塞项给什么修复指引:`scripts/` 不在 `package.json` 的
55
44
  * `files` 里(发布形态本就不该带开发者脚本),所以 npm 装出来的用户照那条指引去跑
56
- * 只会拿到 `MODULE_NOT_FOUND` —— 这是 issue #1 的次要问题之一。指引必须按实际形态给。
45
+ * 只会拿到 `MODULE_NOT_FOUND`。指引必须按实际形态给。
57
46
  */
58
47
  const SOURCE_INSTALL = existsSync(join(dirname(fileURLToPath(import.meta.url)), '..', '..', 'scripts', 'host-deps.mjs'));
59
48
  /** 供界面决定修复指引:`true` = 源码检出(`scripts/` 就在旁边),`false` = npm 安装形态。 */
@@ -68,21 +57,19 @@ export function isSourceInstall() {
68
57
  * `>=0.2.1-rc.2` 匹配不了 `0.2.2-rc.1`,`^0.2.1-rc.2` 也匹配不了它 —— 范围只能**逐段写**,
69
58
  * 一代一段。
70
59
  *
71
- * 但「逐段写」不等于「把历史各代累积起来」。2026-10-22 修正:此前每适配一代新 rc 就**追加**
72
- * 一段,范围于是长成 `0.1.7 || 0.2.0 || 0.2.1` 三代并集,等于向 npm 声明「0.21.2 支持
73
- * 0.1.7-rc.2 起的每一代」。而 0.21.0 起本插件的代码是按 0.2.1 的契约写的(SubagentStartRequest、
74
- * 身份比对、`connection.admit` 这几处都动过会静默改行为的语义),在 0.2.0 / 0.1.7 上从未验证。
75
- * 那种声明最坏的后果不是"装不上",而是"装上了、大部分能用、某几个动作悄悄失效"—— 用户无法
76
- * 判断是插件问题还是版本问题。
60
+ * 但「逐段写」不等于「把历史各代累积起来」。累积成 `0.1.7 || 0.2.0 || 0.2.1` 三代并集,
61
+ * 等于向 npm 声明「支持 0.1.7-rc.2 起的每一代」。而本插件的代码只按 0.2.1 的契约写过
62
+ * (SubagentStartRequest、身份比对、`connection.admit` 这几处都动过会静默改行为的语义),
63
+ * 在 0.2.0 / 0.1.7 上从未验证。那种声明最坏的后果不是"装不上",而是"装上了、大部分能用、
64
+ * 某几个动作悄悄失效"—— 用户无法判断是插件问题还是版本问题。
77
65
  *
78
66
  * 所以现在**只声明当前适配的这一代**。旧宿主不是没人管:插件的老版本自己带着老范围,用户装
79
- * 对应版本即可(`dsh plugin add dsh-plugin-tool-management@0.16.6`)。装上被拒 + 一版新适配,
67
+ * 对应版本即可(`dsh plugin add dsh-plugin-tool-management@<老版本号>`)。装上被拒 + 一版新适配,
80
68
  * 优于装上然后部分功能悄悄失效。
81
69
  *
82
70
  * 上界**必须写**(`<0.2.2`):`^` 不能用,它的隐含上界是 `<0.3.0`,而 `0.2.1-rc.2` 这个已适配
83
71
  * 版本自己都满足不了 `^0.2.1-rc.2`(prerelease 只在同元组比较器带 prerelease 时才匹配)。
84
72
  *
85
- * 2026-09-30 审查 §5 F9 + §5.4:这一段此前与 `package.json` 的 peerDependencies **漂移**成
86
73
  * 两种写法(这里是 `^` 三段、那里是 `>=` 两段,且下界不同)。现在两处是**同一个字符串**,
87
74
  * 并由 `test/contracts.test.mjs` 的断言钉住 —— 漂移会让"界面/doctor 报的范围"与"安装期实际
88
75
  * 校验的范围"各说各话,而两者都自称是插件的兼容范围。同一条断言现在还钉住「只有一段」,
@@ -96,32 +83,21 @@ export function isSourceInstall() {
96
83
  * 0.2.1-rc.2 已实测通过:`assessHost` 全通过,宿主版本读得出来。
97
84
  */
98
85
  export const EXPECTED_PEER_RANGE = '>=0.2.1-rc.2 <0.2.2';
99
- /** The release this plugin's adapters were last verified against. */
100
86
  /**
101
87
  * peer range 的下界。仍从 EXPECTED_PEER_RANGE 派生,避免两处手写漂移。
102
88
  *
103
89
  * 范围收窄到一代之后它**与 VERIFIED_HOST_VERSION 重合**(都是 0.2.1-rc.2)—— 这是正确的:
104
90
  * 适配的那一代就是唯一允许安装的那一代。保留这个导出是因为它进了 `compat-status` 的载荷,
105
91
  * doctor 与外部脚本可能仍在读;语义仍是"最早支持哪一代",只是现在只有一代。
106
- *
107
- * 2026-09-29 起**不再出现在界面上**(用户裁定:删掉「最低要求 ≥ …」那一行 —— 它是安装期
108
- * 门槛,摆在"当前宿主"卡片下面会被读成对当前宿主的断言)。保留此导出是因为它进了
109
- * `compat-status` 的载荷,doctor 与外部脚本可能仍在读。
110
92
  */
111
93
  export const EXPECTED_MIN_HOST_VERSION = EXPECTED_PEER_RANGE.match(/(\d+\.\d+\.\d+(?:-rc\.\d+)?)/)?.[1] ?? VERIFIED_HOST_VERSION;
112
94
  /**
113
- * The capability sets each operation depends on, grouped by how the plugin
114
- * reaches the same outcome when a member is missing. Order matters: the first
115
- * viable route wins.
95
+ * 单项能力的结论。
116
96
  *
117
- * - `native`: host entry points that already implement the whole operation.
118
- * - `adapter`: the checked compatibility adapter (the only route that touches
119
- * private members), used when the host has no native entry.
120
- */
121
- /** Texts a user can act on, per capability, when it is the reason for a refusal. */
122
- /**
123
- * One capability's result. `target` is the live host object; `reference` is
124
- * this plugin's copy of the same implementation when the package is importable.
97
+ * @param spec 能力规格(要求的方法、字段与额外探针)
98
+ * @param target 活宿主对象
99
+ * @param reference 插件侧同实现的副本;包不可解析时为 undefined
100
+ * @returns 该项能力的结论;探测内部失败记为 finding,不抛错
125
101
  */
126
102
  function inspectCapability(spec, target, reference) {
127
103
  const base = {
@@ -176,7 +152,7 @@ function inspectCapability(spec, target, reference) {
176
152
  return { ...base, state: 'shape-mismatch', detail: failure, missing: [], ...(textMatch === undefined ? {} : { textMatch }) };
177
153
  }
178
154
  }
179
- // 删除类收紧(2026-09-19,07 审查五档问题 2):textMatch === false 意味着宿主运行的
155
+ // 删除类收紧:textMatch === false 意味着宿主运行的
180
156
  // 不是本插件适配并验证过的实现(参考副本与宿主同源时恒真 —— junction 同物理文件;
181
157
  // 只有宿主升级/漂移才会 false)。读/写类维持「按能力使用」的宽口径,但删除不可逆:
182
158
  // 漂移的 flush/detachEntered/announce/deleteSession 一律不盲调,路由降级 adapter 或
@@ -211,34 +187,28 @@ function inspectCapability(spec, target, reference) {
211
187
  };
212
188
  }
213
189
  /**
214
- * Capability ids whose absence is a routing fact rather than a failure: the
215
- * plugin substitutes its own implementation. They never appear as degraded and
216
- * never block a route.
190
+ * 「缺失只影响走哪条路、不算故障」的能力 id:插件自己有一份实现顶上。它们既不出现在降级
191
+ * 清单里,也不挡任何路。
217
192
  *
218
- * Superseded by {@link CapabilityFinding.optional}, which marks the same fact on
219
- * the finding itself (the UI and the doctor both read that flag). Kept as the
220
- * exported id list so callers can ask "which slots does the plugin itself back?"
221
- * without duplicating the table.
193
+ * 同一个事实在 {@link CapabilityFinding.optional} 上也有(界面与 doctor 都读那个标记);
194
+ * 这里保留导出是为了让调用方问「哪些槽位是插件自己顶的」而不必复制整张表。
222
195
  */
223
196
  export const SUBSTITUTED_CAPABILITIES = CAPABILITY_SPECS
224
197
  .filter((spec) => spec.optional === true)
225
198
  .map((spec) => spec.id);
226
199
  /**
227
- * The capability table as a *static* view: for each spec, the official class
228
- * whose prototype must carry the required members. This exists so a CLI without
229
- * a running host (the doctor) can still answer "can this build archive / delete /
230
- * list?".
200
+ * 能力表的**静态**视图:每一项给出"必须由哪个官方类的原型承载这些成员"。存在的理由是没有
201
+ * 活宿主的 CLI(doctor)也要能回答「这一份构建能不能归档 / 删除 / 列出」。
231
202
  *
232
- * Derived from {@link CAPABILITY_SPECS} — the previous hand-written second table
233
- * drifted silently: it carried 9 of the 15 ids and missed every `sessions.*` and
234
- * native-slot capability the routing actually needs.
203
+ * 全部由 {@link CAPABILITY_SPECS} 派生。手写第二张表必然漂移:漏掉一半 id、漏掉所有
204
+ * `sessions.*` 与路由真正依赖的原生槽位,而它自己不会报错。
235
205
  */
236
206
  export const CAPABILITY_STATIC = CAPABILITY_SPECS.map((spec) => {
237
207
  const ref = OWNER_CLASSES[spec.owner];
238
208
  const methods = spec.methods;
239
209
  // `staticWhen` 是"这一轮能不能静态检查"的门槛。它说不的时候,`check` 必须是 null ——
240
210
  // 否则 doctor 会从插件锚点解析一个本插件不依赖的包,然后把"解析不到"写成"宿主缺失"
241
- // (2026-10-17 `connection.admit` 的误报正是这条路径)。null 让它落到 `runtime-only`:
211
+ // (`connection.admit` 的误报正是这条路径)。null 让它落到 `runtime-only`:
242
212
  // 「只能对活的宿主查」是事实,"missing" 不是。
243
213
  const checkableByStaticView = spec.staticWhen === undefined || spec.staticWhen();
244
214
  return {
@@ -246,22 +216,21 @@ export const CAPABILITY_STATIC = CAPABILITY_SPECS.map((spec) => {
246
216
  label: spec.label,
247
217
  kind: spec.kind,
248
218
  optional: spec.optional === true,
249
- // A `fields`-only spec (instance Maps) and a spec whose judgement lives in
250
- // its `probe` have nothing a prototype can answer — they stay runtime-only.
219
+ // 只认 `fields`(实例 Map)的规格、以及判据落在 `probe` 里的规格,原型上问不出东西
220
+ // —— 它们只能留在运行期查。
251
221
  check: checkableByStaticView && ref !== undefined && methods !== undefined && methods.length > 0
252
222
  ? { pkg: ref.pkg, target: ref.target, members: methods }
253
223
  : null,
254
224
  };
255
225
  });
256
226
  /**
257
- * Inspect the live host behind one plugin context.
227
+ * 探测一个插件上下文背后的活宿主。
258
228
  *
259
- * Everything is read-only: the only host code paths touched are getters and
260
- * `requireState()`/`requireTable()`, both of which the plugin already calls on
261
- * every list request. A failure inside a probe is a finding, never a throw.
229
+ * 全程只读:只碰 getter 与 `requireState()`/`requireTable()`,而这两类本插件在每次
230
+ * 列表请求里本来就会调。探测内部失败记成 finding,绝不抛错。
262
231
  *
263
- * @param ctx - the plugin's cordis context.
264
- * @returns the assessment snapshot surfaced to the UI, the tools and the log.
232
+ * @param ctx 插件的 cordis 上下文(只用到 `get` 与几个可选服务字段)
233
+ * @returns 交给界面、工具与日志的评估快照
265
234
  */
266
235
  export function assessHost(ctx) {
267
236
  const get = (name) => {
@@ -272,7 +241,7 @@ export function assessHost(ctx) {
272
241
  return undefined;
273
242
  }
274
243
  };
275
- // Cordis exposes traceable proxies; compare and inspect the original objects.
244
+ // cordis 暴露的是可追踪代理,比对与检查都要落在原始对象上。
276
245
  // `Symbol.for('cordis.original')` 与 cordis 导出的 `symbols.original` 是**同一个符号**
277
246
  // (该包内即 `original: Symbol.for("cordis.original")`)。这里不 import cordis,是为了让
278
247
  // 兼容探测在宿主包加载失败时仍能工作 —— 本文件对宿主零硬依赖(见文件头的 createRequire)。
@@ -322,7 +291,7 @@ export function assessHost(ctx) {
322
291
  const slot = targets[spec.owner];
323
292
  return inspectCapability(spec, slot.target, slot.reference);
324
293
  });
325
- // Identity: is the plugin loading the same physical modules the host runs?
294
+ // 身份:插件加载的是不是宿主正在跑的那几个物理模块?
326
295
  const modules = {};
327
296
  const sameAsHost = {};
328
297
  const blockers = [];
@@ -353,13 +322,12 @@ export function assessHost(ctx) {
353
322
  unverified.push(name);
354
323
  continue;
355
324
  }
356
- // Resolve the same name from the host installation's own anchor, then
357
- // compare PHYSICAL files: a junction is the same module, not a copy.
325
+ // 用宿主安装自己的锚点再解析同一个名字,然后比**物理文件**:junction 是同一个模块,
326
+ // 不是一份拷贝。
358
327
  //
359
- // 逐包解析、逐包取真实形态。realpath 的**机制**确实整轮不变,但上一版曾把
360
- // 这句话错写成连**解析结果**一起复用:第一个包(cordis)的宿主侧入口路径被当成
361
- // 其余五个包的宿主侧路径,于是五条全部比成「与 cordis 不同」→ 假「两份不同拷贝」
362
- // (官方桌面版 0.2.0-rc.2 实测,2026-09-30;解析本就便宜,节点自身还有缓存)。
328
+ // 逐包解析、逐包取真实形态。**机制**整轮只做一次,但**解析结果**必须逐包算:
329
+ // 复用第一个包(cordis)的宿主侧入口路径,会让其余五个包全被比成「与 cordis 不同」,
330
+ // 得出「两份不同拷贝」的假结论(官方桌面版实测)。解析本身不贵,node 自己也有缓存。
363
331
  let hostResolved = null;
364
332
  let hostRealpath = null;
365
333
  try {
@@ -370,7 +338,7 @@ export function assessHost(ctx) {
370
338
  hostResolved = null;
371
339
  }
372
340
  // 真实形态取不到 → 这一格是「比不了」,不是「两份拷贝」。理由如实上报,
373
- // 绝不把路径问题说成模块问题(issue #1 的次要问题之二)。
341
+ // 绝不把路径问题说成模块问题。
374
342
  if (hostRealpath !== null && 'reason' in hostRealpath) {
375
343
  sameAsHost[name] = null;
376
344
  hostRealpathNote = hostRealpathNote ?? hostRealpath.reason;
@@ -404,7 +372,7 @@ export function assessHost(ctx) {
404
372
  if (same === false) {
405
373
  // 指引按**实际形态**给:`scripts/host-deps.mjs` 只存在于源码检出里
406
374
  // (`files` 不含 `scripts/`,npm 安装形态下没有这个文件),
407
- // 发布形态照那条指引去跑必然 `MODULE_NOT_FOUND` —— issue #1 的次要问题之一。
375
+ // 发布形态照那条指引去跑必然 `MODULE_NOT_FOUND`。
408
376
  blockers.push(SOURCE_INSTALL
409
377
  ? `${name}:插件与宿主加载的是两份不同拷贝(在插件源码目录运行 node scripts/host-deps.mjs --fix)`
410
378
  : `${name}:插件与宿主加载的是两份不同拷贝(升级或重装本插件后仍然如此再报)`);
@@ -432,16 +400,13 @@ export function assessHost(ctx) {
432
400
  packages: asarHostPackages,
433
401
  });
434
402
  }
435
- // Degraded = something is genuinely unavailable. Optional slots are excluded:
436
- // their absence selects the adapter route and leaves the feature fully
437
- // working, so listing them here would tell the user a working feature is
438
- // broken (and, with the destructive wording, that its buttons are disabled).
403
+ // 降级 = 确实用不了。可选槽位不算:它们缺席只是选中适配器路线,功能照常可用;
404
+ // 列进降级会让用户以为好用的功能坏了(再配上"不可用"的措辞,还会以为按钮被禁掉)。
439
405
  const degraded = findings.filter((finding) => finding.state !== 'ok' && finding.optional !== true);
440
- // Deletion is possible when SOME route reaches it. The optional native
441
- // delegate slots (`workspace.delete-native`, `workspace.unarchive-native`,
442
- // `workspace.batch-native`) are expected to be ABSENT on hosts whose official
443
- // API lacks those entry points — that absence selects the adapter route, it
444
- // does not mean deletion is impossible.
406
+ // 只要**有一条**路走得到,删除就是可行的。那几个可选的原生委派槽位
407
+ // (`workspace.delete-native` / `workspace.unarchive-native` /
408
+ // `workspace.batch-native`)在官方 API 没有对应入口的宿主上本就该缺席 ——
409
+ // 缺席只是选中适配器路线,不等于删除做不了。
445
410
  const delta = routeFor({ findings }, 'delete').via !== 'none';
446
411
  return {
447
412
  identity: {
@@ -502,12 +467,10 @@ function hostContractStatus(hostRoot) {
502
467
  };
503
468
  }
504
469
  /**
505
- * The `@deepseek-ai` directory of the DSH installation this plugin is attached
506
- * to, derived from where a shared package physically lives.
470
+ * 本插件所挂的那个 DSH 安装的 `@deepseek-ai` 目录,从某个共享包的物理位置推出来。
507
471
  *
508
- * Anchoring on the resolved entry rather than on `require.resolve('@deepseek-ai/dsh')`
509
- * matters: the plugin never imports the `dsh` app package, so it need not be
510
- * resolvable from the plugin at all — only the shared libraries are.
472
+ * 锚在**已解析的入口**上而不是 `require.resolve('@deepseek-ai/dsh')` 上:插件从不 import
473
+ * `dsh` 应用包,它本来就不必对插件可解析 —— 可解析的只有那些共享库。
511
474
  *
512
475
  * 注意 pnpm:这里在 `.pnpm/<name>@<ver>/node_modules/` 布局下会返回**该包的隔离目录**
513
476
  * (那也是一个 `node_modules/@deepseek-ai`)。它本身不是问题 —— node 的解析会继续向上走到
@@ -524,7 +487,7 @@ function hostPackageRoot() {
524
487
  /**
525
488
  * 宿主 `@deepseek-ai` 目录的**候选序列**(按优先级)—— 全仓"宿主在哪"的唯一口径。
526
489
  *
527
- * 为什么单独导出(2026-09-30 审查 §5 F10):运行时(本文件)与 `scripts/doctor.mjs` /
490
+ * 为什么单独导出:运行时(本文件)与 `scripts/doctor.mjs` /
528
491
  * `scripts/host-deps.mjs` 此前**各写一份**,而且顺序不一样 —— doctor 少了桌面版那一条,
529
492
  * 于是在桌面宿主上要么报 "host installation not found",要么拿 npx 缓存里**另一代宿主**
530
493
  * 当锚点比出假 SEPARATE COPY。那正是本文件注释里记过的实测事故,只修了运行时。
@@ -551,28 +514,16 @@ function hostPackageRoot() {
551
514
  * `npm_config_cache`、`~/.npmrc` 的 `cache=`、`%LOCALAPPDATA%\npm-cache` —— probe 全程同步,
552
515
  * 不起子进程,读不到就当没有这批候选。
553
516
  */
554
- /** Human-readable summary line for logs and the settings page header. */
517
+ /** 给日志与设置页标题用的一行摘要。 */
555
518
  export function summarize(assessment) {
556
519
  const total = assessment.findings.length;
557
520
  const ok = total - assessment.degraded.length;
558
521
  const state = assessment.degraded.length === 0 ? '全部可用' : `降级 ${assessment.degraded.length} 项`;
559
522
  return `宿主 ${assessment.identity.version} · 能力 ${ok}/${total} · ${state}`;
560
523
  }
561
- /** Findings by id, for route decisions. */
562
- /** Refusals for every degraded capability in the list, in list order. */
563
- /**
564
- * Choose how one operation should reach the host.
565
- *
566
- * Never silently falls back from a partially available route into a destructive
567
- * one: a route is chosen only when every capability it needs is `ok`.
568
- *
569
- * @param assessment - latest host assessment.
570
- * @param operation - operation name from {@link OPERATION_ROUTES}.
571
- * @returns the route to take plus, when `none`, what is missing and why.
572
- */
573
524
  /**
574
- * The error a refused operation throws. Kept as a distinct class so callers can
575
- * tell "the host cannot do this safely" from "the operation failed".
525
+ * 被拒绝的操作抛出的错误。单独一个类,是为了让调用方能区分「宿主做不了这件事」与
526
+ * 「操作本身失败了」。
576
527
  */
577
528
  export class CapabilityRefusalError extends Error {
578
529
  operation;
@@ -587,7 +538,7 @@ export class CapabilityRefusalError extends Error {
587
538
  this.refusals = refusals;
588
539
  }
589
540
  }
590
- /** Throw unless the assessment allows the operation through some route. */
541
+ /** 评估结果不给路就抛错;给了就返回那条路由决策。 */
591
542
  export function requireRoute(assessment, operation) {
592
543
  const decision = routeFor(assessment, operation);
593
544
  if (decision.via === 'none')
@@ -3,7 +3,7 @@
3
3
  // 为什么需要它:有一批降级**没有抛错可挂**:它们发生在装配期或探测期(第三方包装接管了本插件的
4
4
  // 运行时适配、注入域装配失败、启动期表达式或服务名解析出问题),失败当下的表现只是"某个功能
5
5
  // 少了一半"或者"静默失效"。此前这些点只落 console / logger,用户在界面上看不到,要等事故之后
6
- // 才倒查(审查报告 §3 记了多处)。这里给它们一个共用出口:`noteRuntime` 记一条,
6
+ // 才倒查。这里给它们一个共用出口:`noteRuntime` 记一条,
7
7
  // `compat-status` 把全部条目并进 findings —— 兼容页因此成为"降级总账"。
8
8
  //
9
9
  // 与 `probe.ts` 的 CAPABILITY_SPECS 分工:那张表是**写死的宿主能力清单**(每次探测重算),
@@ -10,9 +10,9 @@ export const INJECT_DOMAIN_KEYS = ['scene', 'memory', 'mcp', 'skills', 'subagent
10
10
  * 命名对齐官方 `*-catalog` 风格与本插件的工具族(`*_manager_*`);改名等于换身份,
11
11
  * 旧消息会被当成"不在上下文里"而重发一次,所以这几个字符串是稳定契约。
12
12
  *
13
- * ⚠️ 0.14.0 把 `memory` 的 kind 从 `scene-memory-manager-catalog` 改成
14
- * `memory-manager-catalog`,并把场景拆成独立的 `scene` 域 —— 升级后每个会话**会重发一次**
15
- * 这两段(旧消息认不出来)。一次性代价,换来的是两段能各自开关、各自去重。
13
+ * ⚠️ `memory` 的 kind 从 `scene-memory-manager-catalog` 改成了 `memory-manager-catalog`,场景
14
+ * 也拆成独立的 `scene` 域 —— 升级后每个会话**会重发一次**这两段(旧消息认不出来)。一次性
15
+ * 代价,换来的是两段能各自开关、各自去重。
16
16
  */
17
17
  export const INJECT_KIND_OF = {
18
18
  scene: 'scene-manager-catalog',
@@ -34,7 +34,7 @@ export const INJECT_KIND_OF = {
34
34
  * 都说明模型确实在读这一域。改工具名等于换身份,这几个字符串是稳定契约。
35
35
  *
36
36
  * 为什么值是**数组**:工具族与注入域不是一一对应的概念 —— 域是"给模型看的信息分组"
37
- * (界面上的勾选),族是"操作哪类对象"。0.14.0 里场景与记忆就一度同域两族
37
+ * (界面上的勾选),族是"操作哪类对象"。场景与记忆就一度同域两族
38
38
  * (`memory_manager_*` + `scene_manager_*`),拆开后现在每个域各一个前缀。留着数组是
39
39
  * 为了让"一个域挂多个族"在类型上成立,将来加族不必改类型。顺序不影响判定。
40
40
  */
@@ -90,7 +90,7 @@ export function subagentDepthOf(agent) {
90
90
  * 这个 agent 是不是**子会话**(子代理派生的会话)。深度判定的布尔投影。
91
91
  *
92
92
  * ⚠️ 生产代码现在只用 `subagentDepthOf` —— 判据是"目录该不该注入到这么深的会话",
93
- * 需要的是**深度数字**,不是一个布尔身份(2026-09-17 方案 A:委派可行性由官方决定,
93
+ * 需要的是**深度数字**,不是一个布尔身份(方案 A:委派可行性由官方决定,
94
94
  * 与"是不是子会话"无关)。这个投影留给真正需要布尔判断的场合,以及测试。
95
95
  */
96
96
  export function isSubagentSession(agent) {
@@ -108,6 +108,7 @@ export const CARRIER_FACT_OF = {
108
108
  prompt: 'carriesAgentsMd',
109
109
  skills: 'carriesSkillCatalog',
110
110
  };
111
+ /** 出厂注入设置:六个域全开,由用户或档案再收窄。 */
111
112
  export const DEFAULT_INJECT_SETTINGS = {
112
113
  underSuppressingPresets: false,
113
114
  domains: { scene: true, memory: true, mcp: true, skills: true, subagents: true, prompt: true },