dsh-plugin-prompt-tool 2.1.0 → 3.0.1

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 (206) hide show
  1. package/README.md +100 -233
  2. package/engine/actions/append-context.mjs +3 -24
  3. package/engine/actions/assembly.mjs +70 -94
  4. package/engine/actions/catalog.mjs +65 -28
  5. package/engine/actions/content.mjs +8 -152
  6. package/engine/actions/examples.mjs +8 -4
  7. package/engine/actions/inbox-prepend.mjs +4 -5
  8. package/engine/actions/index.mjs +17 -9
  9. package/engine/actions/inject-text.mjs +24 -4
  10. package/engine/actions/pre-step-filter.mjs +3 -4
  11. package/engine/actions/registration.mjs +20 -28
  12. package/engine/actions/request-params.mjs +21 -1
  13. package/engine/actions/shared.mjs +22 -13
  14. package/engine/actions/stream-output.mjs +26 -0
  15. package/engine/actions/tool-gate.mjs +31 -0
  16. package/engine/actions/tool-result.mjs +36 -0
  17. package/engine/actions/tool-visibility.mjs +248 -0
  18. package/engine/agent-capability.mjs +67 -0
  19. package/engine/anchor-match.mjs +14 -21
  20. package/engine/audience.d.mts +2 -0
  21. package/engine/audience.mjs +102 -0
  22. package/engine/branch.d.mts +4 -0
  23. package/engine/branch.mjs +61 -18
  24. package/engine/compaction-epoch.d.mts +25 -0
  25. package/engine/compaction-epoch.mjs +27 -4
  26. package/engine/compositions/source/local/filesystem-editor.yml +3 -3
  27. package/engine/compositions/source/local/instruction-hint.yml +2 -4
  28. package/engine/compositions/source/local/module-file-tools.yml +2 -0
  29. package/engine/compositions/source/local/module-import-tools.yml +4 -0
  30. package/engine/compositions/source/local/module-manifest-tools.yml +2 -0
  31. package/engine/compositions/source/local/module-rule-tools.yml +5 -0
  32. package/engine/compositions/source/local/module-variable-tools.yml +5 -0
  33. package/engine/compositions/source/local/present-as.yml +26 -0
  34. package/engine/compositions/source/local/tool-config-engine.yml +2 -3
  35. package/engine/compositions/source/local/tool-search.yml +11 -0
  36. package/engine/condition-facts.mjs +84 -0
  37. package/engine/conditions/anchor.mjs +63 -23
  38. package/engine/conditions/availability.mjs +1 -1
  39. package/engine/conditions/composite.mjs +3 -3
  40. package/engine/conditions/count.mjs +42 -11
  41. package/engine/conditions/evaluation.mjs +74 -19
  42. package/engine/conditions/examples.mjs +2 -1
  43. package/engine/conditions/index.d.mts +15 -0
  44. package/engine/conditions/index.mjs +23 -9
  45. package/engine/conditions/operators.mjs +4 -0
  46. package/engine/conditions/phase.mjs +9 -3
  47. package/engine/conditions/preset.mjs +1 -1
  48. package/engine/conditions/session.mjs +8 -2
  49. package/engine/conditions/subject.mjs +144 -65
  50. package/engine/conditions/text.mjs +26 -8
  51. package/engine/conditions/variable.mjs +83 -0
  52. package/engine/context-activation.d.mts +11 -0
  53. package/engine/{st-world-book.mjs → context-activation.mjs} +104 -64
  54. package/engine/delivery.d.mts +2 -0
  55. package/engine/delivery.mjs +93 -0
  56. package/engine/discovery.d.mts +38 -0
  57. package/engine/discovery.mjs +146 -0
  58. package/engine/env-safety.mjs +14 -0
  59. package/engine/executor.d.mts +28 -0
  60. package/engine/executor.mjs +290 -205
  61. package/engine/fillers.mjs +39 -8
  62. package/engine/fixed-registration.mjs +12 -0
  63. package/engine/history.mjs +71 -0
  64. package/engine/instruction-blocks.d.mts +13 -0
  65. package/engine/instruction-blocks.mjs +21 -0
  66. package/engine/instruction-files.d.mts +5 -0
  67. package/engine/instruction-files.mjs +97 -0
  68. package/engine/instruction-hint.mjs +69 -103
  69. package/engine/interpolate.d.mts +7 -0
  70. package/engine/interpolate.mjs +44 -13
  71. package/engine/layers.mjs +163 -227
  72. package/engine/machine-paths.mjs +40 -0
  73. package/engine/module-file-tools.mjs +8 -0
  74. package/engine/module-import-tools.mjs +10 -0
  75. package/engine/module-manifest-tools.mjs +8 -0
  76. package/engine/module-rule-tools.mjs +10 -0
  77. package/engine/module-variable-tools.mjs +10 -0
  78. package/engine/order.d.mts +14 -0
  79. package/engine/order.mjs +0 -3
  80. package/engine/path-safety.d.mts +2 -0
  81. package/engine/path-safety.mjs +58 -0
  82. package/engine/pre-step-source.d.mts +69 -0
  83. package/engine/pre-step-source.mjs +103 -0
  84. package/engine/present-as.mjs +77 -0
  85. package/engine/promotion-pool.d.mts +9 -0
  86. package/engine/promotion-pool.mjs +69 -0
  87. package/engine/record.mjs +2 -0
  88. package/engine/rule-engine.mjs +3 -2
  89. package/engine/rule-facts.d.mts +11 -0
  90. package/engine/rule-facts.mjs +60 -0
  91. package/engine/rule-runtime.d.mts +46 -0
  92. package/engine/rule-runtime.mjs +98 -13
  93. package/engine/rule-spec.d.mts +106 -0
  94. package/engine/rule-spec.mjs +301 -27
  95. package/engine/run-code-env.mjs +73 -19
  96. package/engine/schema.mjs +165 -243
  97. package/engine/sdk-strip.mjs +2 -2
  98. package/engine/service-names.d.mts +10 -0
  99. package/engine/service-names.mjs +10 -0
  100. package/engine/shared.d.mts +21 -0
  101. package/engine/shared.mjs +46 -13
  102. package/engine/skill-search.mjs +125 -53
  103. package/engine/source-kind.d.mts +9 -0
  104. package/engine/source-kind.mjs +16 -0
  105. package/engine/strategy-ids.mjs +5 -0
  106. package/engine/template-evaluation.d.mts +16 -0
  107. package/engine/template-evaluation.mjs +178 -0
  108. package/engine/template-frame.d.mts +16 -0
  109. package/engine/template-frame.mjs +69 -0
  110. package/engine/tool-config-engine.mjs +38 -34
  111. package/engine/tool-definition.d.mts +4 -0
  112. package/engine/tool-definition.mjs +5 -1
  113. package/engine/tool-git-bash.mjs +5 -1
  114. package/engine/tool-scope.mjs +22 -0
  115. package/engine/{dev-tool-search.mjs → tool-search.mjs} +63 -65
  116. package/engine/trigger.mjs +15 -270
  117. package/engine/vendor/yaml/dist/compose/resolve-flow-scalar.js +19 -18
  118. package/engine/vendor/yaml/dist/nodes/Alias.js +25 -23
  119. package/engine/vendor/yaml/package.json +1 -1
  120. package/lib/client.js +8312 -6724
  121. package/lib/client.js.map +1 -1
  122. package/lib/index.d.mts +16 -2120
  123. package/lib/index.mjs +26914 -5816
  124. package/modules/ponytail/module.yml +83 -203
  125. package/modules/ptc-mode/module.yml +45 -0
  126. package/modules/soul/assets/core-hard.md +6 -0
  127. package/modules/soul/assets/criteria.md +12 -0
  128. package/modules/soul/assets/echo.md +12 -0
  129. package/modules/soul/assets/layers.md +11 -0
  130. package/modules/soul/assets/ledger.md +9 -0
  131. package/modules/soul/assets/manifest.yml +20 -0
  132. package/modules/soul/assets/reference/00-layers.md +27 -0
  133. package/modules/soul/assets/reference/01-criteria.md +32 -0
  134. package/modules/soul/assets/reference/02-echo.md +161 -0
  135. package/modules/soul/assets/reference/03-vital.md +183 -0
  136. package/modules/soul/assets/reference/04-manifest.json +106 -0
  137. package/modules/soul/assets/reference/05-doctor.md +67 -0
  138. package/modules/soul/assets/reference/06-reference.md +189 -0
  139. package/modules/soul/assets/reference/07-bundle.json +431 -0
  140. package/modules/soul/assets/reference/08-/350/270/251/345/235/221/345/256/236/345/275/225.md +59 -0
  141. package/modules/soul/assets/reference/09-dev-workflow.md +109 -0
  142. package/modules/soul/assets/reference/10-echo-anatomy.md +109 -0
  143. package/modules/soul/assets/reference/11-self.md +80 -0
  144. package/modules/soul/assets/reference/12-ledger.md +159 -0
  145. package/modules/soul/assets/reference/ECHO-/346/235/203/345/250/201/345/217/243/345/276/204.md +202 -0
  146. package/modules/soul/assets/reference/ECHO/345/205/255/345/261/202/344/270/216mnemon/345/215/217/345/220/214/350/257/264/346/230/216/344/271/246.md +229 -0
  147. package/modules/soul/assets/reference/README.md +12 -0
  148. package/modules/soul/assets/templates/agents-template.md +6 -0
  149. package/modules/soul/assets/vital.md +9 -0
  150. package/modules/soul/module.yml +311 -0
  151. package/modules/superpowers/module.yml +122 -0
  152. package/modules/tool-surface/module.yml +51 -47
  153. package/package.json +37 -40
  154. package/skills/dsh-module/SKILL.md +67 -147
  155. package/skills/dsh-module/reference.md +113 -86
  156. package/templates/10-pre-step.yml +2 -3
  157. package/templates/14-first-turn-anchor.yml +10 -14
  158. package/templates/15-guide-auto.yml +32 -28
  159. package/templates/16-custom-fallback.yml +33 -21
  160. package/templates/20-system-section.yml +1 -4
  161. package/templates/50-llm-stream.yml +4 -10
  162. package/templates/60-tool-pipeline.yml +12 -10
  163. package/templates/63-append-context.yml +4 -6
  164. package/templates/65-turn-stop.yml +2 -2
  165. package/templates/67-inbox-prepend.yml +2 -2
  166. package/templates/70-subagent-maintenance.yml +9 -10
  167. package/templates/75-subagent-end.yml +2 -2
  168. package/templates/80-tool-surface.yml +41 -57
  169. package/templates/tools/40-delegate-module-import.yml +22 -0
  170. package/templates/tools/50-delegate-module-rules.yml +14 -0
  171. package/templates/tools/60-delegate-module-variables.yml +17 -0
  172. package/templates/tools/70-delegate-module-rules-edit.yml +31 -0
  173. package/engine/actions/decision.mjs +0 -54
  174. package/engine/actions/guard.mjs +0 -80
  175. package/engine/actions/sdk-strip.mjs +0 -30
  176. package/engine/character-tools.mjs +0 -8
  177. package/engine/classify-task.mjs +0 -53
  178. package/engine/compositions/source/local/character-tools.yml +0 -5
  179. package/engine/compositions/source/local/dev-tool-search.yml +0 -11
  180. package/engine/compositions/source/local/session-var-tools.yml +0 -5
  181. package/engine/compositions/source/local/subagent-tool-policy.yml +0 -21
  182. package/engine/compositions/source/local/world-book-tools.yml +0 -5
  183. package/engine/condition.mjs +0 -96
  184. package/engine/declared-triggers.mjs +0 -93
  185. package/engine/session-var-tools.mjs +0 -8
  186. package/engine/session-vars.mjs +0 -54
  187. package/engine/st-macros.d.mts +0 -22
  188. package/engine/st-macros.mjs +0 -208
  189. package/engine/st-render.mjs +0 -109
  190. package/engine/st-world-book.d.mts +0 -10
  191. package/engine/subagent-tool-policy-core.mjs +0 -400
  192. package/engine/subagent-tool-policy.mjs +0 -352
  193. package/engine/trigger-spec.mjs +0 -173
  194. package/engine/world-book-tools.mjs +0 -8
  195. package/lib/migrate-rules.d.mts +0 -1
  196. package/lib/migrate-rules.mjs +0 -610
  197. package/lib/module-package-DqJZaE71.mjs +0 -2
  198. package/lib/module-package-q2gDRu9H.mjs +0 -2869
  199. package/lib/rule-builder-DMrJten6.mjs +0 -14767
  200. package/templates/61-deny-tools-presentation.yml +0 -27
  201. package/templates/62-guard-deny-tools.yml +0 -20
  202. package/templates/policies/legacy-defaults.yml +0 -34
  203. package/templates/tools/40-delegate-character.yml +0 -15
  204. package/templates/tools/50-delegate-worldbook.yml +0 -15
  205. package/templates/tools/60-delegate-session-var.yml +0 -15
  206. package/templates/tools/70-delegate-worldbook-upsert.yml +0 -36
