dsh-plugin-prompt-tool 1.0.0 → 2.0.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 (95) hide show
  1. package/README.md +38 -29
  2. package/engine/actions/append-context.mjs +49 -0
  3. package/engine/actions/assembly.mjs +150 -0
  4. package/engine/actions/catalog.mjs +92 -0
  5. package/engine/actions/content.mjs +205 -0
  6. package/engine/actions/decision.mjs +54 -0
  7. package/engine/actions/examples.mjs +11 -0
  8. package/engine/actions/guard.mjs +80 -0
  9. package/engine/actions/inbox-prepend.mjs +37 -0
  10. package/engine/actions/index.mjs +100 -0
  11. package/engine/actions/inject-text.mjs +22 -0
  12. package/engine/actions/pre-step-filter.mjs +55 -0
  13. package/engine/actions/registration.mjs +168 -0
  14. package/engine/actions/request-params.mjs +32 -0
  15. package/engine/actions/sdk-strip.mjs +30 -0
  16. package/engine/actions/shared.mjs +71 -0
  17. package/engine/actions.mjs +2 -931
  18. package/engine/branch.mjs +44 -0
  19. package/engine/compaction-epoch.mjs +31 -13
  20. package/engine/compositions/source/local/dev-tool-search.yml +11 -0
  21. package/engine/compositions/source/local/instruction-hint.yml +22 -1
  22. package/engine/compositions/source/local/rule-engine.yml +6 -0
  23. package/engine/condition.mjs +16 -3
  24. package/engine/conditions/anchor.mjs +32 -0
  25. package/engine/conditions/availability.mjs +47 -0
  26. package/engine/conditions/composite.mjs +83 -0
  27. package/engine/conditions/count.mjs +140 -0
  28. package/engine/conditions/evaluation.mjs +41 -0
  29. package/engine/conditions/examples.mjs +11 -0
  30. package/engine/conditions/index.mjs +85 -0
  31. package/engine/conditions/names.mjs +21 -0
  32. package/engine/conditions/phase.mjs +54 -0
  33. package/engine/conditions/preset.mjs +94 -0
  34. package/engine/conditions/scope.mjs +18 -0
  35. package/engine/conditions/session.mjs +22 -0
  36. package/engine/conditions/source.mjs +63 -0
  37. package/engine/conditions/subject.mjs +121 -0
  38. package/engine/conditions/text.mjs +44 -0
  39. package/engine/conditions/values.mjs +32 -0
  40. package/engine/dev-tool-search.mjs +213 -0
  41. package/engine/executor.mjs +55 -6
  42. package/engine/fillers.mjs +23 -16
  43. package/engine/instruction-hint.mjs +34 -22
  44. package/engine/layers.mjs +135 -49
  45. package/engine/order.mjs +4 -1
  46. package/engine/predicates.mjs +2 -753
  47. package/engine/rule-engine.mjs +40 -0
  48. package/engine/rule-runtime.mjs +110 -0
  49. package/engine/rule-spec.mjs +187 -0
  50. package/engine/schema.mjs +16 -5
  51. package/engine/shared.mjs +1 -1
  52. package/engine/strategies.mjs +2 -235
  53. package/engine/subagent-tool-policy-core.mjs +7 -7
  54. package/engine/subagent-tool-policy.mjs +20 -10
  55. package/engine/tool-config-engine.mjs +53 -32
  56. package/engine/trigger-editor-meta.mjs +2 -21
  57. package/engine/trigger-spec.mjs +49 -133
  58. package/lib/client.js +10446 -10820
  59. package/lib/client.js.map +1 -1
  60. package/lib/index.d.mts +82 -139
  61. package/lib/index.mjs +826 -1087
  62. package/lib/migrate-rules.d.mts +1 -0
  63. package/lib/migrate-rules.mjs +39 -0
  64. package/lib/module-package-CHPFweqK.mjs +2 -0
  65. package/lib/module-package-Cnd1_mwx.mjs +2872 -0
  66. package/lib/{paths-BgL42sSM.d.mts → paths-CyP0IkaM.d.mts} +223 -108
  67. package/lib/preset-transfer.d.mts +2 -2
  68. package/lib/preset-transfer.mjs +3 -2
  69. package/lib/{module-package-Cm3fHHlp.mjs → rules-migration-DJ6vASB5.mjs} +13696 -15557
  70. package/modules/ponytail/module.yml +381 -147
  71. package/modules/skill-surface/module.yml +74 -0
  72. package/modules/tool-surface/module.yml +67 -0
  73. package/package.json +5 -1
  74. package/templates/10-pre-step.yml +26 -22
  75. package/templates/14-first-turn-anchor.yml +25 -21
  76. package/templates/15-guide-auto.yml +34 -19
  77. package/templates/16-custom-fallback.yml +27 -15
  78. package/templates/18-placeholder-env-facts.yml +23 -14
  79. package/templates/20-system-section.yml +16 -10
  80. package/templates/30-runtime-context.yml +13 -7
  81. package/templates/40-agent-request.yml +11 -8
  82. package/templates/50-llm-stream.yml +14 -6
  83. package/templates/60-tool-pipeline.yml +15 -9
  84. package/templates/65-turn-stop.yml +19 -12
  85. package/templates/66-subagent-start.yml +12 -7
  86. package/templates/70-subagent-maintenance.yml +35 -29
  87. package/templates/75-subagent-end.yml +10 -5
  88. package/templates/80-tool-surface.yml +66 -0
  89. package/templates/policies/legacy-defaults.yml +34 -0
  90. package/engine/compositions/source/local/prompt-config-engine.yml +0 -7
  91. package/engine/prompt-config-engine.mjs +0 -104
  92. package/modules/ponytail/configs/0000-ponytail-rules.yml +0 -102
  93. package/modules/ponytail/configs/0010-ponytail-level-full.yml +0 -19
  94. package/modules/ponytail/configs/0020-ponytail-level-lite.yml +0 -19
  95. package/modules/ponytail/configs/0030-ponytail-level-ultra.yml +0 -19
