dsh-plugin-prompt-tool 0.6.2 → 0.7.0

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 (87) hide show
  1. package/README.md +11 -9
  2. package/engine/anchor-match.mjs +38 -12
  3. package/engine/anchor-turn.mjs +68 -0
  4. package/engine/classify-task.mjs +35 -0
  5. package/engine/code-presentation.mjs +103 -0
  6. package/engine/compositions/library/anchor-turn.yml +10 -0
  7. package/engine/compositions/library/bootstrap-filesystem.yml +1 -1
  8. package/engine/compositions/library/code-presentation.yml +8 -0
  9. package/engine/compositions/library/command-goal.yml +11 -0
  10. package/engine/compositions/library/compaction.yml +1 -1
  11. package/engine/compositions/library/context-gate.yml +1 -2
  12. package/engine/compositions/library/cot-drip.yml +11 -0
  13. package/engine/compositions/library/custom-bash.yml +1 -1
  14. package/engine/compositions/library/delegation.yml +11 -7
  15. package/engine/compositions/library/deliberation-gate.yml +11 -0
  16. package/engine/compositions/library/persistent-shell.yml +25 -2
  17. package/engine/compositions/library/persona.yml +6 -2
  18. package/engine/compositions/library/planning.yml +1 -1
  19. package/engine/compositions/library/prompt-config-engine.yml +1 -1
  20. package/engine/compositions/library/run-code-env.yml +1 -1
  21. package/engine/compositions/library/skill-filesystem.yml +1 -1
  22. package/engine/compositions/library/skill-search.yml +1 -1
  23. package/engine/compositions/library/str-replace-editor.yml +2 -2
  24. package/engine/compositions/library/tool-ask-user.yml +1 -1
  25. package/engine/compositions/library/tool-bash.yml +1 -1
  26. package/engine/compositions/library/tool-bootstrap.yml +1 -3
  27. package/engine/compositions/library/tool-config-engine.yml +9 -0
  28. package/engine/compositions/library/tool-filter.yml +3 -7
  29. package/engine/compositions/library/tool-fs-search.yml +1 -1
  30. package/engine/compositions/library/tool-fs.yml +1 -1
  31. package/engine/compositions/library/tool-goal.yml +1 -9
  32. package/engine/compositions/library/tool-jobs.yml +1 -1
  33. package/engine/compositions/library/tool-pwsh.yml +1 -1
  34. package/engine/compositions/library/tool-todo.yml +1 -1
  35. package/engine/compositions/library/tool-web.yml +2 -2
  36. package/engine/compositions/source/local/code-presentation.yml +8 -0
  37. package/engine/compositions/source/local/context-gate.yml +0 -1
  38. package/engine/compositions/source/local/str-replace-editor.yml +10 -0
  39. package/engine/compositions/source/local/tool-bootstrap.yml +1 -3
  40. package/engine/compositions/source/local/tool-config-engine.yml +9 -0
  41. package/engine/compositions/source/local/tool-filter.yml +8 -0
  42. package/engine/cot-drip.mjs +137 -0
  43. package/engine/custom-bash.mjs +73 -21
  44. package/engine/deliberation-gate.mjs +127 -0
  45. package/engine/layers.mjs +223 -198
  46. package/engine/run-code-env.mjs +8 -2
  47. package/engine/schema.mjs +1 -1
  48. package/engine/strategies.mjs +25 -14
  49. package/engine/tool-bootstrap.mjs +185 -59
  50. package/engine/tool-config-engine.mjs +390 -0
  51. package/lib/client.js +3840 -2311
  52. package/lib/client.js.map +1 -1
  53. package/lib/index.d.mts +185 -79
  54. package/lib/index.mjs +1000 -356
  55. package/lib/preset-core.d.mts +1 -1
  56. package/lib/preset-core.mjs +29 -3
  57. package/lib/{prompt-configs-BgFw_bFf.mjs → prompt-configs-BnQKRHVb.mjs} +211 -136
  58. package/lib/prompt-configs-CN0sJTUL.d.mts +193 -0
  59. package/package.json +121 -105
  60. package/preset/anchored/preset.yml +262 -308
  61. package/preset/creative/preset.yml +34 -32
  62. package/preset/custom/preset.yml +0 -1
  63. package/preset/liangshen/preset.yml +53 -50
  64. package/preset/minimal/preset.yml +18 -17
  65. package/preset/ptc/preset.yml +35 -33
  66. package/preset/standard/preset.yml +34 -32
  67. package/templates/10-pre-step.yml +18 -15
  68. package/templates/14-first-turn-anchor.yml +13 -13
  69. package/templates/15-guide-auto.yml +13 -13
  70. package/templates/16-custom-fallback.yml +19 -18
  71. package/templates/18-placeholder-env-facts.yml +13 -2
  72. package/templates/30-runtime-context.yml +3 -0
  73. package/templates/40-agent-request.yml +9 -9
  74. package/templates/60-tool-pipeline.yml +9 -8
  75. package/templates/tools/10-shell-command.yml +20 -0
  76. package/templates/tools/20-http-fetch.yml +24 -0
  77. package/templates/tools/30-fs-read.yml +20 -0
  78. package/templates/tools/40-delegate-character.yml +15 -0
  79. package/templates/tools/50-delegate-worldbook.yml +15 -0
  80. package/templates/tools/60-delegate-session-var.yml +15 -0
  81. package/templates/tools/70-delegate-worldbook-upsert.yml +36 -0
  82. package/lib/prompt-configs-B4vH09wx.d.mts +0 -100
  83. package/templates/11-merged-a.yml +0 -11
  84. package/templates/13-anchor.yml +0 -19
  85. package/templates/17-instruction-hint.yml +0 -23
  86. package/templates/19-placeholder-skill-catalog.yml +0 -19
  87. package/templates/31-runtime-context-placeholder.yml +0 -18