@@ -10,7 +10,7 @@
10
10
  而 `engine/`、`modules/`、`templates/` 在插件包里。包名 `dsh-plugin-prompt-tool`,定位用环境变量
11
11
  `$env:DSH_PROFILE_DIR`(bash 里读 `$DSH_PROFILE_DIR`)——包就在它的 `node_modules/` 下。读包内文件用
12
12
  **文件读取工具**:Desktop 部署下包可能落在 `app.asar` 里,shell、glob、grep、node 都打不开它。
13
- 找不到包时以本文件为准,它是源码摘要,只有存疑才需要回源。
13
+ 找不到包时用本摘要说明边界;需要确认未列出的能力时读取实际安装契约,不猜测支持。
14
14
 
15
15
  ## 一、条件谓词(`if` 里能写什么)
16
16
 
@@ -20,15 +20,15 @@
20
20
 
21
21
  | 谓词 | 字段 | 语义与边界 |
22
22
  |---|---|---|
23
- | `text` | `keys` / `secondaryKeys` 至少一个非空;`logic`(`any`/`all`/`not`/`notAny`,对齐 ST world_info_logic);`mode`(`scan` 全文 / `prefix` 词首);`caseSensitive`;`wholeWords`;`useRegex`(`true` 强制正则 / `false` 强制字面 / 缺省=只把 `/pattern/flags` 形态当正则);`stWords`;`subject` | 文本匹配。`subject` 决定匹配哪段文本,缺省由层决定(见第三节) |
23
+ | `text` | `keys` / `secondaryKeys`,或单独 `minChars` / `maxChars`(含端点的非负安全整数);`logic`(any/all/not/notAny);`mode`(scan/prefix);`caseSensitive`;`wholeWords`;`useRegex`;`wordBoundary`;`subject` | 关键词与长度同时声明时取交集,minChars 不得大于 maxChars;userMessage 读取本批全部真实用户文本。动作级条件必须声明本通道可用的 subject;缺事实不执行 |
24
24
  | `phase` | `promoted`(缺省 `true`=只匹配已晋升;`false`;`'ignore'` 必须同时写 `compacted`);`compacted`;`promoteOn`(`either`/`tool-call`/`assistant-message`);`includeSubagents`(缺省 false=子代理视为已晋升);`promoteGate` + `reasoningPattern`/`reasoningNegativePattern`/`reasoningFlags`;`maxPromoteSteps`;`promoteAfterFirstResponse` | 晋升相位。**单个节点表达不了「两个相位都命中」**,用 `any` 拼 `{promoted: true}` 与 `{compacted: true, promoted: false}` |