@@ -0,0 +1,67 @@
1
+ # 工具面收窄 —— 常驻核心集 + dev_tool_search 按需解锁。
2
+ #
3
+ # 为什么:工具面实测 **156 个工具、描述合计 46894 字符(≈12K token)**,每个请求都付,
4
+ # 而多数请求只用到其中几个。收窄到核心集后只剩 10 个左右。
5
+ #
6
+ # 三件东西互相依赖,缺一件就退化(详见 docs/engine-reuse.md 的「工具面收窄与按需解锁」):
7
+ # 1. 本模块的 `narrow-tools` 规则 —— 常驻白名单 `allow` + 动态白名单 `allowFrom`
8
+ # 2. `dev-tool-search` 组合源行 —— 唯一发现入口,模型靠它搜索并解锁
9
+ # 3. `allowFrom` 读回 —— 解锁名写进持久 `tool/call` 参数,下次请求起生效
10
+ # 只挂插件不配 allowFrom 的话,解锁是**一次性的**(当次请求用完即被裁)。
11
+ #
12
+ # 相位用 any 两支表达(单个 phase 节点无法表达「两个相位都命中」):
13
+ # `promoted` 的缺省是 **true**(= 只匹配已晋升,不是「任意」);而 `promoted: 'ignore'`
14
+ # 要求同时声明只接受布尔值的 `compacted`。所以:
15
+ # 支 1 `promoted: true` → 已晋升(不论压缩与否)
16
+ # 支 2 `{compacted: true, promoted: false}` → 压缩后未晋升
17
+ # **首轮(未晋升且未压缩)刻意不收窄**——先让模型看到完整目录,再随相位推进收窄;
18
+ # 长会话必然进入上面两支,省下的正是大头。
19
+ #
20
+ # `requireMatch: true` 是刻意的:任一 allow 工具缺失(或模型解锁了一个不存在的名字)
21
+ # 就放弃裁剪、暴露完整目录。宁可多给上下文,也不静默裁成空目录——收窄错了会让当前
22
+ # 工作流调不到工具,那是比多花 token 严重得多的故障。
23
+ #
24
+ # 工具名必须与**实际装配名**一致:本项目 harness 是 `pwsh`(不是 `bash`)、
25
+ # `edit` + `write`(不是 `str_replace_editor`)。写错名字的后果很隐蔽——写进 allow 的
26
+ # 名字不存在会触发 requireMatch 的 fail-open,表现为「收窄没生效」而不是报错。
27
+ #
28
+ # 停用即回滚:本模块在 config.yml 的 enabled 里删掉即可,重启后工具面完全恢复。
29
+
30
+ id: tool-surface
31
+ name: 工具面收窄(核心文件与任务集)
32
+ version: 1.0.0
33
+ engineCompat: ">=0.4.2"
34
+ description: 把工具面收窄到常驻核心集(pwsh/read/write/edit/glob/grep/todo_write/skill_search/skill_load/dev_tool_search),其余由 dev_tool_search 按需解锁;解锁名经 allowFrom 从持久 tool/call 参数回收,跨请求与压缩保留。实测工具描述合计 46894 字符。
35
+ meta:
36
+ source: manual
37
+ modules:
38
+ - rule-engine
39
+ - dev-tool-search
40
+ order: 7
41
+ rules:
42
+ - id: tool-surface-resident
43
+ name: 工具面收窄(核心文件与任务集)
44
+ enabled: true
45
+ if:
46
+ any:
47
+ - phase: { promoteOn: either, includeSubagents: true, promoted: true }
48
+ - phase: { promoteOn: either, includeSubagents: true, compacted: true, promoted: false }
49
+ then:
50
+ - id: narrow-tools
51
+ kind: assembly
52
+ target:
53
+ tools:
54
+ allow:
55
+ - pwsh
56
+ - read
57
+ - write
58
+ - edit
59
+ - glob
60
+ - grep
61
+ - todo_write
62
+ - skill_search
63
+ - skill_load
64
+ - dev_tool_search
65
+ # 解锁项从 dev_tool_search 的持久调用参数回收({ tool, key } 精确匹配)。
66
+ allowFrom: { tool: dev_tool_search, key: toolNames }
67
+ requireMatch: true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-prompt-tool",
3
- "version": "1.0.0",
3
+ "version": "2.0.0",
4
4
  "description": "DSH 插件:提示词工具,规范模型的思维链与回答内容,提供 Web UI 编辑 preset.md 与 AGENTS.md,并按 skills 目录注册可开关技能。",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -10,6 +10,9 @@
