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,18 +1,19 @@
1
- // 技能域的 model 工具(2026-09-19 从 index.ts 的注册区抽出;2026-09-23 合并):
1
+ // 技能域的 model 工具(从 index.ts 的注册区抽出;合并):
2
2
  // skill_manager_list / skill_manager_read / skill_manager_switch / skill_manager_save。
3
3
  //
4
4
  // create → save:`skill-create` 对同名是**拒绝**的,所以"建还是改"的判定只能在工具这一侧
5
5
  // (先读一次 `skill-state`)。改的分支走新加的 `skill-update` op,它只认本插件可写的两个根
6
- // (hub = 导入落点 / dsh = 新建默认落点,2026-10-15 裁定)里的胜出者。
6
+ // (hub = 导入落点 / dsh = 新建默认落点)里的胜出者。
7
7
  import { toKebab } from '../skills/core.js';
8
- import { effectiveScope, globalActionNote, isolationOffNote, locateSkillRoot, requireGlobalScope, scopeGlobalOnlyDesc, scopeOnlyNote, scopeSessionDesc, sessionLayerOn, sessionScopeOf, text } from './deps.js';
8
+ import { effectiveScope, globalActionNote, globalUnchangedNote, isolationOffNote, locateSkillRoot, requireGlobalScope, scopeGlobalOnlyDesc, scopeOnlyNote, scopeSessionDesc, sessionLayerOn, sessionScopeOf, text } from './deps.js';
9
+ /** 注册技能域的 model 工具(列表 / 启停 / 新建或更新)。 */
9
10
  export function buildSkillTools(deps) {
10
11
  const { defineTool, register } = deps;
11
- // Skill-facing tools: list, toggle, create. create is gated by the
12
- // tools/pre-execute hook below (the model must ask before writing files).
12
+ // 面向模型的技能工具:list / toggle / create。create 由下面的 tools/pre-execute 钩子把关
13
+ //(写文件之前必须先问过用户)。
13
14
  register(defineTool({
14
15
  name: 'skill_manager_list',
15
- // 关于「官方 `skill` 工具挂载时这条读能力由谁提供」:两处都不写了(2026-10-21 审查 P2)。
16
+ // 关于「官方 `skill` 工具挂载时这条读能力由谁提供」:两处都不写了。
16
17
  // 原先把它放在 `skill_manager_read` 的描述里,但那条工具在官方工具挂载时会被
17
18
  // `CARRIER_DUPLICATES` 直接隐藏 —— 能看到那句话的 agent,条件必然不成立;条件成立的
18
19
  // agent,看不到那句话。这条描述里再写一遍同样是白付 token。工具被隐藏本身就是最准确的信号。
@@ -23,7 +24,7 @@ export function buildSkillTools(deps) {
23
24
  output: { schema: { type: 'string' }, render: (_a, v) => text(v) },
24
25
  async execute(args, exec) {
25
26
  const showAll = Boolean(args && args.all === true);
26
- // 会话层(0.21.2,计划 §8.2「skill_manager_list 按会话过滤」):
27
+ // 会话层(`skill_manager_list` 按会话过滤):
27
28
  // · `sessionId` 让 op 只按**本会话的 cwd** 推导项目技能根(不给 = 全部活动会话的并集,
28
29
  // 两个对话看到同一份清单);
29
30
  // · `overrides` 是本会话的逐条开关,标出"全局开着、本会话关掉"的那几条。
@@ -49,18 +50,18 @@ export function buildSkillTools(deps) {
49
50
  // 踩到的正是这个坑(同一技能在 dsh/agents/claude/custom 各有一份,启错根等于没启)。
50
51
  // 这里把生效/被覆盖如实标出来,让模型(和人)不必猜。
51
52
  //
52
- // 默认只列启用的(2026-09-16 用户裁定):本机 36 条里只有 1 条启用,全列一次约 4.3k
53
+ // 默认只列启用的:本机 36 条里只有 1 条启用,全列一次约 4.3k
53
54
  // 字符且永久留在 transcript。表头始终给出全量口径(多少条 / 多少同名组),所以
54
55
  // 「还有没列出来的」不会变成盲区 —— 要看就传 all=true。
55
56
  const rows = [];
56
57
  const counts = new Map();
57
58
  for (const root of data.roots || []) {
58
- // 来源级停用 = 上层闸:里面的单条技能一条都加载不了。0.21.2 起这一格也有会话层
59
+ // 来源级停用 = 上层闸:里面的单条技能一条都加载不了。这一格也有会话层
59
60
  // (skillSources):场景勾中的来源为开、没勾的为关;拨开一个来源时写侧会把它按
60
61
  // 租约跑起来(来源关着时技能级 enable 会被 core 吞掉)。
61
62
  const rootKey = String(root.key || '');
62
63
  const srcFlag = flagOf('skillSources', rootKey);
63
- // 没有会话层时落到**全局意图**(`globalOn`,0.21.2),不是运行态(`enabled`):
64
+ // 没有会话层时落到**全局意图**(`globalOn`),不是运行态(`enabled`):
64
65
  // 租约期间两者不同,读运行态会把"只为几个对话开着"报成"全局开着"。
65
66
  const rootEnabled = typeof srcFlag === 'boolean' ? srcFlag
66
67
  : (typeof root.globalOn === 'boolean' ? root.globalOn : root.enabled !== false);
@@ -80,7 +81,7 @@ export function buildSkillTools(deps) {
80
81
  // 读运行态会把"别的对话临时开着"报成"全局开着"(与上面来源那一格同一条)。
81
82
  const skillGlobal = typeof skill.globalOn === 'boolean' ? skill.globalOn : globalEnabled;
82
83
  const enabled = rootEnabled && (typeof over === 'boolean' ? over : skillGlobal);
83
- // 带标签的 `k: v` 串(2026-10-14 对抗性审查 P1-1):此前是无列头的 pipe 串,两个标记
84
+ // 带标签的 `k: v` 串:此前是无列头的 pipe 串,两个标记
84
85
  // (`shadowed by <root>` / `preferred`)还会挤在同一格里、都没有标签 —— 模型得猜哪段
85
86
  // 是字段、哪段是标记,以及 `preferred` 到底是什么(它此前**全仓没有定义**)。
86
87
  // 与 `mcp_manager_list` 的 `server:` / `level:` / `user-hint:` 同款。
@@ -106,7 +107,7 @@ export function buildSkillTools(deps) {
106
107
  }
107
108
  const dupGroups = [...counts.values()].filter((n) => n > 1).length;
108
109
  const shown = showAll ? rows : rows.filter((row) => row.enabled);
109
- // 会话层(0.21.2):项目技能根按**本会话的 cwd** 推导,所以这份清单可能只是这个对话
110
+ // 会话层:项目技能根按**本会话的 cwd** 推导,所以这份清单可能只是这个对话
110
111
  // 看得到的那些。不说清的话,模型会拿它回答"本机装了哪些技能"。
111
112
  const sessionNote = scoped === null
112
113
  ? ''
@@ -144,7 +145,7 @@ export function buildSkillTools(deps) {
144
145
  if (!wanted)
145
146
  throw new Error('name is required');
146
147
  const rootWanted = String((args && args.root) || '').trim();
147
- // 会话层(0.21.2):项目技能根按本会话的 cwd 推导 —— 与 skill_manager_list 同一份口径,
148
+ // 会话层:项目技能根按本会话的 cwd 推导 —— 与 skill_manager_list 同一份口径
148
149
  // 否则「列表里有、读不到」(两个对话的 cwd 不同时项目技能各有一份)。
149
150
  const scoped = sessionScopeOf(deps, exec && exec.agent);
150
151
  const overrides = scoped?.scope?.skills;
@@ -168,7 +169,7 @@ export function buildSkillTools(deps) {
168
169
  shadowedBy: skill.shadowedBy && skill.shadowedBy.root ? String(skill.shadowedBy.root) : '',
169
170
  preferred: skill.preferred === true,
170
171
  // 与 skill_manager_list 同一套启停推导(影子副本没有 enabled 字段)。
171
- // 会话层(0.21.2):覆盖优先 —— 否则「列表里说关着、读出来说 enabled」两处打架。
172
+ // 会话层:覆盖优先 —— 否则「列表里说关着、读出来说 enabled」两处打架。
172
173
  enabled: (() => {
173
174
  const g = skill.enabled !== undefined
174
175
  ? skill.enabled === true
@@ -181,8 +182,8 @@ export function buildSkillTools(deps) {
181
182
  }
182
183
  if (!hits.length) {
183
184
  // 「去调 skill_manager_list」那句:那条工具在出厂默认里就是关着的,点名一条模型没有的
184
- // 工具只会让它白跑一趟(执行侧拦住,而它看不出为什么)。判据按 **agent**(2026-10-14
185
- // 对抗性审查 P0-1 的同一条纪律):人设用 `toolsDeny` 砍掉它时,全局开关看着是开的。
185
+ // 工具只会让它白跑一趟(执行侧拦住,而它看不出为什么)。判据按 **agent**:
186
+ // 人设用 `toolsDeny` 砍掉它时,全局开关看着是开的。
186
187
  const listHint = deps.toolVisibleFor('skill_manager_list', exec && exec.agent)
187
188
  ? ' — call skill_manager_list (pass all=true) to see what is installed'
188
189
  : '';
@@ -203,7 +204,7 @@ export function buildSkillTools(deps) {
203
204
  marks.push('preferred copy');
204
205
  if (!picked.enabled)
205
206
  marks.push('disabled');
206
- // 会话层(0.21.2):本会话关掉的技能照样读得到正文(读 ≠ 生效),但必须说清 ——
207
+ // 会话层:本会话关掉的技能照样读得到正文(读 ≠ 生效),但必须说清 ——
207
208
  // 不说的话模型会以为自己已经掌握了它、下一轮却看不到它。
208
209
  const overHere = scoped?.scope?.skills?.[picked.rootKey + '/' + wanted];
209
210
  if (overHere === false)
@@ -211,7 +212,7 @@ export function buildSkillTools(deps) {
211
212
  const dup = hits.filter((hit) => !hit.shadowedBy).length > 1
212
213
  ? hits.filter((hit) => !hit.shadowedBy).map((hit) => hit.rootKey).filter((k) => k !== picked.rootKey)
213
214
  : [];
214
- // 附件清单(2026-10-16):技能正文常写着「详见 references/xxx.md」,而这一条工具是模型
215
+ // 附件清单:技能正文常写着「详见 references/xxx.md」,而这一条工具是模型
215
216
  // 读技能的唯一入口 —— 不列出来,它就会因为"看到的目录里没有那个文件"而凭空猜内容。
216
217
  // 只报名与大小、不报正文:正文要走宿主文件工具,这里塞进 transcript 太重。
217
218
  const attachments = Array.isArray(detail.attachments) ? detail.attachments : [];
@@ -241,29 +242,29 @@ export function buildSkillTools(deps) {
241
242
  description: 'Enable or disable one DSH skill, or a whole source folder via `source`. Pass `prefer` (with `name` + `root`) to make that copy win a same-name collision, or to clear the recorded choice. Enabling a shadowed copy has no effect. Reversible. Only when the user asks or approves.',
242
243
  parameters: {
243
244
  name: { type: 'string', description: 'Skill name (kebab-case).' },
244
- // `enabled` 从 required 改成"要么给 enabled、要么给 prefer"(2026-10-15):
245
+ // `enabled` 从 required 改成"要么给 enabled、要么给 prefer":
245
246
  // prefer 是一次独立的写(`skill-prefer`),模型不该为了改首选来源先被迫拨一次开关。
246
247
  // 缺省仍然**拒绝**(execute 里那条守卫),不然 `args.enabled ? enable : disable`
247
248
  // 会把"忘了给"静默当成"停用"。
248
249
  enabled: { type: 'boolean', description: 'true to enable, false to disable. Required unless you only pass `prefer`.' },
249
250
  source: { type: 'string', description: 'A source root key to switch as a whole (dsh/hub/agents/codex/claude or a project key).' },
250
251
  root: { type: 'string', description: 'Source root the skill lives in (with `name`). Default: whichever source holds it. Required with `prefer`.' },
251
- // 同名首选来源(2026-10-15 注入文本审查)。此前这条工具的回执写着
252
+ // 同名首选来源。此前这条工具的回执写着
252
253
  // "or make this root the preferred copy **in the panel**" —— 明明一个布尔能解决,
253
254
  // 却把用户推去界面点。而 `skill-prefer` / `skill-unprefer` 两个 op 早就在(面板在用)。
254
255
  // 代价为零:本工具在出厂默认名单里就是关着的,加参数不进默认上下文。
255
256
  prefer: { type: 'boolean', description: 'true = the copy in `root` wins this name\'s collision; false = drop the recorded choice. Needs `name` + explicit `root`; omit = leave it.' },
256
- // 决策 10(2026-10-19):默认只改**这个对话**。写全局要显式说明。
257
- // 0.21.2:`source` 也有会话版本了(拨开时来源按租约跑起来 —— 来源关着时技能级
257
+ // 默认只改**这个对话**。写全局要显式说明。
258
+ // `source` 也有会话版本(拨开时来源按租约跑起来 —— 来源关着时技能级
258
259
  // 开关会被 core 吞掉,所以那一步在回执里如实交代)。
259
- scope: { type: 'string', enum: ['session', 'global'], description: scopeSessionDesc('turning a source or skill on may run that source as a lease, invisible outside that scope (isolation on only). global = every conversation (the state file).') },
260
+ scope: { type: 'string', enum: ['session', 'global'], description: scopeSessionDesc('turning a source or skill on here may start that source for this scope only. global = every conversation.') },
260
261
  },
261
262
  output: { schema: { type: 'string' }, render: (_a, v) => text(v) },
262
263
  async execute(args, exec) {
263
264
  if (args && args.enabled !== undefined && typeof args.enabled !== 'boolean') {
264
265
  throw new Error('enabled must be true or false (omit it to only change the preferred copy)');
265
266
  }
266
- // 场景锁冻结的是**全局**写入(决策 11):本会话的逐条开关写的是侧车,与锁无关 ——
267
+ // 场景锁冻结的是**全局**写入:本会话的逐条开关写的是侧车,与锁无关 ——
267
268
  // 与面板的 `scopeWriteLocked()` 同一口径。只有真会改全局状态的那几条才过守卫。
268
269
  // 全局粒度一律走全局:那一档没有会话层,写的就是状态文件 —— 所以要过场景锁。
269
270
  const sessionWrite = Boolean(args && args.enabled !== undefined && effectiveScope(deps, args) === 'session' &&
@@ -275,7 +276,7 @@ export function buildSkillTools(deps) {
275
276
  }
276
277
  const name = String((args && args.name) || '').trim();
277
278
  const source = String((args && args.source) || '').trim();
278
- // `prefer` 的三态与它自己的前置条件(2026-10-15):省略 = 不碰首选表;
279
+ // `prefer` 的三态与它自己的前置条件:省略 = 不碰首选表;
279
280
  // true / false = 设 / 撤。**必须点名 root** —— 默认值 `dsh` 在"同名首选"这件事上
280
281
  // 恰恰是最容易猜错的一格(要选赢的往往是**非 dsh** 那一份),所以这里不接受默认值。
281
282
  const preferGiven = Boolean(args && args.prefer !== undefined);
@@ -290,7 +291,7 @@ export function buildSkillTools(deps) {
290
291
  throw new Error('missing argument: name (one skill) or source (a whole source folder)');
291
292
  if (preferGiven && !name)
292
293
  throw new Error('missing argument: prefer needs name');
293
- // 会话层(0.21.2):首选来源是**全局**的一张表,没有会话版本。`scope` 省略时默认是
294
+ // 会话层:首选来源是**全局**的一张表,没有会话版本。`scope` 省略时默认是
294
295
  // session(见参数说明),所以这里必须要求显式 `scope="global"` —— 否则一次「本会话
295
296
  // 切个技能」会静默改掉全局的同名胜负。
296
297
  const scopeArg = String((args && args.scope) || '');
@@ -310,7 +311,7 @@ export function buildSkillTools(deps) {
310
311
  if (source) {
311
312
  if (args.root !== undefined)
312
313
  throw new Error('source is already a source-level key; do not pass root with it');
313
- // 会话层(0.21.2):来源这一格有会话版本了(`skillSources`)。拨开时 op 侧会把它
314
+ // 会话层:来源这一格有会话版本了(`skillSources`)。拨开时 op 侧会把它
314
315
  // 在**全局**启用(来源关着时技能级 enable 会被 core 吞掉);拨关只影响本会话的
315
316
  // 「看不看得到」,别的对话与全局状态都不动。
316
317
  if (effectiveScope(deps, args) === 'session') {
@@ -320,12 +321,12 @@ export function buildSkillTools(deps) {
320
321
  if (!sc || sc.ok === false)
321
322
  throw new Error((sc && sc.error) || 'failed to switch this source here');
322
323
  const warnings = sc.warnings !== undefined && sc.warnings.length > 0 ? '\n' + sc.warnings.join('\n') : '';
323
- return 'OK: source ' + source + ' now ' + (args.enabled ? 'enabled' : 'disabled') + scopeOnlyNote() +
324
+ return 'OK: source ' + source + ' now ' + (args.enabled ? 'enabled' : 'disabled') + scopeOnlyNote(deps) +
324
325
  (sc.cleared === true ? ' (that matches what this scope would see anyway, so the override was removed)' : '') + warnings +
325
- (warnings === '' ? '\nThe global source switch is unchanged; other conversations keep theirs.' : '') +
326
+ (warnings === '' ? '\n' + globalUnchangedNote(deps) : '') +
326
327
  ' Pass scope="global" to change it for every conversation.';
327
328
  }
328
- // 全局来源开关 = **意图**(0.21.2):off 之后仍被会话认领的来源保持启用(租约),
329
+ // 全局来源开关 = **意图**:off 之后仍被会话认领的来源保持启用(租约)
329
330
  // 只是别的会话看不到它下面的技能。直接改来源状态会让这次会话级开启串到所有会话 ——
330
331
  // 与 MCP 那条是同一个修法。
331
332
  if (deps.scopeIntentSet) {
@@ -353,11 +354,11 @@ export function buildSkillTools(deps) {
353
354
  (syncErr ? '\nWARN: the current scene archive was not synced (' + syncErr + ')' : '') +
354
355
  '\nnote: a whole source folder is global (every conversation); omit scope to switch it here only.' + isolationOffNote(deps);
355
356
  }
356
- // 不给 root 就在全部来源里找(2026-10-15 smoke-test P0-1):`skill_manager_save` 的落点
357
+ // 不给 root 就在全部来源里找:`skill_manager_save` 的落点
357
358
  // 是 hub(`tool-management/skills/`),而这里的默认值原本是 dsh —— 「建完就启用」这条
358
359
  // 最自然的链路必然报「技能不存在」。默认值改哪一边都不对(面板是显式传 root 的,
359
360
  // 两边都依赖各自的默认),所以判定放到工具侧:按名字找**胜出的那一份**。
360
- /** 会话覆盖键用的声明名(与目录名可以不同;0.21.2)。 */
361
+ /** 会话覆盖键用的声明名(与目录名可以不同)。 */
361
362
  let canonicalName = name;
362
363
  const resolveRoot = async () => {
363
364
  const explicit = String((args && args.root) || '').trim();
@@ -405,7 +406,7 @@ export function buildSkillTools(deps) {
405
406
  '\nnote: which copy wins a name collision is a global setting (it has no per-conversation version).');
406
407
  }
407
408
  if (args.enabled !== undefined) {
408
- // 决策 10(2026-10-19):默认写**本会话**(别的对话不受影响),`scope: "global"` 才改状态文件。
409
+ // 默认写**本会话**(别的对话不受影响),`scope: "global"` 才改状态文件。
409
410
  // 会话层只改"列不列"(决策:会话层不碰启停本身),所以它不需要冻结守卫与场景档案同步 ——
410
411
  // 那两样保护的是全局状态。
411
412
  if (effectiveScope(deps, args) === 'session') {
@@ -419,9 +420,9 @@ export function buildSkillTools(deps) {
419
420
  // 拨开时 op 侧可能顺手在全局把它的**来源**启用(来源关着时技能级开关会被 core 吞掉),
420
421
  // 那一步的影响由 `warnings` 如实带出来;没动全局时才说"全局设置未变"。
421
422
  const warnings = sc.warnings !== undefined && sc.warnings.length > 0 ? '\n' + sc.warnings.join('\n') : '';
422
- out.push('OK: ' + args.name + ' now ' + (args.enabled ? 'enabled' : 'disabled') + scopeOnlyNote() +
423
+ out.push('OK: ' + args.name + ' now ' + (args.enabled ? 'enabled' : 'disabled') + scopeOnlyNote(deps) +
423
424
  (sc.cleared === true ? ' (that matches what this scope would see anyway, so the override was removed)' : '') + warnings +
424
- (warnings === '' ? '\nThe global setting is unchanged; other conversations keep theirs.' : '') +
425
+ (warnings === '' ? '\n' + globalUnchangedNote(deps) : '') +
425
426
  ' Pass scope="global" to change it for every conversation.');
426
427
  return out.join('\n');
427
428
  }
@@ -450,7 +451,7 @@ export function buildSkillTools(deps) {
450
451
  catch {
451
452
  shadowedBy = '';
452
453
  }
453
- // 出路指向**本工具自己的参数**(2026-10-15 注入文本审查):此前写的是
454
+ // 出路指向**本工具自己的参数**:此前写的是
454
455
  // "or make this root the preferred copy in the panel" —— 模型读得到这句却做不到,
455
456
  // 只能转述给用户去点界面。现在 `prefer` 就在同一张参数表里;而这条工具在出厂默认
456
457
  // 名单里是关着的,模型既然调得到它,就一定拿得到这个参数(不会指到一条它没有的工具)。
@@ -469,23 +470,21 @@ export function buildSkillTools(deps) {
469
470
  // 「新建技能」动作,人点界面和模型调用会落到两个不同的根)。当前两边都是 **DSH 技能目录**
470
471
  // (`~/.dsh/skills/`):UI 是 `43-skills.js` 的 `defaultCreateRoot`,模型侧就是下面这句
471
472
  // `skill-create` 的 op 默认值。hub(`tool-management/skills/`)只留给「导入技能」功能
472
- // (用户裁定 2026-10-15)。历史上两边曾一个 dsh 一个 hub,靠本条纪律对齐。
473
+ // 。历史上两边曾一个 dsh 一个 hub,靠本条纪律对齐。
473
474
  //
474
475
  // 改的分支**认全部来源里的胜出者**:同名技能在 dsh/hub/项目根各有一份时只有一份生效,
475
476
  // 改错那一份会返回 OK 而技能毫无变化 —— 那层判定在 `skill-update` op 里,它同时要求
476
477
  // 胜出者落在本插件可写的两个根(hub 导入落点 / dsh 新建落点)。也就是说:本工具建出来
477
478
  // 的技能(只落在 dsh)一定还能被本工具改回去,不会建完就改不动。
478
479
  //
479
- // 描述里的落点路径(`under DSH_HOME/tool-management/skills`)删掉(2026-10-15 注入文本
480
- // 审查):模型不按路径行动,而这段路径还与本轮 `remove.ts` 头注释写的落点口径不一
481
- // (那里写 hub 的 tool-management/skills/)。真正要它知道的是"建在哪一侧",
482
- // 而"只认本插件写的技能"那半句已经说清了。
480
+ // 描述里不写落点路径:模型不按路径行动,而写死路径还会与 `remove.ts` 头注释里的落点
481
+ // 口径打架。真正要它知道的是"建在哪一侧",而"只认本插件写的技能"那半句已经说清了。
483
482
  description: 'Create a DSH skill, or update the one that already has this name — the receipt says which. Only skills this plugin wrote can be updated. Only on the user\'s instruction.',
484
483
  parameters: {
485
484
  name: { type: 'string', required: true, description: 'Skill name; normalized to kebab-case (≤128 chars, [a-z0-9-]).' },
486
485
  description: { type: 'string', description: 'A concise routing description (≤500 chars). Required when creating; omit = keep.' },
487
486
  body: { type: 'string', description: 'Markdown instructions (≤256 KiB). Required when creating; omit = keep.' },
488
- // 0.21.2:技能 / 人设 / 场景 / MCP 服务器是**机器级**对象,没有「本会话的一份」。
487
+ // 技能 / 人设 / 场景 / MCP 服务器是**机器级**对象,没有「本会话的一份」。
489
488
  // 这个参数只为一件事:模型以为自己在改会话时,当场纠回来(见 deps.ts 的 requireGlobalScope)。
490
489
  scope: { type: 'string', enum: ['session', 'global'], description: scopeGlobalOnlyDesc('a skill file is machine-wide', 'switch it here instead of editing it') },
491
490
  },
@@ -531,13 +530,13 @@ export function buildSkillTools(deps) {
531
530
  throw new Error((r && r.error) || 'skill create failed');
532
531
  const data = r.data || {};
533
532
  // 新建的技能默认停用(与 MCP / 人设同口径)。这句必须留 —— 不说的话模型会直接去用,
534
- // 然后发现技能不生效,而它不知道自己少拨了一个开关(smoke-test 报告 P1-3:三个 save
533
+ // 然后发现技能不生效,而它不知道自己少拨了一个开关(三个 save
535
534
  // 里只有这一条不报启用状态)。点名的 `skill_manager_switch` 在出厂默认名单里就是关着的,
536
535
  // 关着就改说"用户启用后才能用",别指一条模型没有的工具。
537
- const enableHint = deps.toolVisible('skill_manager_switch')
536
+ const enableHint = deps.toolVisibleFor('skill_manager_switch', exec && exec.agent)
538
537
  ? ' (created disabled; use skill_manager_switch to enable it)'
539
538
  : ' (created disabled; the user has to enable it first)';
540
- // 会话层(0.21.2):技能文件是**机器级**的,本会话的开关只决定这里看不看得到它。
539
+ // 会话层:技能文件是**机器级**的,本会话的开关只决定这里看不看得到它。
541
540
  return 'Created DSH skill ' + (data.name || kebab) + ' at ' + (data.path || '(unknown)') + enableHint +
542
541
  globalActionNote(deps, exec && exec.agent, 'skills', 'skill');
543
542
  }
@@ -1,4 +1,4 @@
1
- // 子智能体域的 model 工具(2026-09-19 从 index.ts 的注册区抽出;2026-09-23 合并):
1
+ // 子智能体域的 model 工具(从 index.ts 的注册区抽出;合并):
2
2
  // subagent_manager_list / subagent_manager_run / _switch / _save。
3
3
  //
4
4
  // exec.agent / exec.signal 由工具运行时提供(parent 与取消信号的官方通道)。
@@ -6,15 +6,14 @@
6
6
  // 两个工具**各自** try/catch:一个注册失败不该把另一个也带走,而且失败必须说得出
7
7
  // 「是哪一个没注册上」——只打一行日志时,模型侧只会「查无此工具」、界面毫无痕迹。
8
8
  import { defineSubagentManagerListTool, defineSubagentManagerRunTool } from '../subagents/tools.js';
9
- import { effectiveScope, globalActionNote, isolationOffNote, requireGlobalScope, scopeGlobalOnlyDesc, scopeOnlyNote, scopeSessionDesc, sessionLayerOn, text } from './deps.js';
9
+ import { effectiveScope, globalActionNote, globalUnchangedNote, isolationOffNote, requireGlobalScope, scopeGlobalOnlyDesc, scopeOnlyNote, scopeSessionDesc, sessionLayerOn, text } from './deps.js';
10
10
  /**
11
11
  * 高频高级字段:`subagent_manager_save` 与 op 之间原样透传的那几个(省略 = 不出现 = op 侧保持)。
12
12
  *
13
- * 2026-10-15:从"面板专有"里挑出**配置人设时最常改的三类**交给模型 —— `model`(换模型)、
14
13
  * `continuable`(允许追问)、`tools` / `toolsDeny`(工具黑白名单)。此前模型看得见却改不了
15
14
  * (`subagent_manager_save` 只读回它们防止冲掉,旧注释把这条写成"留给面板")。
16
15
  *
17
- * **刻意不加** `provider` / `reasoningEffort` / `catalogDepth`:都是低频(用户裁定
16
+ * **刻意不加** `provider` / `reasoningEffort` / `catalogDepth`:都是低频(用户要求
18
17
  * "使用频率高的才需要,太多功能反而冗余、浪费 token")。`toolsByPreset`(嵌套对象)同理。
19
18
  */
20
19
  const ADVANCED_FIELDS = ['model', 'continuable', 'tools', 'toolsDeny'];
@@ -25,6 +24,7 @@ function advancedArgs(args) {
25
24
  out[k] = args[k];
26
25
  return out;
27
26
  }
27
+ /** 注册人设域的 model 工具(列表 / 委派 / 新建或更新)。 */
28
28
  export function buildSubagentTools(deps) {
29
29
  const { defineTool, register } = deps;
30
30
  const recordFailure = (name, e) => {
@@ -53,12 +53,12 @@ export function buildSubagentTools(deps) {
53
53
  try {
54
54
  // 工具限制按**当前会话的 Agent 预设**下发:父会话跑在哪个预设,就用那个预设那一行的
55
55
  // 白/黑名单(`decideToolFilter`),名单里已消失的工具名会被丢掉并在结果里如实说明。
56
- // ⚠️ 必须 `Object.create`,**不能**用对象展开 —— 这是 0.15.0 起就存在的实际故障:
56
+ // ⚠️ 必须 `Object.create`,**不能**用对象展开 —— 这是就存在的实际故障:
57
57
  // `deps.subagentService` 是 index.ts 用 `Object.assign(Object.create(真实服务), { ops })`
58
58
  // 造的**包装层**,只有 `ops` 落在自有属性上,`list` / `runSerial` 都挂在原型链上。对象展开
59
59
  // 只复制**自有可枚举**属性,展开后只剩 `{ ops }` —— 于是 `subagent_manager_run` 每次一进
60
60
  // execute 就在 `subagents.list()` 上抛 `subagents.list is not a function`(人设查不到就
61
- // 谈不上委派;0.19.0 测「允许追问」时才被暴露出来,因为那条通道同样要过这一步)。
61
+ // 谈不上委派;测「允许追问」时才被暴露出来,因为那条通道同样要过这一步)。
62
62
  // `Object.create` 保持同一条原型链:`ops` 仍是审计过的那份,`list` / `runSerial` 回真实服务。
63
63
  // 与 index.ts 造这个包装层时用的是同一个写法(那边注释写的是「原型链回真实服务,其余读法一字不动」)。
64
64
  register(defineTool(defineSubagentManagerRunTool(Object.assign(Object.create(deps.subagentService), { sceneLists: deps.sceneLists, toolFilterFor: deps.toolFilterFor, flagFor: deps.subagentFlagFor }))));
@@ -71,7 +71,7 @@ export function buildSubagentTools(deps) {
71
71
  // 宿主没挂 `dsh-subagent-*` 也照样该能用(恰恰那时更需要:能把人设建好、开关拨对,
72
72
  // 等 provider 回来就可用)。所以各自单独 try/catch,不与 `_run` 绑在一起失败。
73
73
  //
74
- // 参数表(2026-10-15 扩):基础四项(name / description / body / output)之外,把高级字段
74
+ // 参数表(扩):基础四项(name / description / body / output)之外,把高级字段
75
75
  // 也接上 —— 此前工具限制(tools / toolsDeny)与 provider / model / reasoningEffort /
76
76
  // catalogDepth / continuable 只读回防止冲掉、模型改不了,于是"给这个人设换个便宜模型"
77
77
  // 这类要求模型手里没有出口,描述里也没写"去面板"。现在能设的都在参数里说清,
@@ -84,8 +84,8 @@ export function buildSubagentTools(deps) {
84
84
  parameters: {
85
85
  name: { type: 'string', required: true, description: 'Persona name.' },
86
86
  enabled: { type: 'boolean', required: true, description: 'true = enable, false = disable.' },
87
- // 决策 10(2026-10-19):默认只改**这个对话**。写全局要显式说明。
88
- scope: { type: 'string', enum: ['session', 'global'], description: scopeSessionDesc('global = every conversation (the persona state file).') },
87
+ // 默认只改**这个对话**。写全局要显式说明。
88
+ scope: { type: 'string', enum: ['session', 'global'], description: scopeSessionDesc('global = every conversation.') },
89
89
  },
90
90
  output: { schema: { type: 'string' }, render: (_a, v) => text(String(v)) },
91
91
  async execute(args, exec) {
@@ -94,7 +94,7 @@ export function buildSubagentTools(deps) {
94
94
  // 这个对话里的人设凭空消失(全局那条倒是没动,更难查)。
95
95
  if (typeof (args && args.enabled) !== 'boolean')
96
96
  throw new Error('missing argument: enabled must be true or false');
97
- // 场景锁冻结的是**全局**写入(决策 11):会话覆盖写侧车,与锁无关。
97
+ // 场景锁冻结的是**全局**写入:会话覆盖写侧车,与锁无关。
98
98
  // 全局粒度下一律走全局:那一档没有会话层,写的就是状态文件。
99
99
  const sessionOnly = effectiveScope(deps, args) === 'session';
100
100
  if (!sessionOnly) {
@@ -102,7 +102,7 @@ export function buildSubagentTools(deps) {
102
102
  if (blocked)
103
103
  throw new Error(blocked);
104
104
  }
105
- // 决策 10:默认写**本会话**(别的对话不受影响),`scope: "global"` 才改状态文件。
105
+ // 默认写**本会话**(别的对话不受影响),`scope: "global"` 才改状态文件。
106
106
  // 会话层只改"列不列、调不调得动",不碰启停本身 —— 所以不需要场景档案同步。
107
107
  if (sessionOnly) {
108
108
  if (!deps.sessionScopeSet)
@@ -110,9 +110,9 @@ export function buildSubagentTools(deps) {
110
110
  const sc = await deps.sessionScopeSet(exec && exec.agent, 'subagents', name, args.enabled === true);
111
111
  if (!sc || sc.ok === false)
112
112
  throw new Error((sc && sc.error) || 'failed to switch this persona here');
113
- return 'OK: persona ' + name + ' ' + (args.enabled === true ? 'enabled' : 'disabled') + scopeOnlyNote() +
114
- (sc.cleared === true ? ' (that matches the global setting, so the per-conversation override was removed)' : '') +
115
- '. The global setting is unchanged; other conversations keep theirs. Pass scope="global" to change it for every conversation.';
113
+ return 'OK: persona ' + name + ' ' + (args.enabled === true ? 'enabled' : 'disabled') + scopeOnlyNote(deps) +
114
+ (sc.cleared === true ? ' (that matches what this scope would see anyway, so the override was removed)' : '') +
115
+ '. ' + globalUnchangedNote(deps) + ' Pass scope="global" to change it for every conversation.';
116
116
  }
117
117
  const r = await ops()['subagent-toggle']({ name, enabled: args.enabled === true });
118
118
  if (!r || r.ok === false)
@@ -136,12 +136,11 @@ export function buildSubagentTools(deps) {
136
136
  // 却直通过去,就会把人设正文与工具限制一起冲掉。这里先读现状再合并 —— 合并发生在
137
137
  // 工具这一侧,op 的语义不动。
138
138
  //
139
- // 0.14.0:create 与 update 并成一条 upsert。判定也只能在这里做 —— `subagent-create`
140
- // 对同名是拒绝的、`subagent-update` 对不存在的名字报错,而模型手里的目录可能已经过期。
139
+ // create 与 update 并成一条 upsert。判定也只能在这里做 —— `subagent-create` 对同名是
140
+ // 拒绝的、`subagent-update` 对不存在的名字报错,而模型手里的目录可能已经过期。
141
141
  //
142
- // 落点路径(`at ~/.dsh/tool-management/subagents/<name>.md`)删掉(2026-10-15 注入文本
143
- // 审查):模型不按路径行动,这条工具也没有"给我路径"的用法(要读正文有 `list` +
144
- // 宿主的文件工具,而人设正文本来就是给它自己当系统提示词用的)。
142
+ // 描述里不写落点路径:模型不按路径行动,这条工具也没有"给我路径"的用法(要读正文有
143
+ // `list` + 宿主的文件工具,而人设正文本来就是给它自己当系统提示词用的)。
145
144
  description: 'Create a persona, or update the one with this name — the receipt says which; omitted fields keep their values. Write `body` as who this is and how it judges its own work, not steps or paths (those belong to the task); put hard output requirements in `output`, one per line. Also settable: `model` (\'\' = inherit), `continuable`, `tools`/`toolsDeny` ([] = clear) — other routing/limit fields aren\'t. Blocked while the active scene is locked. Only on the user\'s instruction.',
146
145
  parameters: {
147
146
  name: { type: 'string', required: true, description: 'Persona name (= file name); ≤64 chars, one path segment — no / \\ or < > : " | ? *, no leading dot, no reserved device name, no trailing dot or space.' },
@@ -153,7 +152,7 @@ export function buildSubagentTools(deps) {
153
152
  continuable: { type: 'boolean', description: 'true = this persona may be followed up (runs in the background and returns an agent id); false = one-shot.' },
154
153
  tools: { type: 'array', items: { type: 'string' }, description: 'Tool allowlist — the subagent keeps only these tools. [] = clear.' },
155
154
  toolsDeny: { type: 'array', items: { type: 'string' }, description: 'Tool denylist — removed from the subagent; wins over the allowlist. [] = clear.' },
156
- // 0.21.2:人设是**机器级**文件,没有「本会话的一份」。这个参数只为一件事:
155
+ // 人设是**机器级**文件,没有「本会话的一份」。这个参数只为一件事:
157
156
  // 模型以为自己在改会话时,当场纠回来(见 deps.ts 的 requireGlobalScope)。
158
157
  scope: { type: 'string', enum: ['session', 'global'], description: scopeGlobalOnlyDesc('a persona file is machine-wide', 'switch it here instead of editing it') },
159
158
  },
@@ -193,10 +192,10 @@ export function buildSubagentTools(deps) {
193
192
  // 然后收到"人设不可用",而它并不知道自己少拨了一个开关。点名的 subagent_manager_switch
194
193
  // 在出厂默认名单里就是关着的 —— 关着就改说"用户启用后才能委派",别指一条模型没有的
195
194
  // 工具(与 mcp/skill 的 listHint 同一条纪律)。
196
- const enableHint = deps.toolVisible('subagent_manager_switch')
195
+ const enableHint = deps.toolVisibleFor('subagent_manager_switch', exec && exec.agent)
197
196
  ? ' (created disabled; use subagent_manager_switch to enable it before delegating)'
198
197
  : ' (created disabled; the user has to enable it before you can delegate)';
199
- // 会话层(0.21.2):人设文件是**机器级**的,本会话的开关只决定这里看不看得到它。
198
+ // 会话层:人设文件是**机器级**的,本会话的开关只决定这里看不看得到它。
200
199
  return 'OK: persona ' + String(r.name || name) + ' created' + enableHint +
201
200
  globalActionNote(deps, exec && exec.agent, 'subagents', 'persona');
202
201
  }
@@ -1,30 +1,31 @@
1
- // 「模型工具表」开关(2026-09-23)。
1
+ // 「模型工具表」开关。
2
2
  //
3
3
  // 为什么要有它:工具表是按**每个请求**付钱的 —— 每一轮都随请求发出工具 schema,哪怕这一轮
4
4
  // 根本用不上。关掉某几个工具,它们整份不进请求(不是"把描述写短点"那种省);面板
5
5
  // (118 个 op)与注入通道完全不受影响。
6
6
  //
7
- // 出厂**默认就关着十九条**(57 条里实发 38 条)—— 名单、判据与代价见下面
7
+ // 出厂**默认就关着二十条**(整张表 26 条,每轮实发 6 条)—— 名单、判据与代价见下面
8
8
  // `DEFAULT_HIDDEN_TOOLS`;用户自己额外关的与出厂关的在合计那句里分开报。
9
9
  //
10
10
  // 实测数字(口径:宿主 `recordToolSize` 的 `ceil(JSON.stringify(header.tools).length / 4) + 4`,
11
11
  // 即**字符数 / 4**;界面「模型工具表」那行合计与逐条 ≈tok 就是这份,逐条相加与整份数组
12
12
  // 的算法差不到 1%):
13
- // · 2026-10-20 重测:十九条隐藏 ≈**5,213 tok**(≈20,852 字符),默认可见那六条 ≈**1,547 tok**。
13
+ // · 重测:二十条隐藏 ≈**5,213 tok**(≈20,852 字符),默认可见那六条 ≈**1,547 tok**。
14
14
  // 比 10-18 那份(16,743 字符 ≈4,186)涨了两成 —— 会话作用域这轮给工具描述加了"写本对话
15
15
  // 还是全局""`scope` 参数""租约"这些句子,名单一个字没变。
16
+ // 那次实测的名单里还没有 `memory_manager_search`(它自己 ≈70 tok 未计入)。
16
17
  // · 10-18 那轮 A/B(同一次请求里把十九条逐个打开,前后各跑两轮)净少 **4,119 / 4,197 tok**,
17
18
  // 对照当天那份合计 4,186 略低是正常的(边界按 ceil 逐个算、四条一合并就省下那几个 +4),
18
19
  // 所以它们是**净节省的下界**,不是"省了多少"的上界。**那对数量的是当天那份描述** ——
19
20
  // 描述一改就得重测,新的净省要在真实环境跑 A/B,这里不拿估算冒充实测。
20
21
  //
21
- // ⚠️ **那个口径不是 token 数,别拿它跟别的数直接比**(2026-09-23 用真 BPE 词表实测):
22
+ // ⚠️ **那个口径不是 token 数,别拿它跟别的数直接比**(用真 BPE 词表实测):
22
23
  // 工具描述是英文,`字符数 / 4` 对英文**高估约 10%** —— 18 个工具那一版真实是 ≈3,137 tok(o200k)。
23
24
  // 反方向也一样:注入段是中文,同一个口径对它**低估约 13%**(四段 716 → 真 823)。
24
25
  // 所以"工具表 / 注入"这两个数不是同一把尺子,跨语言比大小会得出错的结论。
25
26
  // 口径本身是**宿主的**(`recordToolSize`),我们改不了;能做的只是知道它偏在哪。
26
27
  //
27
- // 当前环境(2026-10-18 查过,2026-10-20 复述)**没有 BPE 分词器可实测**:306 个官方包里零个
28
+ // 当前环境(查过,复述)**没有 BPE 分词器可实测**:306 个官方包里零个
28
29
  // 词表文件,本机 python site-packages 里也没有 tiktoken / transformers。所以 5,213 只是
29
30
  // **按宿主的尺子**量出来的数,真 BPE 值按上面那条经验约低一成(≈4,7xx)—— 没有实测,别当实测引用。
30
31
  //
@@ -32,7 +33,7 @@
32
33
  // 注入设置(`inject-settings.json`)走同一套写法。
33
34
  //
34
35
  // 谁读这份设置:
35
- // · index.ts 的 op `tool-table`(读写侧车 + 写后刷新可见性与两个目录)—— 0.21.2 起
36
+ // · index.ts 的 op `tool-table`(读写侧车 + 写后刷新可见性与两个目录)——
36
37
  // 带 `sessionId` 的那一支改的是**本对话**的整份名单(存 `scope-overrides.json`),
37
38
  // 这份侧车只剩"新对话的默认模板"与方案库;
38
39
  // · mcp/manager.ts 的 `pluginHiddenTools` —— 官方 `tools.restrict()` 只允许**每个 agent
@@ -42,9 +43,9 @@
42
43
  // · 注入通道与两个目录:目录里「用 `skill_manager_list` 查」这类句子在工具关掉后就是假的。
43
44
  import { INJECT_DOMAIN_KEYS, domainOfTool } from '../context-inject.js';
44
45
  /**
45
- * 出厂默认关掉的**十九条**:整张表 25 条,关掉后**每轮实发 6 条**。
46
+ * 出厂默认关掉的**二十条**:整张表 26 条,关掉后**每轮实发 6 条**。
46
47
  *
47
- * 判据是用户 2026-09-23 的三轮裁定,同一条:**这些信息或动作常态下由注入段与面板承担,
48
+ * 判据只有一条:**这些信息或动作常态下由注入段与面板承担,
48
49
  * 平时也用不到模型自己伸手**。三组:
49
50
  * · **写侧五条** —— 三个 `*_save`(MCP / 技能 / 人设:配置本体在面板上改)+ 提示词两条
50
51
  * (这一族只有两条,而当前生效的那份本来就在 `Current prompt` 注入段里)。
@@ -55,13 +56,11 @@ import { INJECT_DOMAIN_KEYS, domainOfTool } from '../context-inject.js';
55
56
  * 写着当前开着哪些。**`mcp_manager_switch` 刻意留着**:它是"这台先给我关了"这条最常用的
56
57
  * 临时动作的唯一入口,也是 MCP 域留下来的一条腿。
57
58
  *
58
- * 2026-10-14(对抗性审查 P0-2):**`subagent_manager_list` 从这份名单里拿了出来**(十四条)。
59
59
  * 判据与上面那条"注入段承担"不同 —— 人设域**没有官方载体兜底**:MCP / 技能 / 记忆三个域的
60
60
  * 目录即便被压制型预设压掉,也各自还有一条常驻发现路径,而人设目录一旦不注入,模型手里就
61
61
  * 只剩 `subagent_manager_run` 一条可见工具、**无从知道任何人设名**(死路:有工具、没输入)。
62
62
  * 它只有 42 tok,买的是把"注入段是唯一发现路径"这个单点消掉。
63
63
  *
64
- * 2026-10-15:**删除 / 回收站族五条**(`*_manager_remove`)出厂默认关。判据是"删一条记忆 /
65
64
  * 技能 / 人设"是常问的,但它**低频于"读现状 + 拨开关 + 建改定义"**那批,而且面板每个域都有
66
65
  * 删除入口 —— 默认关、要用时在「兼容」页勾上(与另外十四条同一条纪律,不额外付 token)。
67
66
  *
@@ -99,15 +98,16 @@ export const DEFAULT_HIDDEN_TOOLS = Object.freeze([
99
98
  'prompt_manager_apply',
100
99
  'prompt_manager_remove',
101
100
  ]);
102
- /** 出厂默认那份设置:十九条不发(名单与理由见上面),方案清单是空的。 */
101
+ /** 出厂默认那份设置:二十条不发(名单与理由见上面),方案清单是空的。 */
103
102
  export const DEFAULT_TOOL_TABLE_SETTINGS = { hidden: [...DEFAULT_HIDDEN_TOOLS], presets: [] };
104
103
  /** 方案名上限(与 MCP 备注那类输入同风格:短到能在一行里读,长了也没人看)。 */
105
104
  export const PRESET_NAME_MAX_LENGTH = 40;
106
105
  /**
107
- * 场景档案绑定「出厂默认那份」时用的方案名(0.15.0 C1)。
106
+ * 场景档案绑定「出厂默认那份」时用的方案名。
108
107
  * 它不是一个可保存的方案名,只在档案里当哨兵用;解析时用户存的同名方案优先。
109
108
  */
110
- export const FACTORY_TOOL_TABLE_PRESET = 'factory-default'; /** 存得下的方案数上限 —— 侧车是人手能审的文件,不放开。 */
109
+ export const FACTORY_TOOL_TABLE_PRESET = 'factory-default';
110
+ /** 存得下的方案数上限 —— 侧车是人手能审的文件,不放开。 */
111
111
  export const PRESET_MAX_COUNT = 20;
112
112
  const DEFAULT_HIDDEN_SET = new Set(DEFAULT_HIDDEN_TOOLS);
113
113
  /** 夹一份工具名名单(只收非空字符串;重复的只留一份)。 */
@@ -163,7 +163,7 @@ export function toolTableSettingsFrom(raw) {
163
163
  return raw === null || raw === undefined ? DEFAULT_TOOL_TABLE_SETTINGS : normalizeToolTableSettings(raw);
164
164
  }
165
165
  /**
166
- * 严格结构检查(0.21.2):宽松归一化会把「合法 JSON 但形状错了」读成 `hidden: []`
166
+ * 严格结构检查:宽松归一化会把「合法 JSON 但形状错了」读成 `hidden: []`
167
167
  * ——也就是**全部打开**,用户关掉的工具会在执行守卫眼皮底下复活。
168
168
  *
169
169
  * 只把真正影响可见性的字段判为损坏:顶层必须是对象、`hidden` 必须是字符串数组、
@@ -187,9 +187,9 @@ export function classifyToolTableSettings(raw) {
187
187
  return { ok: true, value: normalizeToolTableSettings(raw) };
188
188
  }
189
189
  /**
190
- * 旧工具名 → 新工具名迁移表(0.14.0 与 0.14.x 两轮改名累积)。
190
+ * 旧工具名 → 新工具名迁移表(两轮改名累积)。
191
191
  *
192
- * 为什么必须有它:`tool-table.json` 存的是**用户点名关掉的那些工具**。0.14.0 把五族并成 17 条
192
+ * 为什么必须有它:`tool-table.json` 存的是**用户点名关掉的那些工具**。五族并成 17 条
193
193
  * 之后,旧名在新表里根本不存在 —— 不迁移的话,用户"关掉了某条"的意图会在新名字上**静默失效**
194
194
  * (那条工具照旧每轮发出去,而他以为早就关了)。
195
195
  *
@@ -200,8 +200,8 @@ export function classifyToolTableSettings(raw) {
200
200
  * 误删别人的条目比留着一条死名更糟。
201
201
  */
202
202
  export const LEGACY_TOOL_NAME_MAP = Object.freeze({
203
- // 记忆族:0.14.0 只把 write + update 并成一条 `save`,名字本身没动 —— 所以只有这两条要迁移。
204
- // (0.14.0 开发中途曾把整族改叫 `scene_memory_manager_*`,但那个名字**从未发布**,用户侧
203
+ // 记忆族:只把 write + update 并成一条 `save`,名字本身没动 —— 所以只有这两条要迁移。
204
+ // (开发中途曾把整族改叫 `scene_memory_manager_*`,但那个名字**从未发布**,用户侧
205
205
  // 不可能有它,因此不存在需要从它迁回来的数据。)
206
206
  memory_manager_write: 'memory_manager_save',
207
207
  memory_manager_update: 'memory_manager_save',
@@ -211,7 +211,7 @@ export const LEGACY_TOOL_NAME_MAP = Object.freeze({
211
211
  skill_manager_create: 'skill_manager_save',
212
212
  subagent_manager_create: 'subagent_manager_save',
213
213
  subagent_manager_update: 'subagent_manager_save',
214
- // 0.14.x:「拨一个开关」六域同形 —— `_set_enabled` → `_switch`(与 `mcp_manager_set_enabled`
214
+ // 「拨一个开关」六域同形 —— `_set_enabled` → `_switch`(与 `mcp_manager_set_enabled`
215
215
  // → `mcp_manager_switch` 同一条路)。**改的只是名字,参数不动**(仍是 `enabled` 布尔),
216
216
  // 所以这里是一对一翻译、不涉及语义合并。
217
217
  memory_manager_set_enabled: 'memory_manager_switch',
@@ -249,7 +249,7 @@ export function migrateLegacyToolNames(settings) {
249
249
  return changed ? { settings: { hidden, presets }, changed: true } : { settings, changed: false };
250
250
  }
251
251
  /**
252
- * 新存一份命名方案:**同名不覆盖**(用户 2026-09-23:「保存方案不能同名」)。"保存"这颗按钮
252
+ * 新存一份命名方案:**同名不覆盖**(用户 :「保存方案不能同名」)。"保存"这颗按钮
253
253
  * 不该悄悄改掉一份已有的记录 —— 那是破坏性动作,而它连一句确认都没有。撞名时 `exists=true`
254
254
  * 且原样返回,由调用方在写盘之前挡下来并如实报错。封顶同样由调用方挡(超了要报错,不是静默丢)。
255
255
  */
@@ -276,6 +276,7 @@ export function dropPreset(settings, name) {
276
276
  * API 的 `stream_options.include_usage`)。界面上必须带「≈」。
277
277
  */
278
278
  export const CHARS_PER_TOKEN = 4;
279
+ /** 按宿主的尺子把字节数估成 token 数(经验值,见文件头;不是 BPE 实测)。 */
279
280
  export function estimateTok(bytes) {
280
281
  const value = Number(bytes);
281
282
  if (!Number.isFinite(value) || value <= 0)
package/lib/trash-id.js CHANGED
@@ -1,7 +1,7 @@
1
- // 回收站条目 id:**一个生成器,五个域共用**(2026-10-15 smoke-test P1-7)。
1
+ // 回收站条目 id:**一个生成器,五个域共用**。
2
2
  //
3
3
  // 为什么单独一个文件:`hub.ts` 引了 `skills/core.js` 的 `resolveDshHome`,所以技能域不能反过来
4
- // 引 `hub.ts` 取这个函数 —— 那正好把 2026-10-01 剥层拆掉的那个运行时环重新接上(见 core.ts
4
+ // 引 `hub.ts` 取这个函数 —— 那正好把 剥层拆掉的那个运行时环重新接上(见 core.ts
5
5
  // 头部的层注释)。放到这一叶模块里,两边都只向下引,不产生环。
6
6
  //
7
7
  // 形状:时间戳 base36 + uuid 前 8 位。统一它不是为了审美 —— 五个域的 `*_manager_remove` 都按
@@ -11,6 +11,7 @@
11
11
  // 读写都是**向后兼容**的:读侧只校验「单个合法路径段」(`entryPath` / `isValidSegment`),
12
12
  // 两种形状都过;磁盘上已有的旧条目照旧能列、能恢复。
13
13
  import { randomUUID } from 'node:crypto';
14
+ /** 生成回收站条目 id:时间戳(可排序)+ 随机后缀(防同毫秒撞车)。 */
14
15
  export function newTrashId() {
15
16
  return Date.now().toString(36) + '-' + randomUUID().slice(0, 8);
16
17
  }