25
25
  | `source` | `kind` / `plugin`(字符串或字符串数组,两个都写是**合取**);`caseSensitive`(缺省 true);`match`(`exact` 缺省 / `prefix`) | 消息来源。列举多值要析取时用 `any` 显式写两支 |
26
- | `count` | `of`(`tool-call`/`tool-result`/`assistant-message`/`assistant-chars`/`user-message`/`turn`);`per`(`session` 缺省 / `turn`);`min` / `max` / `every`(**至少写一个**,否则恒真);`includeCurrent`;`delegated` | 计数。冷启动从持久事件流重建,重启后同一结果 |
26
+ | `count` | `of`(`tool-call`/`tool-result`/`assistant-message`/`assistant-chars`/`user-message`/`turn`);`per`(`session` 缺省 / `turn`);`min` / `max` / `every`(**至少写一个**,否则恒真);`includeCurrent`;`delegated` | 消息类信号按可见历史;tool-call/turn 按完整日志,冷启动按相同视图重建 |
27
27
  | `names` | `allow` / `deny`;`caseSensitive`(缺省 true) | 名称名单:工具名(工具通道)、子代理 provider(`subagent/start`、`subagent/end`) |
28
28
  | `session` | `type`(事件类型,如 `user/message`);`present`(缺省 `false`=该事件还没有);`delegated` | 会话态。判「首轮」用 `{type: user/message, present: false}` |
29
29
  | `preset` | `presetId` | 当前**挂载**的官方会话预设;取不到时返回 `UNAVAILABLE`(不乐观放行) |
30
30
  | `scope` | `audience`(`main`/`subagent`);`modelScope`(`all` 缺省 / `pro` / `flash`) | 受众与模型范围。这是**唯一**该写这些门的地方 |
31
- | `anchor` | `keys`(前缀匹配确认词);`fallbackAfter` | 锚定确认:首条 assistant reasoning 命中 `keys` 即确认;`fallbackAfter: N` 表示 assistant 消息超过 N 条后也放行 |
31
+ | `anchor` | `subject`(userMessage/assistantReasoning/assistantText/toolResult,缺省 assistantReasoning);`keys`;scan 模式可选既有匹配选项;`after: { action: seed }`;可选正整数 `fallbackAfter` | 当前可见已结算消息确认;缺省 prefix 只按 keys 作 ASCII 忽略大小写的字面前缀匹配,显式 secondaryKeys/caseSensitive/wholeWords/useRegex/logic/wordBoundary 一律拒绝,需这些选项时用 scan。关联只看同规则动作实际投递后的输出;第 N 个含所选内容块的完整输出仍未命中时兜底,中断模型消息不计,省略持续等待 |
32
32
 
33
33
  拿不到必要事实时谓词返回 `UNAVAILABLE`:只有严格 `true` 才执行;`any` 遇已知 `true`、`all` 遇已知
34
34
  `false` 仍可决断。
@@ -36,123 +36,150 @@
36
36
  ## 二、动作(`then` / `else` 里能写什么)
37
37
 
38
38
  `then` 是非空数组;每个动作要有唯一非空 `id` 与合法 `kind`。动作级分支写成 `{ if, then, else }`
39
- 节点嵌在数组里,可嵌套。`else` 结构上保证必有一支命中。
39
+ 节点嵌在数组里,可嵌套。else 必须有对应 if;必要事实未知时两支都不执行。
40
40
 
41
41
  | 动作 | 执行点 | 主要字段 | 失败时 |
42
42
  |---|---|---|---|
43
- | `inject-text` | 由 `config.layer` 决定(九层) | `layer`、`strategy`(`static`/`placeholder`/`first-turn-anchor`/`guide-auto`/`anchor-notice`/`world-book`)、`position`、`dedupe`、`mergeMode`、`role`、`order`、`text`/`texts`、`variables`、`params`、`templateFile`、`configKind` | 空正文=不注册 |
44
- | `assembly` | `system-prompt/assemble` 下游 | `target.tools`(`allow` **或** `deny`,可加 `requireMatch`、`allowFrom`)、`target.sections`(`add`/`remove` **或** `keep`)、`target.contexts`(`add`/`remove`/`clear`) | 返回未改动的装配(对 tools 即暴露完整目录) |
45
- | `decision` | `tools/pre-execute` / `tools/post-execute` | `phase`(`pre`/`post`)、`decision`(`allow`/`deny`/`ask`)、`action`(`accept`/`replace`/`block`)、`toolNames`、`text`、`reason` | 一律放行/接受——裁决 bug 不卡死调用 |
46
- | `append-context` | `mode: context` → `tools/post-execute`;`mode: continue` → `agent/turn-stopping` | `mode`、`text` | 保持原结果 |
47
- | `guard` | 注册期(agent scope) | `mask.allow` **或** `mask.deny`、`includeSubagents`、`reason`、`audience` | 静默不注册(**不**退化成放行以外的东西) |
48
- | `sdk-strip` | `system-prompt/assemble` 下游 | `mask.allow` **或** `mask.deny` | 原样返回;只删不增 |
43
+ | `inject-text` | 由 config.layer 决定(**六层可注入**,agent-request/llm-stream/tool-pipeline 只作展示归属) | layer、strategy(static/placeholder/context-activation)、position、dedupe、mergeMode、role、order、text/texts、params、templateFile、configKind | 空正文不生成投递;变量赋值模板另按显式求值事务处理 |
44
+ | `assembly` | `system-prompt/assemble` 下游 | `target.sections`(`add`/`remove` **或** `keep`)、`target.contexts`(`add`/`remove` **或** `clear`,二者互斥——并存编译期拒绝);`target.tools` 已移除 | 返回未改动的装配 |
45
+ | `tool-visibility` | system-prompt/assemble 下游 | allow 与/或 deny(先保留再剔除)、requireMatch(仅 allow)、discovery({ kind };tool/key 可选,只作断言);受众归 scope,提示归普通注入动作 | 呈现面失败保留原装配;执行闸失败留痕,不静默放行 |
46
+ | `tool-gate` | tools/pre-execute | decision(allow/deny/ask)、reason;工具名归 names 条件 | 一律放行——裁决 bug 不卡死调用 |
47
+ | `tool-result` | tools/post-execute | action(accept/replace/block)、text(仅 replace/block);工具名归 names 条件 | 一律接受——结果处理 bug 不把调用变成失败 |
48
+ | `append-context` | tools/post-execute | text;续跑用 inject-text 的 turn-stop 层 | 保持原结果 |
49
49
  | `request-params` | `agent/request` 下游 | `patch`(浅合并)、`unset`(`{键: 期望值}`)、`replace`(整体替换) | 保持原请求配置 |
