@morlay/dsh-tool-guidance 0.0.11-alpha.0 → 0.0.11-alpha.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/dist/index.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import { createUserMessage } from "@deepseek-ai/dsh-llm";
2
+ import { RUN_CODE_NAME } from "@deepseek-ai/dsh-tools";
2
3
  import z from "@deepseek-ai/schemastery";
3
4
  // src/guidance/packs/ask.ts
4
5
  const ASK_PACK = {
@@ -68,19 +69,19 @@ const FLOW_PACK = {
68
69
  },
69
70
  {
70
71
  tool: "schedule_create",
71
- short: "在本会话里建定时提醒"
72
+ short: "按 rrule 建定时任务"
72
73
  },
73
74
  {
74
75
  tool: "schedule_list",
75
- short: "列出本会话的活动提醒"
76
+ short: "列出全部定时任务"
76
77
  },
77
78
  {
78
- tool: "schedule_update",
79
- short: "原地改一个提醒"
79
+ tool: "schedule_view",
80
+ short: "按 id 查看一个定时任务"
80
81
  },
81
82
  {
82
- tool: "schedule_delete",
83
- short: "删除一个提醒"
83
+ tool: "schedule_edit",
84
+ short: "按 id 改 / 暂停 / 删除任务"
84
85
  },
85
86
  {
86
87
  tool: "plugin_manager",
@@ -104,6 +105,10 @@ const FS_PACK = {
104
105
  tool: "edit",
105
106
  short: "按精确匹配替换文件片段"
106
107
  },
108
+ {
109
+ tool: "apply_patch",
110
+ short: "用一个补丁批量增删改移多个文件"
111
+ },
107
112
  {
108
113
  tool: "glob",
109
114
  short: "按模式查找文件路径"
@@ -257,6 +262,10 @@ const BASE_GROUP = {
257
262
  when: "edit",
258
263
  text: "edit:按精确匹配替换;old_string 默认必须唯一,出现多次时给更长的上下文或 replace_all。"
259
264
  },
265
+ {
266
+ when: "apply_patch",
267
+ text: "apply_patch:跨文件或分开的几处一起改时用它(Codex 风格补丁:`*** Begin Patch` … `*** End Patch`);整份先校验、拒绝则什么都不改,开始应用后按序执行、遇错即停且不回滚——重试前先重读受影响的文件。"
268
+ },
260
269
  {
261
270
  when: "str_replace_editor",
262
271
  text: "str_replace_editor:path 必须绝对路径、目录只能 view;str_replace 的 old_str 必须逐字且唯一(不唯一就不改),删除匹配要省略 new_str 而不是传 null。"
@@ -331,6 +340,7 @@ const BASE_GROUP = {
331
340
  "tool:read",
332
341
  "tool:write",
333
342
  "tool:edit",
343
+ "tool:apply_patch",
334
344
  "tool:glob",
335
345
  "tool:grep",
336
346
  "tool:bash",
@@ -344,6 +354,7 @@ const BASE_GROUP = {
344
354
  "read",
345
355
  "write",
346
356
  "edit",
357
+ "apply_patch",
347
358
  "str_replace_editor",
348
359
  "glob",
349
360
  "grep",
@@ -454,15 +465,16 @@ const FLOW_GROUP = {
454
465
  text: "exit_plan_mode:动手前提交计划(计划模式下只读);本部署装了计划模式才有这一行。"
455
466
  },
456
467
  {
457
- when: "schedule_create",
458
- text: "schedule_create:会话里的定时提醒,恰好给一个时间选择器(after_seconds / at / every_seconds / daily / weekly / cron,every_seconds 最小 60);schedule_list 看本会话还挂着哪些。"
459
- },
460
- {
461
- when: "schedule_update",
462
- text: "schedule_update:原地改、保留 id(它没有 after_seconds,改相对延迟要新建提醒);schedule_delete 不撤回已经入队的提醒消息。"
468
+ when: [
469
+ "schedule_create",
470
+ "schedule_list",
471
+ "schedule_view",
472
+ "schedule_edit"
473
+ ],
474
+ text: "定时任务:schedule_create 用 rrule(一行 DTSTART + 一行 RRULE)与 target 指定投递去处,prompt 每次触发时作为用户消息送达;schedule_list 列 Host 全部任务(含别的会话建的,分页),schedule_view 看单个,schedule_edit 按 action 改 / 暂停 / 恢复 / 删除(带 expectedUpdatedAt 才防并发覆盖,删除不撤回已入队的消息)。"
463
475
  }
464
476
  ],
465
- drops: ["tool:goal"],
477
+ drops: ["tool:goal", "tool:schedule"],
466
478
  tools: [
467
479
  "todo_write",
468
480
  "exit_plan_mode",
@@ -472,8 +484,8 @@ const FLOW_GROUP = {
472
484
  "present",
473
485
  "schedule_create",
474
486
  "schedule_list",
475
- "schedule_update",
476
- "schedule_delete"
487
+ "schedule_view",
488
+ "schedule_edit"
477
489
  ]
478
490
  }
479
491
  };
@@ -639,13 +651,13 @@ function apply(ctx, config) {
639
651
  writable: true
640
652
  });
641
653
  };
642
- ctx.on("system-prompt/assemble", async (_assembly, context, next) => {
654
+ ctx.on("system-prompt/assemble", async (assembly, context, next) => {
643
655
  const result = await next();
644
656
  const agent = context.agent;
645
657
  if (agent !== void 0) {
646
- const toolSet = context.toolSet;
647
- const definitions = ctx.tools.definitions(agent, toolSet);
648
- visibleTools.set(agent, new Set(definitions.map((tool) => tool.name)));
658
+ const definitions = ctx.tools.definitions(agent, context.toolSet);
659
+ const ptc = assembly.sections.some((section) => section.name === PTC_ONLY_SECTION);
660
+ visibleTools.set(agent, ptc ? /* @__PURE__ */ new Set([RUN_CODE_NAME]) : new Set(definitions.map((tool) => tool.name)));
649
661
  for (const definition of definitions) project(definition);
650
662
  }
651
663
  return result;
@@ -664,6 +676,7 @@ function apply(ctx, config) {
664
676
  projectVisible();
665
677
  }
666
678
  const baseGroup = groupByKey(BASE_GROUP_KEY);
679
+ const PTC_ONLY_SECTION = "tools:ptc-only";
667
680
  function registeredIn(ctx, agent) {
668
681
  return (tool) => ctx.tools.get(tool, agent) !== void 0;
669
682
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@morlay/dsh-tool-guidance",
3
- "version": "0.0.11-alpha.0",
3
+ "version": "0.0.11-alpha.3",
4
4
  "description": "Tool guidance for dsh: localized short tool descriptions, trimmed schema and usage groups as one host-plane row. The agent row list lives in the agent presets themselves (shipped or deployment-owned).",
5
5
  "keywords": [
6
6
  "dsh",
@@ -34,29 +34,29 @@
34
34
  "./locale/*.json": "./locale/*.json"
35
35
  },
36
36
  "devDependencies": {
37
- "@deepseek-ai/cordis-plugin-include": "^1.0.11-alpha.1",
38
- "@deepseek-ai/dsh-agent-loop-testkit": "^0.2.2-alpha.2",
39
- "@deepseek-ai/dsh-llm": "^0.2.2-alpha.2",
40
- "@deepseek-ai/dsh-scope": "^0.2.2-alpha.2",
41
- "@deepseek-ai/dsh-session": "^0.2.2-alpha.2",
42
- "@deepseek-ai/dsh-system-prompt": "^0.2.2-alpha.2",
43
- "@deepseek-ai/schemastery": "^3.18.6-alpha.1",
44
- "@morlay/dsh-context-assembler": "0.0.11-alpha.0",
45
- "@morlay/dsh-session-mode": "0.0.14-alpha.0",
37
+ "@deepseek-ai/cordis-plugin-include": "^1.0.11-alpha.2",
38
+ "@deepseek-ai/dsh-agent-loop-testkit": "^0.2.2-alpha.3",
39
+ "@deepseek-ai/dsh-llm": "^0.2.2-alpha.3",
40
+ "@deepseek-ai/dsh-scope": "^0.2.2-alpha.3",
41
+ "@deepseek-ai/dsh-session": "^0.2.2-alpha.3",
42
+ "@deepseek-ai/dsh-system-prompt": "^0.2.2-alpha.3",
43
+ "@deepseek-ai/schemastery": "^3.18.6-alpha.2",
44
+ "@morlay/dsh-context-assembler": "0.0.11-alpha.3",
45
+ "@morlay/dsh-session-mode": "0.0.14-alpha.3",
46
46
  "@types/js-yaml": "^4.0.9",
47
47
  "js-yaml": "^4.1.0"
48
48
  },
49
49
  "peerDependencies": {
50
- "@deepseek-ai/cordis": "^4.0.6-alpha.1",
51
- "@deepseek-ai/dsh-agent": "^0.2.2-alpha.2",
52
- "@deepseek-ai/dsh-llm": "^0.2.2-alpha.2",
53
- "@deepseek-ai/dsh-skill": "^0.2.2-alpha.2",
54
- "@deepseek-ai/dsh-tools": "^0.2.2-alpha.2",
55
- "@deepseek-ai/schemastery": "^3.18.6-alpha.1",
56
- "@morlay/dsh-context-assembler": "0.0.11-alpha.0"
50
+ "@deepseek-ai/cordis": "^4.0.6-alpha.2",
51
+ "@deepseek-ai/dsh-agent": "^0.2.2-alpha.3",
52
+ "@deepseek-ai/dsh-llm": "^0.2.2-alpha.3",
53
+ "@deepseek-ai/dsh-skill": "^0.2.2-alpha.3",
54
+ "@deepseek-ai/dsh-tools": "^0.2.2-alpha.3",
55
+ "@deepseek-ai/schemastery": "^3.18.6-alpha.2",
56
+ "@morlay/dsh-context-assembler": "0.0.11-alpha.3"
57
57
  },
58
58
  "engines": {
59
- "dsh": ">= 0.2.2-alpha.2 < 0.2.3"
59
+ "dsh": ">= 0.2.2-alpha.3 < 0.2.3"
60
60
  },
61
61
  "scripts": {
62
62
  "build": "pnpm exec tsdown"
@@ -10,10 +10,10 @@ export const FLOW_PACK: ToolPack = {
10
10
  { tool: "create_goal", short: "创建会话目标" },
11
11
  { tool: "update_goal", short: "更新会话目标状态" },
12
12
  { tool: "present", short: "声明交付给用户的产物" },
13
- { tool: "schedule_create", short: "在本会话里建定时提醒" },
14
- { tool: "schedule_list", short: "列出本会话的活动提醒" },
15
- { tool: "schedule_update", short: "原地改一个提醒" },
16
- { tool: "schedule_delete", short: "删除一个提醒" },
13
+ { tool: "schedule_create", short: "按 rrule 建定时任务" },
14
+ { tool: "schedule_list", short: "列出全部定时任务" },
15
+ { tool: "schedule_view", short: "按 id 查看一个定时任务" },
16
+ { tool: "schedule_edit", short: "按 id 改 / 暂停 / 删除任务" },
17
17
  { tool: "plugin_manager", short: "管理本 profile 的插件与 bundle" },
18
18
  ],
19
19
  };
@@ -7,6 +7,7 @@ export const FS_PACK: ToolPack = {
7
7
  { tool: "read", short: "读文件内容(可指定行范围)" },
8
8
  { tool: "write", short: "写入文件或整文件覆盖" },
9
9
  { tool: "edit", short: "按精确匹配替换文件片段" },
10
+ { tool: "apply_patch", short: "用一个补丁批量增删改移多个文件" },
10
11
  { tool: "glob", short: "按模式查找文件路径" },
11
12
  { tool: "grep", short: "按正则搜索文件内容" },
12
13
  { tool: "working_directory", short: "查看当前工作目录,或用 cd 切换" },
@@ -21,6 +21,10 @@ export const BASE_GROUP: GroupPack = {
21
21
  when: "edit",
22
22
  text: "edit:按精确匹配替换;old_string 默认必须唯一,出现多次时给更长的上下文或 replace_all。",
23
23
  },
24
+ {
25
+ when: "apply_patch",
26
+ text: "apply_patch:跨文件或分开的几处一起改时用它(Codex 风格补丁:`*** Begin Patch` … `*** End Patch`);整份先校验、拒绝则什么都不改,开始应用后按序执行、遇错即停且不回滚——重试前先重读受影响的文件。",
27
+ },
24
28
  {
25
29
  when: "str_replace_editor",
26
30
  text: "str_replace_editor:path 必须绝对路径、目录只能 view;str_replace 的 old_str 必须逐字且唯一(不唯一就不改),删除匹配要省略 new_str 而不是传 null。",
@@ -80,6 +84,7 @@ export const BASE_GROUP: GroupPack = {
80
84
  "tool:read",
81
85
  "tool:write",
82
86
  "tool:edit",
87
+ "tool:apply_patch",
83
88
  "tool:glob",
84
89
  "tool:grep",
85
90
  "tool:bash",
@@ -93,6 +98,7 @@ export const BASE_GROUP: GroupPack = {
93
98
  "read",
94
99
  "write",
95
100
  "edit",
101
+ "apply_patch",
96
102
  "str_replace_editor",
97
103
  "glob",
98
104
  "grep",
@@ -19,15 +19,11 @@ export const FLOW_GROUP: GroupPack = {
19
19
  text: "exit_plan_mode:动手前提交计划(计划模式下只读);本部署装了计划模式才有这一行。",
20
20
  },
21
21
  {
22
- when: "schedule_create",
23
- text: "schedule_create:会话里的定时提醒,恰好给一个时间选择器(after_seconds / at / every_seconds / daily / weekly / cron,every_seconds 最小 60);schedule_list 看本会话还挂着哪些。",
24
- },
25
- {
26
- when: "schedule_update",
27
- text: "schedule_update:原地改、保留 id(它没有 after_seconds,改相对延迟要新建提醒);schedule_delete 不撤回已经入队的提醒消息。",
22
+ when: ["schedule_create", "schedule_list", "schedule_view", "schedule_edit"],
23
+ text: "定时任务:schedule_create 用 rrule(一行 DTSTART + 一行 RRULE)与 target 指定投递去处,prompt 每次触发时作为用户消息送达;schedule_list 列 Host 全部任务(含别的会话建的,分页),schedule_view 看单个,schedule_edit 按 action 改 / 暂停 / 恢复 / 删除(带 expectedUpdatedAt 才防并发覆盖,删除不撤回已入队的消息)。",
28
24
  },
29
25
  ],
30
- drops: ["tool:goal"],
26
+ drops: ["tool:goal", "tool:schedule"],
31
27
  tools: [
32
28
  "todo_write",
33
29
  "exit_plan_mode",
@@ -37,8 +33,8 @@ export const FLOW_GROUP: GroupPack = {
37
33
  "present",
38
34
  "schedule_create",
39
35
  "schedule_list",
40
- "schedule_update",
41
- "schedule_delete",
36
+ "schedule_view",
37
+ "schedule_edit",
42
38
  ],
43
39
  },
44
40
  };
package/src/index.ts CHANGED
@@ -2,7 +2,7 @@ import type { Context } from "@deepseek-ai/cordis";
2
2
  import type { Agent } from "@deepseek-ai/dsh-agent";
3
3
  import { createUserMessage } from "@deepseek-ai/dsh-llm";
4
4
  import type {} from "@deepseek-ai/dsh-skill";
5
- import type { ToolDefinition } from "@deepseek-ai/dsh-tools";
5
+ import { RUN_CODE_NAME, type ToolDefinition } from "@deepseek-ai/dsh-tools";
6
6
  import type {} from "@morlay/dsh-context-assembler";
7
7
  import z from "@deepseek-ai/schemastery";
8
8
  import {
@@ -114,24 +114,31 @@ export function apply(ctx: Context, config: Config): void {
114
114
  writable: true,
115
115
  });
116
116
  };
117
- // 本行挂在**最外层**(`prepend`):`base` 正文要按这个会话最终可见的工具目录过滤,而装配上下文里的
118
- // `toolSet` 就是这一步的准入集(上游 0.2.1-rc.2 起工具声明由 `tools.resolve` 定,装配瀑布不再带 `tools`)。
117
+ // 本行挂在**最外层**(`prepend`):`base` 正文要按这个会话**模型面能直接调的工具**过滤。准入集来自装配
118
+ // 上下文(上游 0.2.1-rc.2 起工具声明由 `tools.resolve` 定,装配瀑布不再带 `tools`),执行器再往上那一层
119
+ // 见下面 PTC 那段。
119
120
  ctx.on(
120
121
  "system-prompt/assemble",
121
- async (_assembly, context, next) => {
122
+ async (assembly, context, next) => {
122
123
  const result = await next();
123
124
  const agent = context.agent;
124
- // 记名字集合:准入集已应用这个会话的收窄(`tools.restrict`)与条件激活,名字不受描述改写影响。
125
- // 诊断式的无 agent 装配不记(那种装配也不属于任何会话)。
125
+ // 记名字集合(`base` 正文的过滤判据)。诊断式的无 agent 装配不记。
126
126
  if (agent !== undefined) {
127
- const toolSet = context.toolSet;
128
- const definitions = ctx.tools.definitions(agent, toolSet);
127
+ const definitions = ctx.tools.definitions(agent, context.toolSet);
128
+ // 模型面 ≠ 准入集:执行器还会再投影一层,而那一层在装配瀑布**之后**(工具声明由 provider 在瀑布前
129
+ // 算好,瀑布只拿到 sections / contexts)。PTC 就是这一层——它把模型面收窄成 `run_code` 一条,
130
+ // 注册表与准入集里工具一个不少。信号是它注册的专属 section:`tools:ptc-only` 只有
131
+ // `@deepseek-ai/dsh-tool-executor-ptc` 会注册(原生执行器没有 sections)。
132
+ // 读**入参**那份(原始装配):瀑布把同一份 value 传给每个监听,而通道会把非 keep 的 section
133
+ // 降级成 reminder,`result` 里已经看不到执行器那两条。
134
+ const ptc = assembly.sections.some((section) => section.name === PTC_ONLY_SECTION);
129
135
  visibleTools.set(
130
136
  agent,
131
- new Set(definitions.map((tool) => tool.name)),
137
+ ptc ? new Set([RUN_CODE_NAME]) : new Set(definitions.map((tool) => tool.name)),
132
138
  );
133
139
  // 会话内晚注册的工具(MCP 重连、skill 重载)赶不上 `agent/created`:这里补一次改写。本次装配的声明已经
134
- // 按旧定义收集过了,所以从**下一次**请求开始生效。
140
+ // 按旧定义收集过了,所以从**下一次**请求开始生效。改写走准入集的全部定义:PTC 的 SDK 正文就是拿
141
+ // 它们渲染的,描述与参数说明也要一起汉化精简。
135
142
  for (const definition of definitions) project(definition);
136
143
  }
137
144
  return result;
@@ -159,6 +166,10 @@ export function apply(ctx: Context, config: Config): void {
159
166
 
160
167
  const baseGroup = groupByKey(BASE_GROUP_KEY);
161
168
 
169
+ // PTC 执行器在模型面只声明 `run_code` 一条:它注册的这条专属 section 是装配期唯一能看到的信号
170
+ // (section 名来自 `@deepseek-ai/dsh-tool-executor-ptc` 的 `PTC_ONLY_INSTRUCTION`)。
171
+ const PTC_ONLY_SECTION = "tools:ptc-only";
172
+
162
173
  // **兜底**判据 = 工具注册表(这一行装没装这个工具):只有当 `visibleTools` 里还没有这个 agent 的记录时才用得上。
163
174
  // 为什么需要兜底:理论上 `agent/pre-step` 之前每个 agent 必有一次装配(loop 里先 `assemble` 再走这条瀑布),
164
175
  // 但直接调瀑布的路径(诊断、别的插件自造 pre-step)可能没有——退回注册表总比渲染一份全量正文或空正文强。
@@ -227,4 +238,3 @@ function slimSchema(schema: unknown): unknown {
227
238
  }
228
239
  return rest;
229
240
  }
230
-