dsh-plugin-tool-management 0.21.2 → 0.21.3
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/CHANGELOG.md +38 -1
- package/README.md +1 -1
- package/README_EN.md +1 -1
- package/docs/{update.md → UPDATE.md} +34 -33
- package/lib/approval-policy.js +2 -2
- package/lib/audit-log.js +1 -1
- package/lib/boot/reconcile.js +3 -3
- package/lib/client.js +12 -1
- package/lib/compat/capability-specs.js +13 -17
- package/lib/compat/host-contracts.js +2 -0
- package/lib/compat/host-probe.js +35 -38
- package/lib/compat/host-roots.js +86 -15
- package/lib/compat/preset-reach.js +75 -102
- package/lib/compat/probe.js +68 -117
- package/lib/compat/runtime-notes.js +1 -1
- package/lib/context-inject-contract.js +6 -5
- package/lib/context-inject-frame.js +113 -53
- package/lib/context-inject-select.js +13 -14
- package/lib/context-inject-surface.js +5 -3
- package/lib/context-inject.js +58 -44
- package/lib/desktop-cookie-prune.js +95 -0
- package/lib/diagnostics.js +3 -1
- package/lib/exports/transcript.js +4 -4
- package/lib/host-names.js +6 -6
- package/lib/http-api.js +35 -26
- package/lib/http-fence.js +6 -6
- package/lib/hub.js +12 -13
- package/lib/imports/parsers.js +25 -21
- package/lib/imports/upload.js +5 -1
- package/lib/index.js +238 -231
- package/lib/mcp/disabled-tools.js +1 -0
- package/lib/mcp/loader-token.js +4 -4
- package/lib/mcp/manager.js +93 -114
- package/lib/mcp/override-blocks.js +1 -1
- package/lib/mcp/patch-yaml.js +42 -31
- package/lib/mcp/restart-marker.js +1 -1
- package/lib/mcp/secret-guard.js +6 -6
- package/lib/mcp/state-section.js +110 -69
- package/lib/mcp/tool-visibility.js +21 -22
- package/lib/memories/archive-engine.js +29 -29
- package/lib/memories/archive.js +23 -3
- package/lib/memories/constants.js +40 -127
- package/lib/memories/discovery.js +11 -2
- package/lib/memories/index-io.js +26 -20
- package/lib/memories/projection.js +18 -19
- package/lib/memories/prompt-layer.js +3 -2
- package/lib/memories/service.js +41 -38
- package/lib/memories/snapshot.js +37 -29
- package/lib/op-registry.js +33 -17
- package/lib/ops/candidates.js +3 -2
- package/lib/ops/compat.js +10 -9
- package/lib/ops/ctx.js +1 -1
- package/lib/ops/memory.js +18 -18
- package/lib/ops/prompts.js +8 -8
- package/lib/ops/quick-prompts.js +1 -0
- package/lib/ops/scene-records.js +23 -24
- package/lib/ops/scene-sync.js +8 -7
- package/lib/ops/scope.js +31 -30
- package/lib/ops/sessions.js +10 -9
- package/lib/ops/snapshot.js +10 -9
- package/lib/ops/state-doctor.js +6 -6
- package/lib/ops/trash-retention.js +2 -1
- package/lib/ops/trash.js +6 -6
- package/lib/prompts/preset-id.js +1 -1
- package/lib/prompts/project-instructions.js +3 -3
- package/lib/prompts/quick-service.js +1 -0
- package/lib/prompts/service.js +13 -12
- package/lib/request-gate.js +26 -25
- package/lib/scene-linkage.js +6 -5
- package/lib/scene-prompt-sync.js +10 -9
- package/lib/scene-settings.js +1 -0
- package/lib/scenes/candidates.js +9 -10
- package/lib/scope/intent-store.js +1 -0
- package/lib/scope/intent.js +10 -10
- package/lib/scope/resolve.js +6 -6
- package/lib/scope/scope-overrides.js +17 -17
- package/lib/scope/store.js +1 -0
- package/lib/sessions/archive-schemas.js +9 -0
- package/lib/sessions/bridge.js +42 -56
- package/lib/sessions/history.js +6 -7
- package/lib/sessions/workspace.js +21 -23
- package/lib/settings-sidecars.js +1 -0
- package/lib/sidebar-settings.js +1 -0
- package/lib/skills/catalog.js +9 -10
- package/lib/skills/core-util.js +5 -0
- package/lib/skills/core.js +35 -22
- package/lib/skills/frontmatter.js +26 -14
- package/lib/skills/homes.js +2 -0
- package/lib/skills/import-pipeline.js +8 -1
- package/lib/skills/manager-state.js +30 -6
- package/lib/skills/official.js +14 -11
- package/lib/skills/readonly-discovery.js +1 -0
- package/lib/skills/service.js +19 -18
- package/lib/skills/skill-roots.js +25 -7
- package/lib/skills/skill-trash.js +14 -3
- package/lib/skills/system-trash.js +3 -1
- package/lib/skills/upload-pipeline.js +19 -3
- package/lib/slash-settings.js +1 -0
- package/lib/stale-write.js +9 -1
- package/lib/subagents/catalog.js +5 -5
- package/lib/subagents/child-preset.js +7 -10
- package/lib/subagents/persona-parse.js +9 -8
- package/lib/subagents/persona-write.js +1 -1
- package/lib/subagents/run-provider.js +13 -15
- package/lib/subagents/service.js +13 -12
- package/lib/subagents/tool-filter.js +1 -1
- package/lib/subagents/tools.js +41 -39
- package/lib/token-config.js +9 -9
- package/lib/tool-table-switch.js +3 -2
- package/lib/tools/deps.js +33 -13
- package/lib/tools/mcp.js +62 -35
- package/lib/tools/memory.js +51 -36
- package/lib/tools/prompt.js +32 -20
- package/lib/tools/remove.js +12 -11
- package/lib/tools/scene.js +39 -36
- package/lib/tools/skills.js +44 -45
- package/lib/tools/subagent.js +21 -22
- package/lib/tools/table.js +21 -20
- package/lib/trash-id.js +3 -2
- package/lib/trash-retention.js +4 -5
- package/lib/update-check.js +5 -1
- package/package.json +3 -2
package/lib/tools/scene.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// 场景域的 model
|
|
1
|
+
// 场景域的 model 工具(从记忆族分出来;同日补上 `_switch` 与 `_list`):
|
|
2
2
|
// `scene_manager_list` → `_switch` → `_save`。**注册顺序就是兼容页「模型工具表」的显示顺序**
|
|
3
3
|
// (`tools/table.ts` 刻意不定义第二份排序),这一族按其余四族同形的排法排:先查、再拨开关、
|
|
4
4
|
// 最后写定义 —— 场景族补上这两条时是照"先建后切"的语义顺序注册的,成了五族里唯一的例外。
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
// 预算)。合成一条工具会让 `description` 变成双义参数、门禁按参数分叉,而这两件事的失败
|
|
9
9
|
// 形状都是静默的。
|
|
10
10
|
//
|
|
11
|
-
// 为什么有 `scene_manager_list
|
|
11
|
+
// 为什么有 `scene_manager_list`:
|
|
12
12
|
// 场景清单此前挂在 `memory_manager_list` 的输出末尾(它最初解释的是"这条记忆为什么没被注入",
|
|
13
|
-
//
|
|
13
|
+
// 后来把档案也并了进去,为的是不加新工具、不加新 op)。省下那 106 tok/轮的代价是
|
|
14
14
|
// **引用方向反了** —— 场景族两条工具都要模型去调记忆族的工具看现状,而工具表可以单独关掉
|
|
15
15
|
// `memory_manager_list`(`tools/table.ts`),关掉后 `_switch` 描述里那句"照抄它打印的场景名"
|
|
16
16
|
// 就悬空了。六个注入域里也只有场景没有自己的 list。
|
|
@@ -20,14 +20,14 @@
|
|
|
20
20
|
// 写侧为什么是两条、而不是一条带 `action` 的:
|
|
21
21
|
// · `_save` 只写**定义**(场景记录 + 档案),不改变现在;
|
|
22
22
|
// · `_switch` 改的是**现在**(进入 = 六处开关一起动 + 收窄注入 + 改写 AGENTS.md)。
|
|
23
|
-
//
|
|
23
|
+
// 危险度差一档,回执要说的事也完全不同。当初把「启用与进入」整个留在界面,
|
|
24
24
|
// 理由是"那是改运行时环境的动作";补上 `_switch` 的取舍记在 CHANGELOG 里 —— 要点是
|
|
25
25
|
// **场景段的动作句仍然不加回来**:「上下文注入只给现在是什么」是同一天定下的原则,
|
|
26
26
|
// 不因为多了一条工具就破例(工具描述本来就是写"什么时候该用它"的地方)。
|
|
27
|
-
import { effectiveScope, isolationOffNote, requireGlobalScope, scopeGlobalOnlyDesc, scopeSessionDesc, sessionLayerOn, sessionScopeOf, text, toolNameList } from './deps.js';
|
|
27
|
+
import { effectiveScope, globalUnchangedNote, isolationOffNote, requireGlobalScope, scopeGlobalOnlyDesc, scopeOnlyNote, scopeSessionDesc, sessionLayerOn, sessionScopeOf, text, toolNameList } from './deps.js';
|
|
28
28
|
import { FACTORY_TOOL_TABLE_PRESET } from './table.js';
|
|
29
29
|
/** 档案里由模型设置的段(`memories` 段在 P5 已废弃,不再是档案的一部分)。
|
|
30
|
-
* `mcpNotes
|
|
30
|
+
* `mcpNotes`与其余三段同族:整段替换、段缺席 = 不碰这一域。 */
|
|
31
31
|
const ARCHIVE_SECTIONS = ['mcp', 'mcpNotes', 'skills', 'subagents'];
|
|
32
32
|
/** 段里的名单:数组段是名字列表,`mcp` 段是 serverName → `'*'` | 工具名数组。段缺席 = 空。 */
|
|
33
33
|
function segmentNames(value) {
|
|
@@ -79,16 +79,16 @@ function archiveText(archive) {
|
|
|
79
79
|
const notes = keys(archive.mcpNotes);
|
|
80
80
|
if (notes.length)
|
|
81
81
|
parts.push('notes ' + toolNameList(notes));
|
|
82
|
-
//
|
|
82
|
+
// 模型工具表方案(档案里有这一栏):进入时换的是**模型自己能用什么**,不报就是
|
|
83
83
|
// 让它事后发现自己少了工具却说不出原因。只给方案名 —— 关停名单不在档案里,硬算要多读一次
|
|
84
84
|
// 方案清单,而真正需要条数的时机是切换之后(那条回执有)。没绑就不冒这一格(与备注同口径)。
|
|
85
85
|
const tt = toolTableLabel(archive.toolTablePreset);
|
|
86
86
|
if (tt)
|
|
87
87
|
parts.push('tool-table preset "' + tt + '"');
|
|
88
|
-
//
|
|
88
|
+
// 快捷提示词绑定:进了这个场景会动到 `/` 菜单里哪些条目,不报就只能靠猜。
|
|
89
89
|
// 空表是"进入后全部停用",与"没绑"(这一域不碰)是两句相反的话,不能压成一个 "0 条"。
|
|
90
90
|
//
|
|
91
|
-
// 印 **id
|
|
91
|
+
// 印 **id 而不是条数**:`scene_manager_save.quickPrompts` 的描述让模型
|
|
92
92
|
// "copy them from a scene binding in the listing" —— 而此前这里只印「N 条」,清单里根本
|
|
93
93
|
// 没有 id 可抄,那句是一条**指不到的死路**(模型照做只会白跑一趟,然后去问用户)。
|
|
94
94
|
// 与 `skills` / `subagents` 两段同款(那两段本来就是 `toolNameList` 印名字)。
|
|
@@ -129,12 +129,12 @@ function segmentDiff(key, beforeValue, afterValue) {
|
|
|
129
129
|
* 探测不到 / 什么都没做(`unchanged`)就不占行:那两种情况下文件确实没变,
|
|
130
130
|
* 说一句"没变"只是噪音。
|
|
131
131
|
*
|
|
132
|
-
* `baselineError
|
|
132
|
+
* `baselineError`:切进去了**但退不回来** —— 场景提示词已写进 AGENTS.md
|
|
133
133
|
* 而"进场景之前那份基线"没能落盘。此前这一支在客户端有(45-scenes.js 的
|
|
134
134
|
* `scenes.agents.note.baselineLost`)、工具回执里没有,于是模型侧唯一能看到的版本是
|
|
135
135
|
* "切成功了"。它比 `error` 更该说:文件已经改了,只是没有退路。
|
|
136
136
|
*
|
|
137
|
-
* `snapshotMissing
|
|
137
|
+
* `snapshotMissing`:**模式快照丢了**,退出场景只能落盘模式位、运行时
|
|
138
138
|
* (MCP / 技能 / 人设 / 工具表)回不来。客户端有计划卡上的同款文案
|
|
139
139
|
* (`scenes.exit.noSnapshot`),工具回执此前同样没有 —— 模型只能看到"已退出"。
|
|
140
140
|
*/
|
|
@@ -159,6 +159,7 @@ function agentsMdNote(sync, action) {
|
|
|
159
159
|
}
|
|
160
160
|
return notes.join('');
|
|
161
161
|
}
|
|
162
|
+
/** 注册场景域的 model 工具(列表 / 进入 / 保存 / 删除)。 */
|
|
162
163
|
export function buildSceneTools(deps) {
|
|
163
164
|
const { defineTool, register } = deps;
|
|
164
165
|
register(defineTool({
|
|
@@ -173,7 +174,7 @@ export function buildSceneTools(deps) {
|
|
|
173
174
|
parameters: {},
|
|
174
175
|
output: { schema: { type: 'string' }, render: (_a, v) => text(v) },
|
|
175
176
|
async execute(_args, exec) {
|
|
176
|
-
//
|
|
177
|
+
// 会话层(`scene_manager_list` 标注本会话与全局默认):
|
|
177
178
|
// 列表里的 on/off 是**全局**的启用集合;本会话进入的场景是另一件事(只改这个对话
|
|
178
179
|
// 看到什么)。两者都不说清,模型会把「全局进入的是 A」读成「这个对话看到的也是 A」。
|
|
179
180
|
const scoped = sessionScopeOf(deps, exec && exec.agent);
|
|
@@ -210,7 +211,7 @@ export function buildSceneTools(deps) {
|
|
|
210
211
|
// 模型会把"启用着"读成"现在就是它" —— 而记忆与提示词只按**进入**的那一个注入。
|
|
211
212
|
if (entered !== null && name === entered)
|
|
212
213
|
state.push('entered');
|
|
213
|
-
//
|
|
214
|
+
// 本会话进入的那个场景:与 `entered` 是两个不同的东西 —— 前者只改
|
|
214
215
|
// 这个对话看到什么,后者真的切了运行时。同一个名字两个标,不冲突。
|
|
215
216
|
if (pinned !== undefined && name === pinned)
|
|
216
217
|
state.push('entered-in-this-conversation');
|
|
@@ -227,8 +228,8 @@ export function buildSceneTools(deps) {
|
|
|
227
228
|
bits.push('archive: ' + (archives === null ? 'unreadable (does not mean absent)' : archiveText(archives[name])));
|
|
228
229
|
return bits.join(' · ');
|
|
229
230
|
});
|
|
230
|
-
//
|
|
231
|
-
// `entered`
|
|
231
|
+
// 会话层:这一层进入的场景只改这一层的视图,不切运行时 —— 这一行必须与
|
|
232
|
+
// `entered` 分开报。退出场景之后这一层不回全局,而是回到创建时的样子。
|
|
232
233
|
const sessionLine = pinned !== undefined
|
|
233
234
|
? '\nthe view here is scene "' + pinned + '" (its own view: the machine-wide runtime was not switched and AGENTS.md was not written).'
|
|
234
235
|
: (detachedHere
|
|
@@ -249,10 +250,10 @@ export function buildSceneTools(deps) {
|
|
|
249
250
|
parameters: {
|
|
250
251
|
action: { type: 'string', required: true, enum: ['enter', 'exit'], description: 'enter = switch to the scene named in `scene`; exit = leave the current one (no scene needed).' },
|
|
251
252
|
scene: { type: 'string', description: 'Scene name (one path segment), required for enter — the exact name, not the display label.' },
|
|
252
|
-
//
|
|
253
|
-
//
|
|
253
|
+
// 默认只改**这个对话看到什么**,不切运行时、不写 AGENTS.md。
|
|
254
|
+
// 进入时可能让场景勾中的 MCP 服务器 / 技能来源按租约临时运行(连接与来源启用是
|
|
254
255
|
// 进程级的);那一步只在回执里出现,别在参数里长篇解释。
|
|
255
|
-
scope: { type: 'string', enum: ['session', 'global'], description: scopeSessionDesc('the scene is entered for that scope only: no runtime switch, AGENTS.md untouched (
|
|
256
|
+
scope: { type: 'string', enum: ['session', 'global'], description: scopeSessionDesc('the scene is entered for that scope only: no runtime switch, AGENTS.md untouched (its MCP servers may keep running for this scope). global = the machine-wide current scene: switches the runtime and applies the bound prompt to AGENTS.md.') },
|
|
256
257
|
},
|
|
257
258
|
output: { schema: { type: 'string' }, render: (_a, v) => text(v) },
|
|
258
259
|
async execute(args, exec) {
|
|
@@ -263,7 +264,7 @@ export function buildSceneTools(deps) {
|
|
|
263
264
|
// 刻意**不过** `lockedSceneGuard()`:场景**自身**的启停不在冻结清单里(冻结的是五个
|
|
264
265
|
// 域的内容)。锁定中的场景正被进入时不能退出 —— 那条守卫在 `scene-mode-set` 的包装里
|
|
265
266
|
// (index.ts),它以 ok:false 返回,下面如实抛出去。
|
|
266
|
-
//
|
|
267
|
+
// 会话层进出场景**不切全局运行时** ——
|
|
267
268
|
// 不调 `scene-mode-set`、不调 `rules-set-active`、不写 AGENTS.md。它把场景作为本会话的
|
|
268
269
|
// 一层记下来:档案里勾了的在其生效集合内、没勾的在本会话关掉,记忆 / 场景段 / 目录按那个
|
|
269
270
|
// 场景投影。两个例外要如实说:进入时会把场景勾中的 MCP 服务器 / 技能来源在**全局**拉起
|
|
@@ -286,10 +287,10 @@ export function buildSceneTools(deps) {
|
|
|
286
287
|
throw new Error((sc && sc.error) || 'failed to switch the scene here');
|
|
287
288
|
const warnings = sc.warnings !== undefined && sc.warnings.length > 0 ? '\n' + sc.warnings.join('\n') : '';
|
|
288
289
|
return action === 'enter'
|
|
289
|
-
? 'OK: scene "' + wanted + '" is now entered
|
|
290
|
-
'. The machine-wide runtime did not switch and AGENTS.md was not written
|
|
290
|
+
? 'OK: scene "' + wanted + '" is now entered' + scopeOnlyNote(deps) + ' (its own view)' +
|
|
291
|
+
'. The machine-wide runtime did not switch and AGENTS.md was not written. ' + globalUnchangedNote(deps) + warnings +
|
|
291
292
|
' Pass scope="global" to enter it for real.'
|
|
292
|
-
: 'OK:
|
|
293
|
+
: 'OK: left the scene' + scopeOnlyNote(deps) + ' — back to how it looked when it was created (its own view). The runtime was not touched. ' + globalUnchangedNote(deps);
|
|
293
294
|
}
|
|
294
295
|
let scene = '';
|
|
295
296
|
if (action === 'enter') {
|
|
@@ -360,7 +361,7 @@ export function buildSceneTools(deps) {
|
|
|
360
361
|
// 而"退出时快照丢了"这件事只有模式引擎知道(见 archive-engine.ts 的 scene-mode-set)。
|
|
361
362
|
// 进 / 退两个方向都报 —— 进场景时它说的是"你即将进入一个退不出来的场景"。
|
|
362
363
|
const snapshotMissing = mode && mode.exit && mode.exit.snapshotMissing === true;
|
|
363
|
-
//
|
|
364
|
+
// 会话层:全局切了场景,但**本会话**若钉着别的场景,这里看到的东西不会变。
|
|
364
365
|
// 不点这一句,模型会以为「切了场景 = 我这边也切了」,然后拿错误的场景解释上下文。
|
|
365
366
|
const pinned = sessionScopeOf(deps, exec && exec.agent)?.scope?.scene;
|
|
366
367
|
const pinnedNote = pinned === undefined
|
|
@@ -378,25 +379,27 @@ export function buildSceneTools(deps) {
|
|
|
378
379
|
register(defineTool({
|
|
379
380
|
name: 'scene_manager_save',
|
|
380
381
|
// 「写入指引」保留("写成指令而不是备注"—— 这是场景说明质量的杠杆),但不再声称
|
|
381
|
-
// "注入后模型会被要求照办"
|
|
382
|
+
// "注入后模型会被要求照办":定稿把场景段的授权语删了(注入只陈述现状),
|
|
382
383
|
// 参数说明与注入侧各说各话时,模型信的那份是错的。改为如实说明去向。
|
|
383
|
-
|
|
384
|
+
// 描述不再逐项列举档案里有哪些段(参数表本身就是那张清单,模型读参数时两处都在手上):
|
|
385
|
+
// 这里只留参数表**答不了**的三件事 —— 场景是什么、整段替换的语义、保存不等于进入。
|
|
386
|
+
description: 'Save a scene — a named bundle the user enters: entering switches on exactly what its archive lists and everything else off. Creates it if absent. Omitted fields keep their values; an archive section you give replaces that section whole (include what should stay — the receipt reports what got displaced). Saving does not enter it. Only on the user\'s instruction.',
|
|
384
387
|
parameters: {
|
|
385
388
|
scene: { type: 'string', required: true, description: 'Scene name (one path segment, ≤64 chars, no / \\ or < > : " | ? *, not `_shared`). Created if absent.' },
|
|
386
389
|
label: { type: 'string', description: 'Display name for this scene.' },
|
|
387
390
|
description: { type: 'string', description: 'What this scene is for — write an instruction, not a note; it shows beside the scene name while the scene is on.' },
|
|
388
391
|
// 与下面 `mcp` / `skills` / `subagents` 同一句式("X = 一个都不"):
|
|
389
|
-
// 界面
|
|
392
|
+
// 界面 补了「无」这个选项,工具侧的空串语义要跟着说清,否则模型只知道
|
|
390
393
|
// 「省略 = 保持」,不知道还有一条「解绑」的路。
|
|
391
394
|
prompt: { type: 'string', description: 'Prompt preset id to bind; while this scene is on it is the global baseline. \'\' = bind none (this scene leaves AGENTS.md alone).' },
|
|
392
|
-
//
|
|
393
|
-
//
|
|
395
|
+
// 模型工具表方案绑定:界面早就能绑、档案里一直有这一栏,`_list` / `_switch` 也读它,
|
|
396
|
+
// 唯独 `_save` 写不了。'' = 解绑只能走
|
|
394
397
|
// `rules-update-scene` —— `scene-archive-save` 对载荷里**不带的栏**一律保留现值
|
|
395
398
|
// (archive-engine 的「不带 ≠ 解绑」),所以解绑与设置分成两条路,见 execute 的 ②。
|
|
396
399
|
// 哨兵 `factory-default` 与界面下拉同值(tools/table.ts 的 FACTORY_TOOL_TABLE_PRESET);
|
|
397
400
|
// 不存在的方案名由引擎按 stale 丢弃并在进入时报告,op 不硬拒(与悬空绑定同口径)。
|
|
398
401
|
toolTablePreset: { type: 'string', description: "Model tool-table scheme to bind while this scene is on. '' = unbind; 'factory-default' = the factory default; otherwise a saved scheme name. An unknown name is dropped and reported." },
|
|
399
|
-
//
|
|
402
|
+
// 快捷提示词绑定。段语义与上面三个档案段相反:**空数组是合法值**
|
|
400
403
|
// (进入后全部停用),不是"清除这一段"。本工具不提供解绑(界面可解)—— 与
|
|
401
404
|
// mcp / skills / subagents 三段没有解绑参数同一条口径。id 从场景清单里别的场景的
|
|
402
405
|
// 绑定、或用户口述里来;不存在的 id 被引擎丢弃并在回执报出来。
|
|
@@ -409,7 +412,7 @@ export function buildSceneTools(deps) {
|
|
|
409
412
|
additionalProperties: true,
|
|
410
413
|
description: "Archive: serverName -> '*' (whole server) or a list of tool names to leave on. {} = switch none on.",
|
|
411
414
|
},
|
|
412
|
-
// 场景级 MCP
|
|
415
|
+
// 场景级 MCP 备注覆盖:进入这个场景时用这份盖掉全局备注,退出时还原。
|
|
413
416
|
// 与 mcp 段同一句式(省略 = 保持;{} = 一个都不覆盖)—— 界面存档编辑器早就能改,
|
|
414
417
|
// `_list` 也显示它,`_save` 此前不接这一段。
|
|
415
418
|
mcpNotes: {
|
|
@@ -419,7 +422,7 @@ export function buildSceneTools(deps) {
|
|
|
419
422
|
},
|
|
420
423
|
skills: { type: 'array', items: { type: 'string' }, description: 'Archive: skill keys `<root>/<name>` to switch on. [] = switch none on.' },
|
|
421
424
|
subagents: { type: 'array', items: { type: 'string' }, description: 'Archive: persona names to switch on. [] = switch none on.' },
|
|
422
|
-
//
|
|
425
|
+
// 场景记录与档案是**机器级**的,没有「本会话的一份」。这个参数只为一件事:
|
|
423
426
|
// 模型以为自己在改会话时,当场纠回来(见 deps.ts 的 requireGlobalScope)。
|
|
424
427
|
scope: { type: 'string', enum: ['session', 'global'], description: scopeGlobalOnlyDesc('the scene record and archive are machine-wide', 'entering a scene for one conversation is a switch action') },
|
|
425
428
|
},
|
|
@@ -506,7 +509,7 @@ export function buildSceneTools(deps) {
|
|
|
506
509
|
// ③ 档案 read-modify-write:段(mcp / mcpNotes / skills / subagents)与两个绑定栏的
|
|
507
510
|
// 「设置」方向合并成一份,只经 `scene-archive-save` 一条路落盘。
|
|
508
511
|
// **必须 read-modify-write**:`scene-archive-save` 是**整份替换**,只把模型给的段
|
|
509
|
-
// 传过去,没给的段会被静默清掉 —— 与
|
|
512
|
+
// 传过去,没给的段会被静默清掉 —— 与 `subagent_manager_save` 省略字段被
|
|
510
513
|
// 清空同一形状,只是这次清掉的是"这个场景进入时要开哪些东西"。
|
|
511
514
|
// 注意段语义:**段不存在 = 不限制(全部照常)**,段存在但为空 = 全部停用。所以模型给
|
|
512
515
|
// `mcp: {}` 得到的是"全不勾",不是"清除该段" —— 后者只能靠不给。
|
|
@@ -582,16 +585,16 @@ export function buildSceneTools(deps) {
|
|
|
582
585
|
// 点名 scene_manager_switch 的那句按可见性分叉(它在出厂默认名单里就是关着的):
|
|
583
586
|
// 部分启用(开 save 不开 switch)时指向一条模型没有的工具,只会让它白跑一趟 ——
|
|
584
587
|
// 与 mcp/skill 的 listHint 同一条纪律。
|
|
585
|
-
const enterHint = deps.
|
|
588
|
+
const enterHint = deps.toolVisibleFor('scene_manager_switch', exec && exec.agent)
|
|
586
589
|
? 'To take effect, enter it with scene_manager_switch.'
|
|
587
590
|
: 'To take effect, the user has to enter this scene manually (scene_manager_switch is not available in this session).';
|
|
588
|
-
//
|
|
591
|
+
// 会话层:场景记录与档案是**机器级**的(一份索引 + 一份档案),本会话能改的
|
|
589
592
|
// 只有「这个对话用哪个场景」。不说清的话,模型会把「存好了」读成「只在这个对话里生效」。
|
|
590
593
|
const pinned = sessionScopeOf(deps, exec && exec.agent)?.scope?.scene;
|
|
591
594
|
const globalNote = pinned === undefined
|
|
592
595
|
? ''
|
|
593
|
-
: '\nnote: scenes are global (one record and one archive for the whole machine).
|
|
594
|
-
' (currently "' + pinned + '");
|
|
596
|
+
: '\nnote: scenes are global (one record and one archive for the whole machine). The pin here only decides which scene this scope uses' +
|
|
597
|
+
' (currently "' + pinned + '"); ' + globalUnchangedNote(deps);
|
|
595
598
|
return 'OK: scene "' + scene + '"' + parts.join('; ') + warnTail + clearWarn + globalNote +
|
|
596
599
|
(collapsed
|
|
597
600
|
? '\nnote: every scene was enabled until now (the historical all-enabled default); this call narrowed the enabled set to one scene, and the new one is not it — the user should confirm the enabled state.'
|
package/lib/tools/skills.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
// 技能域的 model
|
|
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 =
|
|
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
|
-
//
|
|
12
|
-
|
|
12
|
+
// 面向模型的技能工具:list / toggle / create。create 由下面的 tools/pre-execute 钩子把关
|
|
13
|
+
//(写文件之前必须先问过用户)。
|
|
13
14
|
register(defineTool({
|
|
14
15
|
name: 'skill_manager_list',
|
|
15
|
-
// 关于「官方 `skill`
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
// 来源级停用 =
|
|
59
|
+
// 来源级停用 = 上层闸:里面的单条技能一条都加载不了。这一格也有会话层
|
|
59
60
|
// (skillSources):场景勾中的来源为开、没勾的为关;拨开一个来源时写侧会把它按
|
|
60
61
|
// 租约跑起来(来源关着时技能级 enable 会被 core 吞掉)。
|
|
61
62
|
const rootKey = String(root.key || '');
|
|
62
63
|
const srcFlag = flagOf('skillSources', rootKey);
|
|
63
|
-
// 没有会话层时落到**全局意图**(`globalOn
|
|
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`
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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
|
|
185
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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"
|
|
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
|
-
//
|
|
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
|
-
//
|
|
257
|
-
//
|
|
257
|
+
// 默认只改**这个对话**。写全局要显式说明。
|
|
258
|
+
// `source` 也有会话版本(拨开时来源按租约跑起来 —— 来源关着时技能级
|
|
258
259
|
// 开关会被 core 吞掉,所以那一步在回执里如实交代)。
|
|
259
|
-
scope: { type: 'string', enum: ['session', 'global'], description: scopeSessionDesc('turning a source or skill on may
|
|
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
|
-
//
|
|
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`
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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 === '' ? '\
|
|
326
|
+
(warnings === '' ? '\n' + globalUnchangedNote(deps) : '') +
|
|
326
327
|
' Pass scope="global" to change it for every conversation.';
|
|
327
328
|
}
|
|
328
|
-
// 全局来源开关 =
|
|
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
|
|
357
|
+
// 不给 root 就在全部来源里找:`skill_manager_save` 的落点
|
|
357
358
|
// 是 hub(`tool-management/skills/`),而这里的默认值原本是 dsh —— 「建完就启用」这条
|
|
358
359
|
// 最自然的链路必然报「技能不存在」。默认值改哪一边都不对(面板是显式传 root 的,
|
|
359
360
|
// 两边都依赖各自的默认),所以判定放到工具侧:按名字找**胜出的那一份**。
|
|
360
|
-
/**
|
|
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
|
-
//
|
|
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 === '' ? '\
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
480
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
533
|
+
// 然后发现技能不生效,而它不知道自己少拨了一个开关(三个 save
|
|
535
534
|
// 里只有这一条不报启用状态)。点名的 `skill_manager_switch` 在出厂默认名单里就是关着的,
|
|
536
535
|
// 关着就改说"用户启用后才能用",别指一条模型没有的工具。
|
|
537
|
-
const enableHint = deps.
|
|
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
|
-
//
|
|
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
|
}
|