50
+ | `stream-output` | llm/stream | mode(pass 缺省 / replace)、text(替代正文) | 保持原流 |
50
51
  | `inbox-prepend` | `agent/inbox/inserted`(emit,无 next) | `target`(`next-turn` 缺省 / `next-step`)、`text` | 不命中即什么都不做 |
51
52
  | `pre-step-filter` | `agent/pre-step` 下游 | `sources` **或** `keepKinds`(互斥,未声明即不过滤)、`blockPlugins`(正交,空=关闭) | 异常时保留全部消息 |
52
53
 
53
54
  通用规则:
54
55
 
55
- - 名单类参数(`allow`/`deny`/`sources`/`toolNames`)写成逗号分隔字符串或字符串数组都接受。
56
- - `allow` 与 `deny` **取一**(同一声明里二选一)。
57
- - `maxPerTurn`(正整数)用在 `assembly` / `decision` / `append-context` / `sdk-strip` /
58
- `request-params` / `inbox-prepend` / `pre-step-filter` 上;它数的是「本动作本轮生效几次」,
56
+ - 名单类参数(allow/deny/sources)写成逗号分隔字符串或字符串数组都接受。
57
+ - 工具可见面的 `allow` 与 `deny` 可以同时给:对齐官方 `ToolRestriction`,先按 `allow` 保留、再按 `deny` 剔除。
58
+ - `maxPerTurn`(正整数)用在 `assembly` / `tool-gate` / `tool-result` / `append-context` / `request-params` /
59
+ `inbox-prepend` / `pre-step-filter` 上;它数的是「本动作本轮生效几次」,
59
60
  与 `count` 谓词(数持久事件)是两回事。
60
- - `guard`、`complete`、`suppressRuntimeContext` 是**固定注册效果**:所在规则不带 `if`(注册期即生效)。
61
+ - `complete` 与 `suppressRuntimeContext` 是**固定注册效果**:所在规则不带 `if`(注册期即生效)。
61
62
 
62
63
  ### 禁用或收窄某个工具
63
64
 
64
- 工具的装配面由**会话原有预设**与各模块共同决定,所以「禁用」要在三层同时下手,只做一层会留下可见痕迹:
65
-
66
- | 层次 | 动作 | 效果 |
67
- |---|---|---|
68
- | 呈现 | `assembly` + `target.tools.deny` | 本次请求的工具目录里没有它 |
69
- | 文本 | `sdk-strip` + `mask.deny` | `tools:sdk` 段里的声明正文消失 |
70
- | 执行 | `guard` + `mask.deny` | 真正调不动——经 `run_code` 的子调用同样被拒 |
65
+ 工具的装配面由**会话原有预设**与各模块共同决定,所以「禁用」必须同时落到呈现与执行两层——只做一层会留下可见痕迹:
71
66
 
72
67
  ```yaml
73
68
  rules:
74
- - id: no-web-presentation
75
- then:
76
- - id: drop-from-assembly
77
- kind: assembly
78
- target: { tools: { deny: [web_search, web_fetch] } }
79
- - id: strip-sdk-text
80
- kind: sdk-strip
81
- mask: { deny: [web_search, web_fetch] }
82
- - id: no-web-execution # 固定注册效果:自成一条不带 if 的规则
69
+ - id: no-web
83
70
  then:
84
- - id: deny-at-execution
85
- kind: guard
86
- mask: { deny: [web_search, web_fetch] }
71
+ - id: hide-web
72
+ kind: tool-visibility
73
+ deny: [web_search, web_fetch]
87
74
  reason: 本模块不开放联网工具
88
75
  ```
89
76
 
90
- `guard` 注册在 **agent scope** 上,会话原有预设装的行也归它裁决——这是模块禁用官方工具的硬手段。要**收窄**而非禁用,用 `assembly.tools.allow` 白名单(范例见 `modules/tool-surface/module.yml`);要让禁用传播到子代理,加 `guard.includeSubagents: true`。
77
+ 一份 deny 名单同时裁装配目录、tools:sdk 正文,并在 agent scope 注册执行闸——会话原有预设装的行也归它裁决,经 run_code 的子调用同样被拒。要让禁用只作用于子代理,在规则或分支写 if.scope.audience: subagent;不设受众条件则两者都执行。
78
+
79
+ 要收窄,用同一动作的 allow 白名单(范例见 modules/tool-surface/module.yml),并按需声明 discovery:
80
+
81
+ ```yaml
82
+ - id: narrow
83
+ kind: tool-visibility
84
+ allow: [pwsh, read, write, edit, glob, grep, todo_write, skill_search, skill_load, tool_search, bash]
85
+ discovery: { kind: tools }
86
+ requireMatch: true
87
+ ```
88
+
89
+ 声明 discovery 的模块必须在 modules 里列出对应适配器行(tools → tool-search),缺行在装配准备期失败。discovery 在首次装配时按 agent 解析适配器,并从持久 tool/call 与 PTC tool/ptc-dispatch 参数回收解锁名(只做加法、跨压缩保留);工具由适配器行注册,discovery.tool/key 可选、只作断言。提示用同规则普通 inject-text 组合 count(user-message,max: 1)与 session 去重,采用 strategy: placeholder、fill: tool-catalog、params: { action: narrow }。只读 RESIDENT_TOOLS 是引用动作 allow 去 deny 后的逗号名单,DISCOVERY_TOOL 是当前 Agent 的发现适配器工具名;模块 text 控制提示正文,保留自动名单而不复制声明。requireMatch 在任一常驻工具缺失时放弃裁剪、暴露完整目录(fail-open),声明名单不等同实时工具面。allow 的执行面由 guard 兜底,不调用 restrict——restrict 的 allow 只收继承面名字,而全局 schemas 视图会漏预设/祖先层工具,局部 allow 反而会把它们裁掉;deny 才用 restrict + guard。PTC 下 tools 数组只有保留传输 `run_code`,实际可见面是 `tools:sdk` 正文;`run_code` 不写进 allow 也保留,且不参与 requireMatch,因此原生收窄声明可以直接与 PTC 共存。
90
+
91
+ tool-catalog 引用目标必须有 allow;仅支持普通只读插值,`templateEvaluation: true` 拒绝。未知动作引用保存前拒绝,发现适配器不可用则跳过提示并告警。
91
92
 
92
93
  ## 三、九层与字段
93
94
 