@@ -0,0 +1,20 @@
1
+ # 自定义工具模板:shell 命令执行器({{args.x}} 参数插值;env 白名单;cwd=会话工作区)。
2
+ id: shell-command
3
+ name: my_shell
4
+ description: 执行 shell 命令(参数经 {{args.*}} 插值)
5
+ parameters:
6
+ command:
7
+ type: string
8
+ required: true
9
+ description: 要执行的命令
10
+ output:
11
+ schema:
12
+ type: object
13
+ additionalProperties: true
14
+ properties:
15
+ exitCode: { type: integer }
16
+ stdout: { type: string }
17
+ stderr: { type: string }
18
+ execute:
19
+ kind: shell
20
+ command: '{{args.command}}'
@@ -0,0 +1,24 @@
1
+ # 自定义工具模板:HTTP 请求执行器(method/url/headers/body;{{args.x}} 插值)。
2
+ id: http-fetch
3
+ name: my_fetch
4
+ description: 发起 HTTP 请求并返回响应
5
+ parameters:
6
+ url:
7
+ type: string
8
+ required: true
9
+ description: 请求 URL
10
+ method:
11
+ type: string
12
+ description: 请求方法(默认 GET)
13
+ output:
14
+ schema:
15
+ type: object
16
+ additionalProperties: true
17
+ properties:
18
+ status: { type: integer }
19
+ ok: { type: boolean }
20
+ body: { type: string }
21
+ execute:
22
+ kind: http
23
+ url: '{{args.url}}'
24
+ method: '{{args.method}}'
@@ -0,0 +1,20 @@
1
+ # 自定义工具模板:工作区内文件读取(路径越界拒绝)。
2
+ id: fs-read
3
+ name: my_read
4
+ description: 读取工作区内文件内容
5
+ parameters:
6
+ path:
7
+ type: string
8
+ required: true
9
+ description: 相对工作区的文件路径
10
+ output:
11
+ schema:
12
+ type: object
13
+ additionalProperties: true
14
+ properties:
15
+ ok: { type: boolean }
16
+ content: { type: string }
17
+ execute:
18
+ kind: fs
19
+ action: read
20
+ path: '{{args.path}}'
@@ -0,0 +1,15 @@
1
+ # 自定义工具模板:委托内置 character_list(自定义名称/描述/参数面;
2
+ # 内置工具为插件固有注册,原工具仍可用)。
3
+ id: delegate-character-list
4
+ name: my_character_list
5
+ description: 查看角色卡库(委托内置工具)
6
+ output:
7
+ schema:
8
+ type: object
9
+ additionalProperties: true
10
+ properties:
11
+ ok: { type: boolean }
12
+ value: { type: json }
13
+ execute:
14
+ kind: delegate
15
+ tool: character_list
@@ -0,0 +1,15 @@
1
+ # 自定义工具模板:委托内置 world_book_list(自定义名称/描述/参数面;
2
+ # 内置工具为插件固有注册,原工具仍可用)。
3
+ id: delegate-worldbook-list
4
+ name: my_worldbook_list
5
+ description: 查看当前预设的世界书条目(委托内置工具)
6
+ output:
7
+ schema:
8
+ type: object
9
+ additionalProperties: true
10
+ properties:
11
+ ok: { type: boolean }
12
+ value: { type: json }
13
+ execute:
14
+ kind: delegate
15
+ tool: world_book_list
@@ -0,0 +1,15 @@
1
+ # 自定义工具模板:委托内置 session_var(自定义名称/描述/参数面;
2
+ # 内置工具为插件固有注册,原工具仍可用)。
3
+ id: delegate-session-var
4
+ name: my_session_var
5
+ description: 会话变量管理(委托内置工具)
6
+ output:
7
+ schema:
8
+ type: object
9
+ additionalProperties: true
10
+ properties:
11
+ ok: { type: boolean }
12
+ value: { type: json }
13
+ execute:
14
+ kind: delegate
15
+ tool: session_var
@@ -0,0 +1,36 @@
1
+ # 自定义工具模板:委托内置 world_book_upsert(有参包装示例)。
2
+ # 模型只见本模板声明的参数(name/content/keys),其余字段走 execute.args 固定映射:
3
+ # constant/order/layer/position 由模板锁定——参数面 = 官方工具定义的 parameters 定制。
4
+ # 内置工具为插件固有注册,原工具仍可用(delegate 仅自定义名称/描述/参数面)。
5
+ id: delegate-worldbook-upsert
6
+ name: my_worldbook_upsert
7
+ description: 新增/更新一条世界书条目(委托内置工具,常驻注入)
8
+ parameters:
9
+ name:
10
+ type: string
11
+ required: true
12
+ description: 条目名称/注释
13
+ content:
14
+ type: string
15
+ required: true
16
+ description: 条目内容(命中后注入)
17
+ keys:
18
+ type: array
19
+ items: { type: string }
20
+ description: 触发关键字
21
+ output:
22
+ schema:
23
+ type: object
24
+ additionalProperties: true
25
+ properties:
26
+ ok: { type: boolean }
27
+ value: { type: json }
28
+ execute:
29
+ kind: delegate
30
+ tool: world_book_upsert
31
+ args:
32
+ name: '{{args.name}}'
33
+ content: '{{args.content}}'
34
+ keys: '{{args.keys}}'
35
+ constant: true
36
+ order: 100
@@ -1,100 +0,0 @@
1
- //#region src/host/prompt-configs.d.ts
2
- interface PromptConfigSpec {
3
- id: string;
4
- name?: string;
5
- enabled?: boolean;
6
- strategy?: string;
7
- layer?: string;
8
- configKind?: 'ordered' | 'anchor';
9
- order?: number;
10
- role?: 'user' | 'assistant';
11
- group?: string;
12
- exclusive?: boolean;
13
- position?: 'after-user' | 'before-all' | 'after-all';
14
- dedupe?: 'session' | 'batch' | 'none';
15
- promotion?: 'none' | 'main' | 'include-subagents';
16
- /** 消息受众:缺省(省略/null)= 公用(主会话+子代理);main=仅主会话;subagent=仅子代理。 */
17
- audience?: 'main' | 'subagent' | null;
18
- modelScope?: 'all' | 'pro' | 'flash';
19
- sourceKind?: string;
20
- form?: string;
21
- summary?: string;
22
- identity?: {
23
- field: 'plugin' | 'kind';
24
- value: string;
25
- };
26
- text?: string;
27
- /** 单条提示词配置的多段文本:注入为一条消息的多个 text 内容块。 */
28
- texts?: string[];
29
- /** 同位置多条提示词配置的插入方式:separate=先后插入独立消息(默认);merged=拼接为一条消息。 */
30
- mergeMode?: 'separate' | 'merged';
31
- templateFile?: string;
32
- fill?: string;
33
- variables?: Record<string, string>;
34
- params?: Record<string, unknown>;
35
- }
36
- interface PromptConfigFile {
37
- /** 模块文件夹内文件名(数字前缀决定引擎执行顺序)。 */
38
- file: string;
39
- /** yml 文件内容。 */
40
- content: string;
41
- }
42
- /** buildCordis 兼容层的运行时选项(生产路径为 writePreset + preset.yml 数据驱动)。 */
43
- interface BuildCordisOptions {
44
- /** 首轮近距离锚定:首条真实用户消息后追加一次性首句锚点。 */
45
- firstTurnAnchor?: boolean;
46
- /** 自定义锚点文本;firstTurnCustom=true 时固定使用。 */
47
- firstTurnText?: string;
48
- /** 自定义锚点开关:true 固定使用 firstTurnText;false 按任务自动选择。 */
49
- firstTurnCustom?: boolean;
50
- /** 自定义每轮引导文本;guideCustom=true 时固定使用。 */
51
- guideText?: string;
52
- /** 自定义每轮引导开关:true 固定使用 guideText;false 按任务自动选择。 */
53
- guideCustom?: boolean;
54
- /** 锚定确认后注入 preset.md;关闭时仍保留工具引导,但不生成 prompt-injector 提示词配置内容。 */
55
- injectPrompt?: boolean;
56
- /** 模型路由 provider;与模型名同时非空时给 subagent/subagent_fork 行加 agentOptions(主对话直派子代理与委派子代理通用)。 */
57
- modelProvider?: string;
58
- /** 模型名;与 provider 同时非空时生效。 */
59
- modelName?: string;
60
- /** 子代理固定模型路由 provider(agentOptions 注入 tool-subagent)。 */
61
- subagentModelProvider?: string;
62
- /** 子代理固定模型名。 */
63
- subagentModelName?: string;
64
- /** 主对话思维程度(agent-request patch reasoningEffort;''=不设置,官方档位 off/low/high/max)。 */
65
- modelReasoningEffort?: string;
66
- /** 主对话采样温度(agent-request patch temperature;''=不设置)。 */
67
- modelTemperature?: string;
68
- /** 主对话输出上限(agent-request patch maxTokens;''=不设置)。 */
69
- modelMaxTokens?: string;
70
- /** 子代理思维程度(agent-request patch,audience=subagent;''=不设置)。 */
71
- subagentReasoningEffort?: string;
72
- /** 子代理采样温度(agent-request patch,audience=subagent;''=不设置)。 */
73
- subagentTemperature?: string;
74
- /** 子代理输出上限(agent-request patch,audience=subagent;''=不设置)。 */
75
- subagentMaxTokens?: string;
76
- /** 子代理自定义模型人设(per-child shadow;缺省 = 经 scope 链继承主会话 persona 模块)。 */
77
- subagentPersona?: string;
78
- /** 委派工具集白名单(toolFilter.allow;支持数组或逗号/空格分隔字符串)。 */
79
- toolFilterAllow?: string[] | string;
80
- /** 委派工具集黑名单(toolFilter.deny)。 */
81
- toolFilterDeny?: string[] | string;
82
- /** 委派递归深度上限(0 禁止委派 / provider-managed / 正整数)。 */
83
- maxDepth?: number | 'provider-managed';
84
- /** 注入 kind 白名单(context-gate allowKinds;数组或逗号分隔字符串)。 */
85
- allowKinds?: string[] | string;
86
- /** custom-fallback 锚定词(prompt-injector params.firstTurnWord)。 */
87
- firstTurnWord?: string;
88
- /** 首轮输出封顶(bootstrapMaxTokens);0 或未设置 = 本项目默认无封顶。 */
89
- bootstrapMaxTokens?: number;
90
- /** 使用 PTC 模式:默认 true。 */
91
- usePtcMode?: boolean;
92
- }
93
- /** 把任意提示词配置 spec 渲染为独立提示词配置模块 yml(全部字段开放可配置)。 */
94
- declare function renderPromptConfigYaml(spec: PromptConfigSpec): string;
95
- /** 多源提示词配置合并:同名 id 后者覆盖(保留默认提示词配置位置),新 id 追加在末尾。 */
96
- declare function mergePromptConfigs(...sources: Array<PromptConfigSpec[] | undefined>): PromptConfigSpec[];
97
- /** 从用户提示词配置目录加载 yml/json 提示词配置(文件名排序;内容必须能解析)。 */
98
- declare function loadPromptConfigFiles(dir: string): PromptConfigSpec[];
99
- //#endregion
100
- export { mergePromptConfigs as a, loadPromptConfigFiles as i, PromptConfigFile as n, renderPromptConfigYaml as o, PromptConfigSpec as r, BuildCordisOptions as t };
@@ -1,11 +0,0 @@
1
- # 模板:merged 拼接(同 position 的 merged 配置拼接为一条消息)
2
- # 本模板演示完整参数(mergeMode + texts 多块);复制本文件为多条同 position
3
- # 配置并调整 order,即演示多配置拼接(UI 卡片可复制/新建)。
4
- id: example-merged-a
5
- layer: pre-step
6
- strategy: static
7
- position: before-all
8
- mergeMode: merged
9
- order: 0
10
- texts:
11
- - ''
@@ -1,19 +0,0 @@
1
- # 模板:固定锚点序(configKind=anchor)
2
- # anchor 配置按模块文件相对顺序排在所有 ordered 配置之前(固定锚点),不参与 order 排序。
3
- # 提示:把本文件放入 promptConfigsDir 目录,或把对象写入 settings.promptConfigs 数组。
4
- id: example-anchor
5
- name: 示例:固定锚点序
6
- enabled: false
7
- layer: pre-step
8
- strategy: static
9
- configKind: anchor
10
- position: before-all
11
- dedupe: session
12
- promotion: none
13
- modelScope: all
14
- role: user
15
- order: 0
16
- mergeMode: separate
17
- sourceKind: ''
18
- form: notice
19
- text: ""
@@ -1,23 +0,0 @@
1
- # 模板:指令文件提示(strategy=placeholder + fill=instruction-hint;
2
- # 等价快捷写法 strategy=instruction-hint,二者同一实现)。
3
- # params.text 可自定义提示文本(覆盖 agents-instruction.txt 与动态探测);
4
- # promotion=include-subagents 表示子代理晋升后同样注入。
5
- # 提示:把本文件放入 promptConfigsDir 目录,或把对象写入 settings.promptConfigs 数组。
6
- id: example-instruction-hint
7
- name: 示例:指令文件提示
8
- enabled: false
9
- layer: pre-step
10
- strategy: placeholder
11
- fill: instruction-hint
12
- position: after-all
13
- dedupe: session
14
- promotion: include-subagents
15
- modelScope: all
16
- configKind: ordered
17
- order: 30
18
- role: user
19
- mergeMode: separate
20
- sourceKind: instruction-hint
21
- form: hint
22
- params:
23
- text: ""
@@ -1,19 +0,0 @@
1
- # 模板:placeholder 动态填充位 —— skill-catalog(技能目录)
2
- # 数据来自宿主 skills 服务(已按 skillSwitches 过滤);服务缺失时跳过不注入。
3
- # 建议 promotion: main + dedupe: session:晋升后注入一次,避开首轮目录扰动。
4
- id: example-skill-catalog
5
- name: 示例:技能目录
6
- layer: pre-step
7
- strategy: placeholder
8
- fill: skill-catalog
9
- position: after-all
10
- dedupe: session
11
- promotion: main
12
- text: |-
13
-
14
- params:
15
- limit: 20
16
- fields: name,description
17
- providers: ''
18
- emptyBehavior: skip
19
- emptyText: "" # emptyBehavior=text 时的空结果提示;留空 = 空文本
@@ -1,18 +0,0 @@
1
- # 模板:runtime-context 层 placeholder(strategy=placeholder + fill=skill-catalog)
2
- # runtime-context 是除 pre-step 外唯一支持 placeholder 的层级;演示技能目录动态填充。
3
- # 提示:把本文件放入 promptConfigsDir 目录,或把对象写入 settings.promptConfigs 数组。
4
- id: example-runtime-context-placeholder
5
- name: 示例:运行时上下文技能目录
6
- enabled: false
7
- layer: runtime-context
8
- strategy: placeholder
9
- fill: skill-catalog
10
- configKind: ordered
11
- order: 0
12
- mergeMode: separate
13
- sourceKind: ''
14
- form: notice
15
- params:
16
- limit: 20
17
- fields: name,description
18
- emptyBehavior: skip