10
10
  "type": "module",
11
11
  "main": "lib/index.mjs",
12
12
  "types": "lib/index.d.mts",
13
+ "bin": {
14
+ "prompt-tool-migrate-rules": "lib/migrate-rules.mjs"
15
+ },
13
16
  "exports": {
14
17
  ".": {
15
18
  "types": "./lib/index.d.mts",
@@ -118,6 +121,7 @@
118
121
  "sync:yaml": "node scripts/sync-yaml-vendor.mjs",
119
122
  "rebuild:preset-template": "node scripts/rebuild-preset-template.mjs",
120
123
  "rematerialize:presets": "node scripts/rematerialize-presets.mjs",
124
+ "migrate:rules": "node lib/migrate-rules.mjs",
121
125
  "repair:profile": "node scripts/repair-profile.mjs",
122
126
  "verify:host": "node scripts/verify-host-contracts.mjs"
123
127
  },
@@ -2,30 +2,34 @@
2
2
  # 本模板覆盖三种字段变体,插入后改字段即可:
3
3
  # - mergeMode=merged + texts 多块 → 同 position 配置拼接为一条消息(原 11-merged-a)
4
4
  # - configKind=anchor → 固定锚点序,按模块文件相对顺序排所有 ordered 之前(原 13-anchor)
5
- # 接入:复制本文件到 promptConfigsDir 目录,或把对象写入 settings.promptConfigs 数组。
6
- # 保存前可 POST /api/prompt-tool/settings/configs-validate 做权威校验。
5
+ # 接入:复制本文件到 模块规则模板目录,或把对象写入 module.yml.rules 数组。
6
+ # 保存前可 POST /api/prompt-tool/settings/rules 做权威校验。
7
7
  # audience 为配置项(缺省=公用;main=仅主会话;subagent=仅子代理),模板不锁定。
8
8
  id: example-pre-step
9
9
  name: 示例:消息批注入
10
10
  enabled: false
11
11
  layer: pre-step
12
- strategy: static
13
- position: after-user
14
- dedupe: session
15
- promotion: none
16
- modelScope: all
17
- configKind: ordered
18
- order: 0
19
- role: user
20
- mergeMode: separate
21
- sourceKind: ''
22
- form: notice
23
- summary: ''
24
- identity:
25
- field: plugin
26
- value: example-pre-step
27
- text: |-
28
-
29
- variables:
30
- WHO: ''
31
- params: {}
12
+ then:
13
+ - id: inject
14
+ kind: inject-text
15
+ config:
16
+ id: example-pre-step
17
+ layer: pre-step
18
+ strategy: static
19
+ position: after-user
20
+ dedupe: session
21
+ configKind: ordered
22
+ order: 0
23
+ role: user
24
+ mergeMode: separate
25
+ sourceKind: ''
26
+ form: notice
27
+ summary: ''
28
+ identity:
29
+ field: plugin
30
+ value: example-pre-step
31
+ text: |
32
+
33
+ variables:
34
+ WHO: ''
35
+ params: {}
@@ -1,27 +1,31 @@
1
1
  # 模板:首句锚点(strategy=first-turn-anchor)
2
2
  # 首条真实用户消息后按任务类型(build / inspect / deep)注入锚句,每会话一次。
3
- # 纯净模板:参数全部留空,由用户自定义;默认锚句与正则见引擎内置策略默认值。
4
- # 提示:把本文件放入 promptConfigsDir 目录,或把对象写入 settings.promptConfigs 数组。
3
+ # 纯净模板:参数全部留空,由用户自定义;锚句与分类正则由模板或用户配置提供,引擎不提供默认正文。
4
+ # 提示:把本文件放入 模块规则模板目录,或把对象写入 module.yml.rules 数组。
5
5
  id: example-first-turn-anchor
6
6
  name: 示例:首句锚点
7
7
  enabled: false
8
8
  layer: pre-step
9
- strategy: first-turn-anchor
10
- position: after-user
11
- dedupe: session
12
- promotion: none
13
- modelScope: all
14
- configKind: ordered
15
- order: 0
16
- role: user
17
- mergeMode: separate
18
- sourceKind: ''
19
- form: notice
20
- params:
21
- useCustom: false
22
- text: "" # 自定义锚文本(useCustom=true 时固定注入)
23
- buildPattern: "" # 构建任务正则;留空 = 该分类不生效
24
- complexPattern: "" # 复杂任务正则;留空 = 该分类不生效
25
- firstTurnBuild: "" # 构建任务锚句(留空 = 引擎内置默认锚句)
26
- firstTurnInspect: "" # 排查任务锚句(留空 = 引擎内置默认锚句)
27
- firstTurnDeep: "" # 复杂设计锚句(留空 = 引擎内置默认锚句)
9
+ then:
10
+ - id: inject
11
+ kind: inject-text
12
+ config:
13
+ id: example-first-turn-anchor
14
+ layer: pre-step
15
+ strategy: first-turn-anchor
16
+ position: after-user
17
+ dedupe: session
18
+ configKind: ordered
19
+ order: 0
20
+ role: user
21
+ mergeMode: separate
22
+ sourceKind: ''
23
+ form: notice
24
+ params:
25
+ useCustom: false
26
+ text: "" # 自定义锚文本(useCustom=true 时固定注入)
27
+ buildPattern: "" # 构建任务正则;留空 = 该分类不生效
28
+ complexPattern: "" # 复杂任务正则;留空 = 该分类不生效
29
+ firstTurnBuild: "" # 构建任务锚句(留空 = 不注入该类别锚句)
30
+ firstTurnInspect: "" # 排查任务锚句(留空 = 不注入该类别锚句)
31
+ firstTurnDeep: "" # 复杂设计锚句(留空 = 不注入该类别锚句)
@@ -1,25 +1,40 @@
1
+ # 复杂任务判定 fallback 复用锚定卡的 complexPattern;长度判定仅使用显式 complexMinChars;未设置时不按长度分类
2
+ # 简单任务自动引导句(留空 = 不注入该类别引导)
3
+ # 复杂任务自动引导句(留空 = 不注入该类别引导)
4
+
1
5
  # 模板:每轮引导(strategy=guide-auto)
2
6
  # 晋升后每轮用户消息后按复杂度注入弱/深度引导;modelScope=flash 表示仅 flash 模型会话注入。
3
- # 纯净模板:参数全部留空,由用户自定义;默认引导句文本见引擎内置策略默认值。
4
- # 提示:把本文件放入 promptConfigsDir 目录,或把对象写入 settings.promptConfigs 数组。
7
+ # 纯净模板:参数全部留空,由用户自定义;引导句由模板或用户配置提供,留空不注入。
8
+ # 提示:把本文件放入 模块规则模板目录,或把对象写入 module.yml.rules 数组。
5
9
  id: example-guide-auto
6
10
  name: 示例:每轮引导
7
11
  enabled: false
8
12
  layer: pre-step
9
- strategy: guide-auto
10
- position: after-user
11
- dedupe: batch
12
- promotion: main
13
- modelScope: flash
14
- configKind: ordered
15
- order: 10
16
- role: user
17
- mergeMode: separate
18
- sourceKind: ''
19
- form: notice
20
- params:
21
- useCustom: false
22
- text: ""
23
- # 复杂任务判定 fallback 复用锚定卡的 complexPattern;留空 = 仅按文本长度 120 判定深/弱
24
- guideWeak: "" # 简单任务自动引导句(留空 = 引擎内置默认引导句)
25
- guideDeep: "" # 复杂任务自动引导句(留空 = 引擎内置默认引导句)
13
+ if:
14
+ all:
15
+ - scope:
16
+ modelScope: flash
17
+ - phase:
18
+ promoted: true
19
+ includeSubagents: false
20
+ then:
21
+ - id: inject
22
+ kind: inject-text
23
+ config:
24
+ id: example-guide-auto
25
+ layer: pre-step
26
+ strategy: guide-auto
27
+ position: after-user
28
+ dedupe: batch
29
+ configKind: ordered
30
+ order: 10
31
+ role: user
32
+ mergeMode: separate
33
+ sourceKind: ''
34
+ form: notice
35
+ params:
36
+ useCustom: false
37
+ text: ""
38
+ guideWeak: ""
39
+ guideDeep: ""
40
+ complexMinChars: 120
@@ -2,22 +2,34 @@
2
2
  # 首轮推理命中锚定确认词后注入一次;未命中最多两轮兜底。确认词集合 anchorWords 由
3
3
  # writePreset 从锚句自动派生(firstTurnWord 空时);显式 firstTurnWord 覆盖派生。
4
4
  # 两者都为空 = 不做词确认,只走未命中兜底注入(引擎不内置确认词)。
5
- # 提示:把本文件放入 promptConfigsDir 目录,或把对象写入 settings.promptConfigs 数组。
5
+ # 提示:把本文件放入 模块规则模板目录,或把对象写入 module.yml.rules 数组。
6
6
  id: example-custom-fallback
7
7
  name: 示例:自定义锚词兜底注入
8
8
  enabled: false
9
9
  layer: pre-step
10
- strategy: custom-fallback
11
- position: before-all
12
- dedupe: session
13
- promotion: main
14
- modelScope: all
15
- configKind: ordered
16
- order: 20
17
- role: user
18
- mergeMode: separate
19
- sourceKind: plugin
20
- form: notice
21
- params:
22
- text: "" # 注入文本(如 preset.md 内容);留空 = 不注入
23
- firstTurnWord: "" # 锚定确认词(显式覆盖;空 = 自动派生)
10
+ if:
11
+ all:
12
+ - phase:
13
+ promoted: true
14
+ includeSubagents: false
15
+ - anchor:
16
+ keys: []
17
+ fallbackAfter: 1
18
+ then:
19
+ - id: inject
20
+ kind: inject-text
21
+ config:
22
+ id: example-custom-fallback
23
+ layer: pre-step
24
+ strategy: anchor-notice
25
+ position: before-all
26
+ dedupe: session
27
+ configKind: ordered
28
+ order: 20
29
+ role: user
30
+ mergeMode: separate
31
+ sourceKind: plugin
32
+ form: notice
33
+ params:
34
+ text: "" # 注入文本(如 preset.md 内容);留空 = 不注入
35
+ firstTurnWord: "" # 锚定确认词(显式覆盖;空 = 自动派生)
@@ -6,17 +6,26 @@
6
6
  # 可用 text 模板 + {{变量}} 完全自定义。
7
7
  id: example-placeholder
8
8
  layer: pre-step
9
- strategy: placeholder
10
- fill: env-facts
11
- position: after-all
12
- dedupe: session
13
- promotion: include-subagents
14
- text: |-
15
-
16
- params:
17
- envKeys: DSH_HOME,DSH_WORKSPACE # 环境变量白名单(逗号分隔);留空 = 只输出 CWD/WORKSPACE
18
- limit: 20 # skill-catalog:条目数上限
19
- fields: name,description # skill-catalog:输出字段
20
- providers: '' # skill-catalog:提供方过滤
21
- emptyBehavior: skip # skill-catalog:空结果行为
22
- emptyText: 当前没有可用技能。 # skill-catalog:emptyBehavior=text 时的提示;留空 = 不注入
9
+ if:
10
+ phase:
11
+ promoted: true
12
+ includeSubagents: true
13
+ then:
14
+ - id: inject
15
+ kind: inject-text
16
+ config:
17
+ id: example-placeholder
18
+ layer: pre-step
19
+ strategy: placeholder
20
+ fill: env-facts
21
+ position: after-all
22
+ dedupe: session
23
+ text: |
24
+
25
+ params:
26
+ envKeys: DSH_HOME,DSH_WORKSPACE # 环境变量白名单(逗号分隔);留空 = 只输出 CWD/WORKSPACE
27
+ limit: 20 # skill-catalog:条目数上限
28
+ fields: name,description # skill-catalog:输出字段
29
+ providers: '' # skill-catalog:提供方过滤
30
+ emptyBehavior: skip # skill-catalog:空结果行为
31
+ emptyText: 当前没有可用技能。 # skill-catalog:emptyBehavior=text 时的提示;留空 = 不注入
@@ -11,13 +11,19 @@
11
11
  id: example-system-section
12
12
  name: 示例:system 静态段
13
13
  layer: system-section
14
- strategy: static
15
- order: -50
16
- mergeMode: merged
17
- text: |-
18
-
19
- variables: {}
20
- params:
21
- complete: false
22
- suppressRuntimeContext: false
23
- sectionName: ''
14
+ then:
15
+ - id: inject
16
+ kind: inject-text
17
+ config:
18
+ id: example-system-section
19
+ layer: system-section
20
+ strategy: static
21
+ order: -50
22
+ mergeMode: merged
23
+ text: |
24
+
25
+ variables: {}
26
+ params:
27
+ complete: false
28
+ suppressRuntimeContext: false
29
+ sectionName: ''
@@ -4,10 +4,16 @@
4
4
  # 支持 placeholder 的层级)。
5
5
  id: example-runtime-context
6
6
  layer: runtime-context
7
- strategy: static
8
- order: 5
9
- mergeMode: merged
10
- text: |-
11
-
12
- params:
13
- contextName: ''
7
+ then:
8
+ - id: inject
9
+ kind: inject-text
10
+ config:
11
+ id: example-runtime-context
12
+ layer: runtime-context
13
+ strategy: static
14
+ order: 5
15
+ mergeMode: merged
16
+ text: |
17
+
18
+ params:
19
+ contextName: ''
@@ -1,11 +1,14 @@
1
1
  # 模板:agent-request 调用配置修改(LlmCallConfig 浅合并 / 整体替换)
2
2
  id: example-agent-request
3
3
  layer: agent-request
4
- strategy: static
5
- modelScope: flash
6
- order: 0
7
- params:
8
- patch:
9
- maxTokens: 4096
10
- temperature: 0.3
11
- replace: false
4
+ if:
5
+ scope:
6
+ modelScope: flash
7
+ then:
8
+ - id: request
9
+ kind: request-params
10
+ patch:
11
+ maxTokens: 4096
12
+ temperature: 0.3
13
+ replace: false
14
+ modelScope: all
@@ -1,9 +1,17 @@
1
1
  # 模板:llm-stream 模型流包装(pass 透传 / replace 用 text 替代整个流)
2
2
  id: example-llm-stream
3
3
  layer: llm-stream
4
- strategy: static
5
- modelScope: flash
6
- order: 0
7
- text: "" # mode=replace 时替代整个模型流的文本
8
- params:
9
- mode: pass
4
+ if:
5
+ scope:
6
+ modelScope: flash
7
+ then:
8
+ - id: inject
9
+ kind: inject-text
10
+ config:
11
+ id: example-llm-stream
12
+ layer: llm-stream
13
+ strategy: static
14
+ order: 0
15
+ text: "" # mode=replace 时替代整个模型流的文本
16
+ params:
17
+ mode: pass
@@ -1,13 +1,19 @@
1
+ # postAction=replace/block 时使用的文本
2
+
1
3
  # 模板:tool-pipeline 工具行为策略(对已注册工具的 pre/post 改写;
2
4
  # 自定义工具定义见工具管理区块——tool-pipeline 层筛选可见)。
3
5
  id: example-tool-pipeline
4
6
  layer: tool-pipeline
5
- strategy: static
6
- order: 0
7
- modelScope: all
8
- text: "" # postAction=replace/block 时使用的文本
9
- params:
10
- toolNames: bash,run_code
11
- preDecision: allow
12
- denyReason: 该工具被提示词配置禁用
13
- postAction: accept
7
+ then:
8
+ - id: before
9
+ kind: decision
10
+ phase: pre
11
+ decision: allow
12
+ toolNames: bash,run_code
13
+ reason: 该工具被提示词配置禁用
14
+ - id: after
15
+ kind: decision
16
+ phase: post
17
+ action: accept
18
+ toolNames: bash,run_code
19
+ text: ""
@@ -4,15 +4,22 @@
4
4
  id: example-turn-stop
5
5
  name: 未完成时强制续跑
6
6
  layer: turn-stop
7
- strategy: static
8
- order: 0
9
- modelScope: all
10
- text: |-
11
- 上一轮还没有给出完整交付。请继续把当前任务做完:不要停在中途,
12
- 也不要用「接下来我会…」的计划代替实际执行。
13
- match:
14
- keys:
15
- - 接下来我会
16
- - 稍后继续
17
- - 待办如下
18
- params: {}
7
+ if:
8
+ text:
9
+ keys:
10
+ - 接下来我会
11
+ - 稍后继续
12
+ - 待办如下
13
+ subject: assistantText
14
+ then:
15
+ - id: inject
16
+ kind: inject-text
17
+ config:
18
+ id: example-turn-stop
19
+ layer: turn-stop
20
+ strategy: static
21
+ order: 0
22
+ text: |-
23
+ 上一轮还没有给出完整交付。请继续把当前任务做完:不要停在中途,
24
+ 也不要用「接下来我会…」的计划代替实际执行。
25
+ params: {}
@@ -5,10 +5,15 @@
5
5
  id: example-subagent-start
6
6
  name: 子代理通用守则
7
7
  layer: subagent-start
8
- strategy: static
9
- order: 0
10
- modelScope: all
11
- text: |-
12
- 开始编辑之前,先确认你改的这条路径在运行时会真的被执行:查调用链,
13
- 或用探针跑一次看它动。找不到证据就继续查,不要凭「看起来像」就动手。
14
- params: {}
8
+ then:
9
+ - id: inject
10
+ kind: inject-text
11
+ config:
12
+ id: example-subagent-start
13
+ layer: subagent-start
14
+ strategy: static
15
+ order: 0
16
+ text: |-
17
+ 开始编辑之前,先确认你改的这条路径在运行时会真的被执行:查调用链,
18
+ 或用探针跑一次看它动。找不到证据就继续查,不要凭「看起来像」就动手。
19
+ params: {}
@@ -7,32 +7,38 @@ id: subagent-maintenance
7
7
  name: 子代理状态/记忆维护
8
8
  enabled: false
9
9
  layer: pre-step
10
- strategy: static
11
- position: after-user
12
- dedupe: none
13
- promotion: none
14
- audience: subagent
15
- modelScope: all
16
- configKind: ordered
17
- order: 2000
18
- role: user
19
- mergeMode: merged
20
- sourceKind: ''
21
- form: hint
22
- summary: ''
23
- identity:
24
- field: plugin
25
- value: subagent-maintenance
26
- text: |-
27
- 你是本会话的「状态与记忆维护者」,与创作类子代理职责互补:
28
- - 状态(本会话临时,模板变量注入用):观察互动中明确的角色状态变化
29
- (心情、态度、接受度等),用 session_var 工具 set 更新——变量名见下方
30
- 「状态变量」清单;状态未变化时不要重复写入。
31
- - 记忆(跨会话持久):有人际关系进展或重要事实时,用 world_book_upsert
32
- 的 note 参数写入来源角色卡记忆(条目 id 带 chara- 前缀 → 角色卡
33
- memory.md,跨会话跟随角色卡);无归属条目写入模块记忆。
34
- - 克制:仅在状态确实变化时更新;不确定时保留原值;不编造未发生的内容。
35
- 状态变量清单:{{stateKeys}}
36
- variables:
37
- stateKeys: 心情, 接受值, 关系进度
38
- params: {}
10
+ if:
11
+ scope:
12
+ audience: subagent
13
+ then:
14
+ - id: inject
15
+ kind: inject-text
16
+ config:
17
+ id: subagent-maintenance
18
+ layer: pre-step
19
+ strategy: static
20
+ position: after-user
21
+ dedupe: none
22
+ configKind: ordered
23
+ order: 2000
24
+ role: user
25
+ mergeMode: merged
26
+ sourceKind: ''
27
+ form: hint
28
+ summary: ''
29
+ identity:
30
+ field: plugin
31
+ value: subagent-maintenance
32
+ text: |-
33
+ 你是本会话的「状态与记忆维护者」,与创作类子代理职责互补:
34
+ - 状态(本会话临时,模板变量注入用):观察互动中明确的角色状态变化
35
+ (心情、态度、接受度等),用 session_var 工具 set 更新——变量名见下方
36
+ 「状态变量」清单;状态未变化时不要重复写入。
37
+ - 记忆(跨会话持久):有人际关系进展或重要事实时,用 world_book_upsert
38
+ 的 note 参数写入来源角色卡记忆(条目 id 带 chara- 前缀 → 角色卡
39
+ memory.md,跨会话跟随角色卡);无归属条目写入模块记忆。
40
+ - 克制:仅在状态确实变化时更新;不确定时保留原值;不编造未发生的内容。
41
+ 状态变量清单:{{stateKeys}}
42
+ variables:
43
+ stateKeys: 心情, 接受值, 关系进度
44
+ params: {}
@@ -8,8 +8,13 @@ id: example-subagent-end
8
8
  name: 子代理结束记录(只观察)
9
9
  enabled: false
10
10
  layer: subagent-end
11
- strategy: static
12
- order: 0
13
- modelScope: all
14
- params:
15
- action: observe
11
+ then:
12
+ - id: inject
13
+ kind: inject-text
14
+ config:
15
+ id: example-subagent-end
16
+ layer: subagent-end
17
+ strategy: static
18
+ order: 0
19
+ params:
20
+ action: observe