94
- 层是官方扩展点,彼此独立,没有跨层运行顺序。规则顶层的 `layer` 只用于展示、可省略;
95
- 真正生效的层取**动作**里的 `config.layer`(工具、装配、请求类动作自带执行点)。
96
-
97
- | 层 | 官方入口 | 层上合法字段 | 可用策略 | 层内 `params` |
98
- |---|---|---|---|---|
99
- | `pre-step` | `agent/pre-step` 消息批 | `position` `dedupe` `promotion` `audience` `modelScope` `mergeMode` `order` `role` `subject` `match` | 六种全支持 | — |
100
- | `system-section` | `ctx.systemPrompt.section` | `audience` `mergeMode` `order` | `static` | `sectionName` `complete` `suppressRuntimeContext` |
101
- | `runtime-context` | `ctx.systemPrompt.context` | `mergeMode` `order` | `static` `placeholder` | `contextName` |
102
- | `agent-request` | `agent/request` | `audience` `modelScope` `order` | `static` | `patch` `replace` |
103
- | `llm-stream` | `llm/stream` | `modelScope` `order` | `static` | `mode`(`pass`/`replace`) |
104
- | `tool-pipeline` | `tools/pre-execute` `tools/post-execute` | `audience` `modelScope` `order` `subject` `match` | `static` | `toolNames` `preDecision` `denyReason` `postAction` |
105
- | `turn-stop` | `agent/turn-stopping` | `modelScope` `order` `subject` `match` | `static` | — |
106
- | `subagent-start` | `subagent/start` | `modelScope` `order` `subject` `match` | `static` | — |
107
- | `subagent-end` | `subagent/end` | `modelScope` `order` `subject` `match` | `static` | `action`(`observe`/`inject-main`) |
95
+ 层是官方扩展点,彼此独立,没有跨层运行顺序。规则顶层 layer 是动作未声明 config.layer 时的缺省及展示归属;
96
+ 动作显式声明 config.layer 时优先使用动作值(工具、装配、请求类动作自带执行点)。
97
+
98
+ 层字段矩阵(`position` / `dedupe` / `promotion` / `audience` / `modelScope` / `merge` / `order` / `role` / `placeholder`;config 里写 `mergeMode`)由 `/meta` 的 `layerFieldPolicies` 下发,根 `module.yml` 也由同一份 `engine/schema.mjs` 生成;本文不再抄写,避免第三份副本漂移。
99
+
100
+ | 层 | 官方入口 | 可用策略 | 层内 `params` |
101
+ |---|---|---|---|
102
+ | `pre-step` | `agent/pre-step` 消息批 | static/placeholder/context-activation | — |
103
+ | `system-section` | `ctx.systemPrompt.section` | `static` | `sectionName` `complete` `suppressRuntimeContext` |
104
+ | `runtime-context` | `ctx.systemPrompt.context` | `static` `placeholder` | `contextName` |
105
+ | `agent-request` | `agent/request` | — | request-params 动作的 patch/unset/replace |
106
+ | `llm-stream` | `llm/stream` | — | stream-output 动作的 mode/text |
107
+ | `tool-pipeline` | 仅展示归属(**无注入通道**) | — | 工具链的裁决 / 结果处理 / 追加上下文改用 `tool-gate` / `tool-result` / `append-context` 动作 |
108
+ | `turn-stop` | `agent/turn-stopping` | `static` | — |
109
+ | `subagent-start` | `subagent/start` | `static` | — |
110
+ | `subagent-end` | `subagent/end` | `static` | `action`(`observe`/`inject-main`) |
108
111
 
109
112
  三条边界:
110
113
 
111
- 1. 层字段按上表用:`position`/`dedupe`/`role`/`promotion` 在 `pre-step`;`subject`/`match` 在
112
- `pre-step`、`tool-pipeline`、`turn-stop`、`subagent-start`、`subagent-end`。
113
- 2. 各层缺省的匹配对象:`pre-step` → `userMessage`、`tool-pipeline` → `toolArgs`、`turn-stop` →
114
- `assistantText`、`subagent-*` → `subagentInfo`。按任务内容分档放在 `pre-step`——`subagent/start`
115
- 的事件里只有 provider 与 id,没有任务文本。
116
- 3. 注册制层(`system-section`、`runtime-context`)的条件写在**规则级 `if`**:它在每次 assembly 走
117
- 条件文本贡献通道求值,`if.scope.audience` 是常见写法;动作级 `{ if, then, else }` 分支留给带逐轮
118
- 时机的层。`complete` 是「唯一 system 段」(同一 scope 一个)。
114
+ 1. 层字段以 `/meta` 的 `layerFieldPolicies` 为准:`position`/`role`/`promotion` 在 `pre-step`,`dedupe` 另支持 `turn-stop` 的 none/session。
115
+ 2. 声明式 `config.subject`/`config.match` 已删除;live 条件在规则 `if` 里写 `text.subject` / `anchor.subject`,
116
+ 可选值见 `/meta` 的 `subjects`。按任务内容分档放在 `pre-step`——`subagent/start` 的事件里只有
117
+ provider 与 id,没有任务文本。
118
+ 3. system-section、runtime-context 的普通文本贡献支持规则级 if 和嵌套 `{ if, then, else }`,
119
+ 每次 assembly 在条件文本贡献通道按当前事实求值,不动态重注册段;if.scope.audience 是常见写法。
120
+ complete / suppressRuntimeContext 属固定注册效果,仍拒绝动态条件分支;complete 表示同 scope 唯一 system 段。
119
121
 
120
- 策略 × 层:`static` 全层;`placeholder` 在 `pre-step`、`runtime-context`;`first-turn-anchor` /
121
- `guide-auto` / `anchor-notice` / `world-book` 在 `pre-step`——后五者都需要每轮求值的 resolver。
122
+ 策略 × 层:static 在六个可注入层;placeholder 在 pre-step、runtime-context;
123
+ context-activation 在 pre-step。分类与正文用通用条件和分支组合(模板15),动态内容策略使用既有 resolver。
122
124
 
123
- ## 四、模块名与参数
125
+ ### 确认后注入
124
126
 
125
- **可写进 `modules` 的名字**(= `engine/compositions/source/local/` 下的文件名;下面这份就是完整清单,不必去枚举目录):
127
+ 先用普通 `inject-text` 动作投递自定义锚句,再在嵌套分支写 `if: { anchor: { keys: [已确认], after: { action: seed } } }`,then 使用另一个普通注入动作声明正文与位置。完整示例见包内 `templates/16-custom-fallback.yml`,运行边界见 [引擎指南](../../docs/engine-reuse.md#字词句确认与动作关联)。不要把等待条件放在锚句动作的父级,否则锚句也无法投递。
126
128
 
127
- ```
128
- character-tools, dev-tool-search, filesystem-editor, instruction-hint, persistent-shell-posix,
129
- rule-engine, run-code-env, session-var-tools, skill-search, subagent-tool-policy,
130
- tool-bash-disabled, tool-config-engine, tool-git-bash, world-book-tools
129
+ `after.action` 仅引用同规则 separate 模式的 pre-step/runtime-context/turn-stop 注入动作;缺引用、自引用、循环、投递身份歧义、system-section 与 merged 目标在编译时拒绝。未实际接纳或已不再可见的起点返回 UNAVAILABLE,旧输出和 fork 继承不算当前会话的新投递。当前可见上下文变化后重判;默认等下次正常请求,显式 turn-stop 续跑仍受预算和取消信号约束。
130
+
131
+ 直接匹配当前 pre-step 用户消息用 `text.subject: userMessage`(模板14);`anchor.subject: userMessage` 看已接纳历史。确认词只写条件,正文只写动作;source.summary 是用户元数据,不生成动态确认/兜底说明。旧 first-turn-anchor、anchor-notice 策略与专属参数已移除,不保留兼容入口,也不自动修改用户模块。
132
+
133
+ ## 四、能力、参数与数据所有权
134
+
135
+ 能力目录以包内 engine/compositions/source/local 的实际文件为准;模块工具统一为 module-file-tools、module-import-tools、module-manifest-tools、module-rule-tools、module-variable-tools。
136
+
137
+ **模块装配清单**(固定 `assets/manifest.yml`,由 `module_manifest` 解释,工具不认业务字段):
138
+
139
+ ```yaml
140
+ dirs:
141
+ - data/10-宪章
142
+ files:
143
+ - from: assets/templates/agents-template.md
144
+ to: data/AGENTS.md
145
+ checks:
146
+ - path: data/02-soul.jsonl
147
+ kind: jsonl
148
+ maxBytes: 8388608
131
149
  ```
132
150
 
133
- 官方组合块已随预设解耦清理:`tool-pwsh`、`tool-fs`、`delegation`、`planning`、`compaction`、
134
- `tool-web` 这些能力由**会话原有的官方预设**提供。声明了 `rules` 就写 `rule-engine`。
151
+ - `dirs` / `files.to` / `checks.path` 只允许 `data/`;`files.from` 只允许 `assets/`(必须存在,单文件 ≤ 1 MiB)。
152
+ - `checks.kind` ∈ `file`/`text`/`json`/`jsonl`;`maxBytes` 缺省 1 MiB。
153
+ - `action`:`next` 返回第一条缺失(`ok` = 是否已完成),`check` 返回全部检查结果(`ok` = 是否全部通过),`apply` 建目录并只落缺失文件(不覆盖、不删除)。
154
+ - 未知键、未知 kind、越界路径与链接都 fail loud。官方工具、规划、压缩与普通委派由会话原有预设提供,空模块不自动获得这些能力。
135
155
 
136
- **共享参数**四个键,写在 `layerSettings.<层名>.<键>`;层由参数自己的 `storageLayer` 固定:
156
+ 共享参数由 `ENGINE_PARAM_DEFINITIONS` 唯一登记,`storageLayer` 决定磁盘路径:主/子模型各有路由与采样键,另含 PTC 呈现(presentAsEnabled、ptcMainMode、ptcSubagentMode)、run_code 环境(runCodeEnvEnabled、runCodeEnvKeys)、Git Bash(toolGitBashEnabled、路径、超时、输出上限)、指令提示(instructionHint 及 promoteOn/includeSubagents/模板)和工具批准(customToolRequireApproval);完整键、options 与默认值以源码为准,不在摘要抄数量。模型卡在装配期合成 request-params 规则;未配置继承宿主。子代理递归深度归官方 `subagent.maxDepth`,插件不提供。
137
157
 
138
- | 键 | 层 | 说明 |
139
- |---|---|---|
140
- | `instructionHint` | `pre-step` | 布尔,默认关:晋升后把官方指令全文换成一次路径提示 |
141
- | `maxDepth` | `subagent-start` | 数字 / `provider-managed` / 空;只在插件子代理策略启用时约束 |
142
- | `toolGitBashEnabled` | `tool-pipeline` | 布尔,默认 true:Windows Git Bash 适配行 |
143
- | `customToolRequireApproval` | `tool-pipeline` | 列表:`shell` `http` `delegate` `fs` `ask-user` |
158
+ - persona.main/subagent:各模块保存 prefix/suffix/complete/includeRuntimeContext,省略继承、空文本清空、false 明确值;rules/_settings.yml 只作校验投影。
159
+ - config.yml.personaSources:main/subagent 各单选官方默认或一个模块 ID,不存正文、不自动启用 rules。只读取所选受众字段,不跨模块逐字段合并;有效官方人设与启用规则的 complete 仍预检,配装失败保留旧状态。
160
+ - variables:模块持久值,覆盖同安装 global;空串保留,删键才回落。普通规则手动建立变量,ST 导入自动登记缺失裸引用为空占位。
161
+ - customTools:shell/http/delegate/fs/ask-user,定义见包内 templates/tools。delegate 走官方工具管线。
162
+ - subagentToolPolicy:授权上限、工具档、角色绑定、任务规则与受控扩权;缺省官方委派。
163
+ - moduleConfigs:已声明共享参数优先于行级配置,不能绕过工具批准。
164
+ - configOrder:模块内规则id→非负序号,排序不修改正文和启停。
165
+
166
+ ## 五、上下文激活与模板
167
+
168
+ `context-activation` 只在 pre-step 使用。`params.activation.scan` 必须为 batch 或 history;历史只扫描模型可见的真实对话,排除插件/指令/工具回执。`scanDepth:0` 不扫描聊天、变量和递归正文,常驻例外。
169
+
170
+ 匹配共有字段:keys、secondaryKeys、constant、caseSensitive、wholeWords、useRegex、wordBoundary、selectiveLogic。词边界 unicode 为原生字母数字边界,ascii-token 为 ST 单词 ASCII/多词子串规则。副键先开启 activation.selective;P=主键命中数,S=副键命中数,N=原副键项数:
171
+
172
+ | 具名逻辑 | 条件 |
173
+ |---|---|
174
+ | AND_ANY | P>0 且 S>0 |
175
+ | NOT_ALL | P>0 且 S<N |
176
+ | NOT_ANY | P>0 且 S=0 |
177
+ | AND_ALL | P>0 且 S=N |
144
178
 
145
- 模型与采样参数走 `agent-request` 动作的 `patch`,受众由规则 `if.scope` 区分。
179
+ 未开 selective 或无副键只要求 P>0;空主键不自动常驻。求值为空的副键仍占一项。activation 还拥有 scanVariables、概率、selectionGroup、评分、sticky/cooldown/delay、递归排除与延迟层级;它的候选组与规则 group/exclusive 不同。模块递归用 contextActivationRecursive,默认 false,池跨模块共享。
146
180
 
147
- **顶层段**各有所有者,互不混写:
181
+ 原生模板显式设置 params.templateEvaluation:true。module/global 的 set/get/add/inc/dec 在暂存变更集求值;同卡读到先前写入,单卡只写一个域,所有读取域都参与 CAS。扫描/预览只读。真实执行提交后跨出口和重挂不重放;跨进程崩溃不保证 exactly-once。
148
182
 
149
- - `persona`:`prefix` / `suffix` / `complete` / `includeRuntimeContext`。
150
- - `variables`:`{{键}}` 插值源;空字符串是合法占位(不按空值删键处理)。
151
- - `customTools`:模型工具定义,执行器五种;结构见仓库 `templates/tools/*.yml`。
152
- - `subagentToolPolicy`:`ceiling` / `defaultProfile` / `profiles` / `characterBindings` /
153
- `taskRules` / `modelExpansion`;缺省时子代理走官方委派行为。
154
- - `moduleConfigs`:行级 config 直写(优先级低于已声明的共享参数),给参数桥没覆盖的键用。
155
- - `configOrder`:规则 id → 序号;缺省按声明序 ×10。切片里落在 `rules/_settings.yml`。
183
+ ## 六、退役输入的显式转换
156
184
 
157
- **目录形态**:`modules/<id>/module.yml` 是定义;旁边的 `rules/<规则id>.yml`、`rules/_settings.yml`、
158
- `rules/variables.yml` 是插件从它物化的切片。
185
+ 旧 world-book/stWorldBook/stWorldBookRecursive/stMacros/stSource、动作 config.variables、扁平 persona 和旧工具能力不作为运行兼容面。重新导入标准 ST 或按 SKILL.md 的转换步骤改写;保留原件和私有记忆,不能靠删来源标记绕过分享保护。旧 API 别名不等于新工具授权。
@@ -4,7 +4,8 @@
4
4
  # - configKind=anchor → 固定锚点序,按模块文件相对顺序排所有 ordered 之前(原 13-anchor)
5
5
  # 接入:复制本文件到 模块规则模板目录,或把对象写入 module.yml.rules 数组。
6
6
  # 保存前可 POST /api/prompt-tool/settings/rules 做权威校验。
7
- # audience 为配置项(缺省=公用;main=仅主会话;subagent=仅子代理),模板不锁定。
7
+ # 受众写在规则 if.scope.audience(main/subagent);不设置即公用。
8
+ # 如需 {{WHO}},先在工作台的模块变量卡手动建立 WHO;本模板不自动登记变量。
8
9
  id: example-pre-step
9
10
  name: 示例:消息批注入
10
11
  enabled: false
@@ -30,6 +31,4 @@ then:
30
31
  value: example-pre-step
31
32
  text: |
32
33
 
33
- variables:
34
- WHO: ''
35
34
  params: {}
@@ -1,31 +1,27 @@
1
- # 模板:首句锚点(strategy=first-turn-anchor)
2
- # 首条真实用户消息后按任务类型(build / inspect / deep)注入锚句,每会话一次。
3
- # 纯净模板:参数全部留空,由用户自定义;锚句与分类正则由模板或用户配置提供,引擎不提供默认正文。
4
- # 提示:把本文件放入 模块规则模板目录,或把对象写入 module.yml.rules 数组。
1
+ # 直接匹配真实用户消息,再以普通动作注入自定义正文。
2
+ # 确认词与正文由用户填写;复制分支可表达不同任务的注入规则。
5
3
  id: example-first-turn-anchor
6
- name: 示例:首句锚点
4
+ name: 示例:匹配后注入
7
5
  enabled: false
8
6
  layer: pre-step
7
+ if:
8
+ text:
9
+ subject: userMessage
10
+ keys: [自定义触发词]
9
11
  then:
10
12
  - id: inject
11
13
  kind: inject-text
12
14
  config:
13
15
  id: example-first-turn-anchor
14
16
  layer: pre-step
15
- strategy: first-turn-anchor
17
+ strategy: static
16
18
  position: after-user
17
19
  dedupe: session
18
20
  configKind: ordered
19
21
  order: 0
20
22
  role: user
21
23
  mergeMode: separate
22
- sourceKind: ''
24
+ sourceKind: plugin
23
25
  form: notice
24
26
  params:
25
- useCustom: false
26
- text: "" # 自定义锚文本(useCustom=true 时固定注入)
27
- buildPattern: "" # 构建任务正则;留空 = 该分类不生效
28
- complexPattern: "" # 复杂任务正则;留空 = 该分类不生效
29
- firstTurnBuild: "" # 构建任务锚句(留空 = 不注入该类别锚句)
30
- firstTurnInspect: "" # 排查任务锚句(留空 = 不注入该类别锚句)
31
- firstTurnDeep: "" # 复杂设计锚句(留空 = 不注入该类别锚句)
27
+ text: "" # 自定义正文
@@ -1,11 +1,5 @@
1
- # 复杂任务判定 fallback 复用锚定卡的 complexPattern;长度判定仅使用显式 complexMinChars;未设置时不按长度分类
2
- # 简单任务自动引导句(留空 = 不注入该类别引导)
3
- # 复杂任务自动引导句(留空 = 不注入该类别引导)
4
-
5
- # 模板:每轮引导(strategy=guide-auto)
6
- # 晋升后每轮用户消息后按复杂度注入弱/深度引导;modelScope=flash 表示仅 flash 模型会话注入。
7
- # 纯净模板:参数全部留空,由用户自定义;引导句由模板或用户配置提供,留空不注入。
8
- # 提示:把本文件放入 模块规则模板目录,或把对象写入 module.yml.rules 数组。
1
+ # 模板:按当前批次全部真实用户文本选择引导;正文留空,由用户填写后启用。
2
+ # minChars/maxChars 含端点;复杂度由正则或长度分支表达,无专用策略参数。
9
3
  id: example-guide-auto
10
4
  name: 示例:每轮引导
11
5
  enabled: false
@@ -17,24 +11,34 @@ if:
17
11
  - phase:
18
12
  promoted: true
19
13
  includeSubagents: false
14
+ - text:
15
+ subject: userMessage
16
+ minChars: 1
20
17
  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
18
+ - if:
19
+ any:
20
+ - text:
21
+ subject: userMessage
22
+ keys: ['复杂|重构|排查'] # 按需替换分类表达式
23
+ useRegex: true
24
+ - text:
25
+ subject: userMessage
26
+ minChars: 121
27
+ then:
28
+ - id: deep-guide
29
+ kind: inject-text
30
+ config:
31
+ layer: pre-step
32
+ strategy: static
33
+ position: after-user
34
+ dedupe: batch
35
+ text: "" # 复杂任务引导
36
+ else:
37
+ - id: weak-guide
38
+ kind: inject-text
39
+ config:
40
+ layer: pre-step
41
+ strategy: static
42
+ position: after-user
43
+ dedupe: batch
44
+ text: "" # 简单任务引导
@@ -1,35 +1,47 @@
1
- # 模板:自定义锚词兜底注入(strategy=custom-fallback)
2
- # 首轮推理命中锚定确认词后注入一次;未命中最多两轮兜底。确认词集合 anchorWords 由
3
- # writePreset 从锚句自动派生(firstTurnWord 空时);显式 firstTurnWord 覆盖派生。
4
- # 两者都为空 = 不做词确认,只走未命中兜底注入(引擎不内置确认词)。
5
- # 提示:把本文件放入 模块规则模板目录,或把对象写入 module.yml.rules 数组。
1
+ # 先投递锚句,仅确认该次投递后的模型推理,再注入正文。
2
+ # 默认持续等待;需要兜底时在 anchor 下显式添加 fallbackAfter: N。
3
+ # 默认等待下一次正常请求;续跑通过既有 turn-stop 规则显式配置。
6
4
  id: example-custom-fallback
7
- name: 示例:自定义锚词兜底注入
5
+ name: 示例:锚句确认后注入
8
6
  enabled: false
9
7
  layer: pre-step
10
- if:
11
- all:
12
- - phase:
13
- promoted: true
14
- includeSubagents: false
15
- - anchor:
16
- keys: []
17
- fallbackAfter: 1
18
8
  then:
19
- - id: inject
9
+ - id: seed
20
10
  kind: inject-text
21
11
  config:
22
- id: example-custom-fallback
12
+ id: example-custom-fallback-seed
23
13
  layer: pre-step
24
- strategy: anchor-notice
25
- position: before-all
14
+ strategy: static
15
+ position: after-user
26
16
  dedupe: session
27
17
  configKind: ordered
28
- order: 20
18
+ order: 0
29
19
  role: user
30
20
  mergeMode: separate
31
21
  sourceKind: plugin
32
22
  form: notice
33
23
  params:
34
- text: "" # 注入文本(如 preset.md 内容);留空 = 不注入
35
- firstTurnWord: "" # 锚定确认词(显式覆盖;空 = 自动派生)
24
+ text: "" # 自定义锚句,要求模型输出约定确认词
25
+ - if:
26
+ anchor:
27
+ subject: assistantReasoning
28
+ keys: [自定义确认词]
29
+ after:
30
+ action: seed
31
+ then:
32
+ - id: body
33
+ kind: inject-text
34
+ config:
35
+ id: example-custom-fallback-body
36
+ layer: pre-step
37
+ strategy: static
38
+ position: before-all
39
+ dedupe: session
40
+ configKind: ordered
41
+ order: 20
42
+ role: user
43
+ mergeMode: separate
44
+ sourceKind: plugin
45
+ form: notice
46
+ params:
47
+ text: "" # 自定义正文
@@ -1,8 +1,6 @@
1
1
  # 模板:system-section 静态 system 段(缓存友好,静态内容优先放这里)
2
2
  # order 参考:-100 身份 / 0 persona-prefix / 100-199 工具引导 / 10200 persona-suffix。
3
- # 人设用法:params.sectionName = deployment:persona-prefix(第一方指导之前)或
4
- # deployment:persona-suffix(第一方指导之后)时注册为人设段
5
- # (同名 shadow 全局 persona,模块列表显示「人设」徽标;子代理经 scope 链继承)。
3
+ # 自定义系统段使用自己的 sectionName;官方人设覆盖由独立 persona.main/subagent 卡管理。
6
4
  # - complete: true 让本段成为唯一的 system prompt 段(身份注入、人设后缀、工具指南等
7
5
  # 其余 system 段全部被抑制;工具链、运行时上下文与变量仍保留)。同一模块只能有一个,
8
6
  # 且与顶层人设的「独占」互斥:写盘前由 bridge 拒绝(400),装配前另有一道兜底校验,
@@ -22,7 +20,6 @@ then:
22
20
  mergeMode: merged
23
21
  text: |
24
22
 
25
- variables: {}
26
23
  params:
27
24
  complete: false
28
25
  suppressRuntimeContext: false
@@ -5,13 +5,7 @@ if:
5
5
  scope:
6
6
  modelScope: flash
7
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
8
+ - id: output
9
+ kind: stream-output
10
+ mode: pass
11
+ text: "" # mode=replace 时替代整个模型流的文本
@@ -1,19 +1,21 @@
1
- # postAction=replace/block 时使用的文本
2
-
3
- # 模板:tool-pipeline 工具行为策略(对已注册工具的 pre/post 改写;
4
- # 自定义工具定义见工具管理区块——tool-pipeline 层筛选可见)。
1
+ # 模板:tool-pipeline 工具行为策略
2
+ #
3
+ # 工具链拆成两个动作、两个执行点:
4
+ # - `tool-gate`(tools/pre-execute):allow / deny / ask,只读 decision / reason;
5
+ # - `tool-result`(tools/post-execute):accept / replace / block,只读 action / text。
6
+ # 工具名只在共享 names 条件声明。
7
+ # 写错相位的字段在编译期就是未知字段,不会静默失效。
5
8
  id: example-tool-pipeline
6
9
  layer: tool-pipeline
10
+ if:
11
+ names:
12
+ allow: [bash, run_code]
7
13
  then:
8
14
  - id: before
9
- kind: decision
10
- phase: pre
15
+ kind: tool-gate
11
16
  decision: allow
12
- toolNames: bash,run_code
13
17
  reason: 该工具被提示词配置禁用
14
18
  - id: after
15
- kind: decision
16
- phase: post
19
+ kind: tool-result
17
20
  action: accept
18
- toolNames: bash,run_code
19
21
  text: ""
@@ -1,12 +1,11 @@
1
1
  # 模板:工具结果之后追加一条 durable user 通知。
2
2
  #
3
- # 与 `decision`(post) 的分工:`decision` 改写的是**工具结果本身**(replace / block),
3
+ # 与 `tool-result` 的分工:`tool-result` 改写的是**工具结果本身**(replace / block),
4
4
  # `append-context` 不动结果,只在结果之后追加一条 user 角色通知。
5
- # 需要模型**再做一步**时改用 `mode: continue`:它走 `agent/turn-stopping` 强制续跑一步,
6
- # 每轮 1 次、每会话 3 次的上限由引擎内置,不能配置关闭(失控的续跑会把会话卡住)。
5
+ # 需要模型**再做一步**时使用 `inject-text` 的 `turn-stop` 层(模板65),
6
+ # 每个来源(模块)每轮 1 次 / 每会话 3 次的上限由引擎内置,不能配置关闭(失控的续跑会把会话卡住)。
7
7
  #
8
- # 条件用规则级 `if.names`(工具名,取自 exec.name):它与 `decision.toolNames` 是两回事——
9
- # 后者是动作自己的名单,前者决定这条规则要不要跑。
8
+ # 工具名条件统一用规则级或分支级 `if.names`(取自 exec.name)。
10
9
  id: example-append-context
11
10
  name: 工具结果后追加上下文
12
11
  enabled: false
@@ -18,5 +17,4 @@ if:
18
17
  then:
19
18
  - id: note-after-tool
20
19
  kind: append-context
21
- mode: context
22
20
  text: 网络结果可能已过期;引用它时说明来源与抓取时间。
@@ -1,6 +1,6 @@
1
1
  # 模板:turn-stop 轮次停止层(命中条件时阻止本轮停止,强制模型续跑一步)
2
- # 接入:subject 缺省 assistantText(匹配最后一条 assistant 消息文本);不写 match
3
- # 即无条件续跑。续跑上限固定在引擎内——每轮 1 次、每会话 3 次,配置关不掉。
2
+ # 接入:条件写在规则 if(本模板用 text);turn-stop 不再有 config.subject/match。
3
+ # 续跑上限固定在引擎内——每个来源(模块)每轮 1 次 / 每会话 3 次,配置关不掉。
4
4
  id: example-turn-stop
5
5
  name: 未完成时强制续跑
6
6
  layer: turn-stop
@@ -4,8 +4,8 @@
4
4
  # 不命中什么都不做。缺省 `target: next-turn`,也可写 `next-step`。
5
5
  # 插件来源的消息(含本动作自己插入的那条)永不再次前置,防自触发插队。
6
6
  #
7
- # 判「首轮」用 `session: { type: user/message, present: false }`——还没有任何
8
- # user/message 事件。注意 `agent/inbox/inserted` 拿不到任务文本本身,所以别在这里
7
+ # 判「首轮」用 `session: { type: user/message, present: false }`——模型**当前可见**
8
+ # 的上下文里还没有 user/message 事件(判据按可见上下文,压缩遮蔽的历史不算数)。注意 `agent/inbox/inserted` 拿不到任务文本本身,所以别在这里
9
9
  # 用 `text` 谓词筛任务内容(那是 `pre-step` 层的事,见 70-subagent-maintenance.yml)。
10
10
  id: example-inbox-prepend
11
11
  name: 首轮前置一条消息