dsh-plugin-prompt-tool 2.0.1 → 3.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 (231) 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 +5 -7
  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 +23 -15
  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 +62 -19
  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 +4 -7
  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 +4 -4
  40. package/engine/conditions/count.mjs +43 -13
  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 +10 -5
  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 +165 -230
  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 +302 -28
  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 +47 -26
  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 +39 -35
  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 +37 -762
  123. package/lib/index.mjs +26919 -5791
  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 +158 -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 +100 -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/README.md +10 -0
  146. package/modules/soul/assets/templates/agents-template.md +6 -0
  147. package/modules/soul/assets/vital.md +9 -0
  148. package/modules/soul/module.yml +311 -0
  149. package/modules/superpowers/module.yml +122 -0
  150. package/modules/tool-surface/module.yml +51 -47
  151. package/package.json +40 -41
  152. package/skills/dsh-module/SKILL.md +119 -0
  153. package/skills/dsh-module/reference.md +185 -0
  154. package/templates/10-pre-step.yml +2 -3
  155. package/templates/14-first-turn-anchor.yml +10 -14
  156. package/templates/15-guide-auto.yml +32 -28
  157. package/templates/16-custom-fallback.yml +33 -21
  158. package/templates/20-system-section.yml +1 -4
  159. package/templates/50-llm-stream.yml +4 -10
  160. package/templates/60-tool-pipeline.yml +12 -10
  161. package/templates/63-append-context.yml +20 -0
  162. package/templates/64-pre-step-filter.yml +23 -0
  163. package/templates/65-turn-stop.yml +2 -2
  164. package/templates/67-inbox-prepend.yml +22 -0
  165. package/templates/70-subagent-maintenance.yml +9 -10
  166. package/templates/75-subagent-end.yml +2 -2
  167. package/templates/80-tool-surface.yml +41 -57
  168. package/templates/tools/40-delegate-module-import.yml +22 -0
  169. package/templates/tools/50-delegate-module-rules.yml +14 -0
  170. package/templates/tools/60-delegate-module-variables.yml +17 -0
  171. package/templates/tools/70-delegate-module-rules-edit.yml +31 -0
  172. package/engine/actions/decision.mjs +0 -54
  173. package/engine/actions/guard.mjs +0 -80
  174. package/engine/actions/sdk-strip.mjs +0 -30
  175. package/engine/character-tools.mjs +0 -8
  176. package/engine/classify-task.mjs +0 -53
  177. package/engine/compositions/library/agent-instructions.yml +0 -9
  178. package/engine/compositions/library/command-goal.yml +0 -7
  179. package/engine/compositions/library/compaction.yml +0 -22
  180. package/engine/compositions/library/delegation-ptc.yml +0 -58
  181. package/engine/compositions/library/delegation.yml +0 -56
  182. package/engine/compositions/library/persistent-shell.yml +0 -50
  183. package/engine/compositions/library/planning.yml +0 -26
  184. package/engine/compositions/library/skill-filesystem-cordis.yml +0 -10
  185. package/engine/compositions/library/skill-filesystem.yml +0 -7
  186. package/engine/compositions/library/tool-ask-user.yml +0 -7
  187. package/engine/compositions/library/tool-bash.yml +0 -8
  188. package/engine/compositions/library/tool-cordis.yml +0 -7
  189. package/engine/compositions/library/tool-fs-search.yml +0 -9
  190. package/engine/compositions/library/tool-fs.yml +0 -7
  191. package/engine/compositions/library/tool-goal.yml +0 -7
  192. package/engine/compositions/library/tool-jobs.yml +0 -7
  193. package/engine/compositions/library/tool-plugin-manager-disabled.yml +0 -8
  194. package/engine/compositions/library/tool-plugin-manager.yml +0 -8
  195. package/engine/compositions/library/tool-present.yml +0 -7
  196. package/engine/compositions/library/tool-presentation.yml +0 -9
  197. package/engine/compositions/library/tool-pwsh.yml +0 -8
  198. package/engine/compositions/library/tool-skill.yml +0 -7
  199. package/engine/compositions/library/tool-todo.yml +0 -9
  200. package/engine/compositions/library/tool-web.yml +0 -10
  201. package/engine/compositions/source/local/character-tools.yml +0 -5
  202. package/engine/compositions/source/local/declared-triggers.yml +0 -12
  203. package/engine/compositions/source/local/dev-tool-search.yml +0 -11
  204. package/engine/compositions/source/local/session-var-tools.yml +0 -5
  205. package/engine/compositions/source/local/subagent-tool-policy.yml +0 -21
  206. package/engine/compositions/source/local/world-book-tools.yml +0 -5
  207. package/engine/condition.mjs +0 -96
  208. package/engine/declared-triggers.mjs +0 -93
  209. package/engine/session-var-tools.mjs +0 -8
  210. package/engine/session-vars.mjs +0 -54
  211. package/engine/st-macros.d.mts +0 -22
  212. package/engine/st-macros.mjs +0 -208
  213. package/engine/st-render.mjs +0 -109
  214. package/engine/st-world-book.d.mts +0 -10
  215. package/engine/subagent-tool-policy-core.mjs +0 -400
  216. package/engine/subagent-tool-policy.mjs +0 -352
  217. package/engine/trigger-spec.mjs +0 -173
  218. package/engine/world-book-tools.mjs +0 -8
  219. package/lib/migrate-rules.d.mts +0 -1
  220. package/lib/migrate-rules.mjs +0 -39
  221. package/lib/module-package-CHPFweqK.mjs +0 -2
  222. package/lib/module-package-Cnd1_mwx.mjs +0 -2872
  223. package/lib/paths-CyP0IkaM.d.mts +0 -1390
  224. package/lib/preset-transfer.d.mts +0 -2
  225. package/lib/preset-transfer.mjs +0 -3
  226. package/lib/rules-migration-DJ6vASB5.mjs +0 -15334
  227. package/templates/policies/legacy-defaults.yml +0 -34
  228. package/templates/tools/40-delegate-character.yml +0 -15
  229. package/templates/tools/50-delegate-worldbook.yml +0 -15
  230. package/templates/tools/60-delegate-session-var.yml +0 -15
  231. package/templates/tools/70-delegate-worldbook-upsert.yml +0 -36
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-plugin-prompt-tool",
3
- "version": "2.0.1",
4
- "description": "DSH 插件:提示词工具,规范模型的思维链与回答内容,提供 Web UI 编辑 preset.md 与 AGENTS.md,并按 skills 目录注册可开关技能。",
3
+ "version": "3.0.0",
4
+ "description": "DSH 插件:提示词工具,规范模型的思维链与回答内容,提供 Web UI 编辑 module.yml 与 AGENTS.md,并按 skills 目录注册可开关技能。",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -10,9 +10,6 @@
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
- },
16
13
  "exports": {
17
14
  ".": {
18
15
  "types": "./lib/index.d.mts",
@@ -23,9 +20,11 @@
23
20
  "./package.json": "./package.json"
24
21
  },
25
22
  "engines": {
26
- "node": "^22.19.0 || >=24.0.0"
23
+ "node": "^22.19.0 || >=24.0.0",
24
+ "dsh": ">=0.2.0-rc.1"
27
25
  },
28
26
  "dsh": {
27
+ "manifestVersion": 1,
29
28
  "bundle": {
30
29
  "patch": "./cordis.patch.yml"
31
30
  },
@@ -62,35 +61,32 @@
62
61
  "react": "^18.2.0"
63
62
  },
64
63
  "devDependencies": {
65
- "@deepseek-ai/cordis": "4.0.4",
66
- "@deepseek-ai/dsh-agent": ">=0.2.0-rc.1",
67
- "@deepseek-ai/dsh-agent-preset-registry": ">=0.2.0-rc.1",
68
- "@deepseek-ai/dsh-api-remotes": ">=0.2.0-rc.1",
69
- "@deepseek-ai/dsh-api-session-controller": ">=0.2.0-rc.1",
70
- "@deepseek-ai/dsh-client-connection": ">=0.2.0-rc.1",
71
- "@deepseek-ai/dsh-client-locale": ">=0.2.0-rc.1",
72
- "@deepseek-ai/dsh-client-store": ">=0.2.0-rc.1",
73
- "@deepseek-ai/dsh-client-ui-layout": ">=0.2.0-rc.1",
74
- "@deepseek-ai/dsh-client-ui-settings": ">=0.2.0-rc.1",
75
- "@deepseek-ai/dsh-client-ui-settings-plugins": ">=0.2.0-rc.1",
76
- "@deepseek-ai/dsh-client-ui-renderer": ">=0.2.0-rc.1",
77
- "@deepseek-ai/dsh-client-ui-session": ">=0.2.0-rc.1",
78
- "@deepseek-ai/dsh-client-ui-workspace": ">=0.2.0-rc.1",
79
- "@deepseek-ai/dsh-client-ui-slots": ">=0.2.0-rc.1",
80
- "@deepseek-ai/dsh-commands": ">=0.2.0-rc.1",
81
- "@deepseek-ai/dsh-fs": ">=0.2.0-rc.1",
82
- "@deepseek-ai/dsh-host-webserver": ">=0.2.0-rc.1",
83
- "@deepseek-ai/dsh-llm": ">=0.2.0-rc.1",
84
- "@deepseek-ai/dsh-package-manifest": ">=0.2.0-rc.1",
85
- "@deepseek-ai/dsh-scope": ">=0.2.0-rc.1",
86
- "@deepseek-ai/dsh-session": ">=0.2.0-rc.1",
87
- "@deepseek-ai/dsh-settings": ">=0.2.0-rc.1",
88
- "@deepseek-ai/dsh-skill": ">=0.2.0-rc.1",
89
- "@deepseek-ai/dsh-skill-filesystem": ">=0.2.0-rc.1",
90
- "@deepseek-ai/dsh-subagent": ">=0.2.0-rc.1",
91
- "@deepseek-ai/dsh-system-prompt": ">=0.2.0-rc.1",
92
- "@deepseek-ai/dsh-tool-subagent": ">=0.2.0-rc.1",
93
- "@deepseek-ai/dsh-tools": ">=0.2.0-rc.1",
64
+ "@deepseek-ai/cordis": "4.0.5-alpha.1",
65
+ "@deepseek-ai/dsh-agent": "0.2.1-alpha.2",
66
+ "@deepseek-ai/dsh-agent-preset-registry": "0.2.1-alpha.2",
67
+ "@deepseek-ai/dsh-api-remotes": "0.2.1-alpha.2",
68
+ "@deepseek-ai/dsh-api-session-controller": "0.2.1-alpha.2",
69
+ "@deepseek-ai/dsh-client-connection": "0.2.1-alpha.2",
70
+ "@deepseek-ai/dsh-client-locale": "0.2.1-alpha.2",
71
+ "@deepseek-ai/dsh-client-ui-layout": "0.2.1-alpha.2",
72
+ "@deepseek-ai/dsh-client-ui-renderer": "0.2.1-alpha.2",
73
+ "@deepseek-ai/dsh-client-ui-session": "0.2.1-alpha.2",
74
+ "@deepseek-ai/dsh-client-ui-settings": "0.2.1-alpha.2",
75
+ "@deepseek-ai/dsh-client-ui-settings-plugins": "0.2.1-alpha.2",
76
+ "@deepseek-ai/dsh-client-ui-sidebar": "0.2.1-alpha.2",
77
+ "@deepseek-ai/dsh-client-ui-slots": "0.2.1-alpha.2",
78
+ "@deepseek-ai/dsh-client-ui-workspace": "0.2.1-alpha.2",
79
+ "@deepseek-ai/dsh-commands": "0.2.1-alpha.2",
80
+ "@deepseek-ai/dsh-fs": "0.2.1-alpha.2",
81
+ "@deepseek-ai/dsh-host-webserver": "0.2.1-alpha.2",
82
+ "@deepseek-ai/dsh-llm": "0.2.1-alpha.2",
83
+ "@deepseek-ai/dsh-scope": "0.2.1-alpha.2",
84
+ "@deepseek-ai/dsh-settings": "0.2.1-alpha.2",
85
+ "@deepseek-ai/dsh-skill": "0.2.1-alpha.2",
86
+ "@deepseek-ai/dsh-skill-filesystem": "0.2.1-alpha.2",
87
+ "@deepseek-ai/dsh-subagent": "0.2.1-alpha.2",
88
+ "@deepseek-ai/dsh-system-prompt": "0.2.1-alpha.2",
89
+ "@deepseek-ai/dsh-tools": "0.2.1-alpha.2",
94
90
  "@types/node": "^26.2.0",
95
91
  "@types/react": "~18.3.1",
96
92
  "@types/react-dom": "^18.3.0",
@@ -109,25 +105,28 @@
109
105
  "cordis.patch.yml",
110
106
  "LICENSE",
111
107
  "modules",
108
+ "skills",
112
109
  "templates",
113
110
  "README.md"
114
111
  ],
115
112
  "scripts": {
116
113
  "build": "tsdown",
117
114
  "prepare": "tsdown",
118
- "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.client.json --noEmit",
115
+ "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.client.json --noEmit && tsc -p tsconfig.test.json --noEmit",
119
116
  "lint": "oxlint src test tsdown.config.ts",
120
117
  "test": "node scripts/run-tests.mjs",
121
118
  "sync:yaml": "node scripts/sync-yaml-vendor.mjs",
122
- "rebuild:preset-template": "node scripts/rebuild-preset-template.mjs",
123
- "rematerialize:presets": "node scripts/rematerialize-presets.mjs",
124
- "migrate:rules": "node lib/migrate-rules.mjs",
119
+ "sync:harness": "node scripts/sync-harness-deps.mjs",
120
+ "rebuild:module-template": "node scripts/rebuild-module-template.mjs",
121
+ "rematerialize:modules": "node scripts/rematerialize-modules.mjs",
125
122
  "repair:profile": "node scripts/repair-profile.mjs",
126
- "verify:host": "node scripts/verify-host-contracts.mjs"
123
+ "verify:harness": "node scripts/sync-harness-deps.mjs --check",
124
+ "verify:host": "node scripts/verify-host-contracts.mjs",
125
+ "verify:pack": "node scripts/verify-package.mjs"
127
126
  },
128
127
  "dependencies": {
129
128
  "@deepseek-ai/schemastery": "^3.18.4",
130
129
  "@zip.js/zip.js": "2.15.0",
131
- "yaml": "^2.9.0"
130
+ "yaml": "^2.9.1"
132
131
  }
133
132
  }
@@ -0,0 +1,119 @@
1
+ ---
2
+ name: dsh-module
3
+ description: 新建、修改、审查 DSH Prompt Tool 模块,或把规则、人设、工具和 SillyTavern 来源转成原生 module.yml;也用于排查启用后未注入、将旧内部上下文/会话变量格式显式转换为原生规则。模块由插件在各 Agent scope 装配,与官方会话预设分开。
4
+ ---
5
+
6
+ # DSH 模块
7
+
8
+ 先确定任务是创建、编辑、审查、导入还是旧格式转换。只读审查不授予修复;用户已经授权的修改直接完成,不额外请求确认。涉及安装、启用新能力、覆盖用户文件或重启服务,遵守会话已有授权和项目边界。
9
+
10
+ 路径基于实际 `$DSH_HOME`。模块定义为 `.prompt-tool/modules/<id>/module.yml`,启用集合在 `.prompt-tool/config.yml`。包内 `engine/`、`templates/`、`modules/` 相对插件包根,不相对本技能目录;可通过已加载插件位置或实际安装信息定位,不猜默认 profile。
11
+
12
+ ## 1. 读取目标与所有者
13
+
14
+ 读取完整 module.yml 与有关资产,确认目录名和 id 一致,保留用户已有修改。不要编辑 `rules/`:它是完整定义的校验投影,手改会被恢复。
15
+
16
+ | 内容 | 写入位置 |
17
+ |---|---|
18
+ | 条件、动作、正文、规则启停 | rules |
19
+ | 共享模型/能力参数 | layerSettings 的登记层 |
20
+ | 持久模块变量 | 顶层 variables |
21
+ | 全局变量 | 同一 DSH_HOME 的插件 variables.yml,经变量 owner 读写 |
22
+ | 人设正文/选项 | 各模块 persona.main / persona.subagent;rules/_settings.yml 仅作投影 |
23
+ | 主/子人设来源 | config.yml.personaSources 只存单选模块 ID,默认官方 |
24
+ | 自定义工具/子代理授权 | customTools / subagentToolPolicy |
25
+ | 模块私有文件 | memory.md、assets/(只读)、data/(只追加),经 module_file_read/append 显式读写;装配清单走 module_manifest |
26
+ | 用户指令文件 | 原文件与独立指令策略,独立授权通道 |
27
+
28
+ 完成判据:每处改动都有单一 owner,工具操作目标与 UI 编辑模块不混淆。
29
+
30
+ ## 2. 创建最小规则
31
+
32
+ ```yaml
33
+ id: my-module
34
+ name: 我的模块
35
+ version: 1.0.0
36
+ modules: [rule-engine]
37
+ variables: {}
38
+ rules:
39
+ - id: project-rules
40
+ enabled: false
41
+ then:
42
+ - id: inject
43
+ kind: inject-text
44
+ config:
45
+ layer: system-section
46
+ strategy: static
47
+ text: |-
48
+ 按用户确认的项目约束执行。
49
+ ```
50
+
51
+ 一条规则有独立总开关;动作 id 在整条规则的 then/else/嵌套树内唯一。if 缺省为无条件,else 必须有对应 if。条件未知时不能以“否定”为由放行。规则级 layer 是动作缺省层与展示归属,不是全局执行阶段。
52
+
53
+ 条件、动作和字段选择查 [reference.md](reference.md)。工具或请求类动作有自身执行点;tool-pipeline 没有 inject-text 通道。普通文本空白保持空,不补未经请求的默认正文。
54
+
55
+ 完成判据:完整候选通过唯一 compileRules 校验,规则启停、受众、层、位置和次数符合请求。静态可解析不等于模型实际收到。
56
+
57
+ ## 3. 变量、人设和上下文激活
58
+
59
+ 普通规则引用的变量需手动在模块变量卡建立;不要扫描正文偷偷登记。空字符串是有效占位,会遮住同名全局值;删除模块键才回落全局。动作 config.variables 已退役。
60
+
61
+ 需要赋值才声明 `params.templateEvaluation: true`,使用 `{{module.set::key::value}}` 或 module/global 的 get/add/inc/dec。一张模板只能写一个域,扫描与预览只读;禁止用 session 表或执行重挂伪装持久事务。
62
+
63
+ 人设正文使用模块内 persona.main/subagent;主会话和子代理各自单选来源,默认官方。来源由独立人设卡下拉选择,config.yml.personaSources 只存模块 ID,不能放正文;选择不自动启用来源模块 rules。仅取所选模块对应受众的字段,不跨模块逐字段合并。省略字段继承、空文本清空、complete:false 解除人设独占;有效官方人设与启用规则的 complete 冲突仍需配装预检。人设不进入规则数组或排序,rules/_settings.yml 的校验投影保持只读。
64
+
65
+ 上下文激活使用 `strategy: context-activation`、`params.activation.scan: batch|history`。关键词、候选组和副键约束的语义查 reference;启停与受众仍归规则。记忆不自动生成常驻规则。
66
+
67
+ 完成判据:变量来源和空值语义明确,人设继承可表达,激活字段无需依赖“来自 ST”才生效。
68
+
69
+ ## 4. 能力与模型工具
70
+
71
+ 只声明任务需要的能力。模型工具目录与能力映射如下:
72
+
73
+ | 能力 | 工具 |
74
+ |---|---|
75
+ | module-rule-tools | module_rules_read / module_rules_edit |
76
+ | module-variable-tools | module_variables |
77
+ | module-file-tools | module_file_read / module_file_append |
78
+ | module-manifest-tools | module_manifest |
79
+ | module-import-tools | module_import |
80
+ | tool-config-engine | customTools 声明的工具 |
81
+
82
+ 规则先读完整树与 revisions,再携带 expectedModuleId/expectedRevisions 编辑完整合法规则;关闭标记 settingsChanged,显式启用用 activateRuleId,删除整规则用 rule:null。正文保存不覆盖并发状态,版本冲突先重读。
83
+
84
+ 变量先 list/get 取版本,再 set/delete;set 必须显式字符串,空串不是删除。global 写影响同一安装的所有模块。文件 append 带当前目标身份与显式 path,与规则事务分开;module_manifest 按清单只写 data/、不覆盖。module_import 先预览并完成选择,提交原始 files 与两份预览凭据,默认另存且不自动启用。
85
+
86
+ 共享模型/能力参数以 `ENGINE_PARAM_DEFINITIONS` 为唯一目录,使用登记的 layerSettings 路径:主/子模型路由与采样、PTC 呈现、run_code 环境、Git Bash、指令提示和工具批准都在其中;数量与 options 以源码为准,不抄旧文档的固定键数。也可通过 request-params 动作按受众改请求。官方工具、规划、压缩和普通委派来自官方预设,模块不重声明它们。
87
+
88
+ 完成判据:声明与实际工具注册一致,目标、版本、批准和取消保护没有绕过。
89
+
90
+ ## 5. 导入和显式转换
91
+
92
+ ST 预设、角色卡、世界书优先经工作台或 module_import 转换。**ST 导入自动登记缺失裸变量为空占位;普通规则不自动登记。** 导入只转换文本和声明,不执行 STscript 或任意来源代码;报告与生成后的 enabled 状态必须一起检查。
93
+
94
+ 用户要求转换旧内部模块时:
95
+
96
+ 1. 读取完整定义并保存用户同意范围内的备份;保留未知资产、记忆与来源证明。
97
+ 2. 将旧上下文策略转换为 context-activation,明确 scan;ST 数字副键映射为具名真值逻辑,不能照抄旧 any/not 注释。
98
+ 3. 将 stWorldBook 执行字段拆为 activation,把角色/位置/不支持控制项移至 source.original;模块递归声明 contextActivationRecursive。
99
+ 4. 将 set/get/add/inc/decvar 经 parser 转为 module/global 操作,启用 templateEvaluation。局部变量无冲突提升到顶层 variables,同名不同值先报告并解决;不建立第三层变量。
100
+ 5. 将旧工具与能力改为上表名称;完整规则替换保留分支与未改字段,记忆从 note 副作用分离。
101
+ 6. 将扁平 persona 明确分配到 main/subagent,保留省略/空串/false;由用户为两类受众各选择官方或一个模块来源,不因转换自动启用规则或切换来源。
102
+ 7. 旧私有记忆标记先核实并把私有内容归回 memory.md;不能单删标记后导出。
103
+ 8. 在隔离候选校验与读回,再按授权提交;失败保留原定义。
104
+
105
+ 插件不提供自动迁移器。未知宏、不等价控制或无法证明的行为要明确报告,不能把成功解析当成转换完成。
106
+
107
+ ## 6. 生效与交付
108
+
109
+ 工作台保存和开关走官方插件运行更新;变量内容更新不重挂 Agent。直接手改 module.yml 的实际加载结果需通过重新读取/重建链确认。代码、bundle、patch 更新需要用户重启 DSH;不自行停止正在运行的服务。
110
+
111
+ 验证以实际公共出口为准:层、位置、次数、受众、规则条件、epoch、变量写入与 disposer。读取失败、过期版本、解析拒绝不应改盘;发布失败区分已保存与尚未生效,refreshOnly 不重放写入。
112
+
113
+ 在本仓库开发时遵守 AGENTS.md 的隔离 cwd 和完整 package gates。一次性探针放临时目录,永久测试须满足项目的 seam/独立真值/公共接口准入,不为退役符号写墓碑测试。
114
+
115
+ 完成判据:用户要求的改动、生效验证和失败路径已覆盖,交付明确实际运行过的检查与未验证限制。
116
+
117
+ ## 审查已有模块
118
+
119
+ 按身份、完整规则树、执行点、受众、变量 owner、共享参数归属、能力授权、人设单选来源与 complete 冲突、排序、保存版本逐项核对。纯审查只给事实与改法,不自动把发现转成修复授权。
@@ -0,0 +1,185 @@
1
+ # 模块参考
2
+
3
+ 由 `SKILL.md` 的指针进入:挑条件、挑动作、查层字段、查模块名与参数时读它。
4
+
5
+ 权威来源是源码:`engine/rule-spec.mjs`、`engine/conditions/`、`engine/actions/catalog.mjs`、
6
+ `engine/schema.mjs` 都在**插件包内**;参数表的源头是 `src/shared/engine-params.ts`(只有源码仓库里有,
7
+ 装态对应 `lib/` 的编译产物)。本文件是摘要,**冲突时以源码为准**。
8
+
9
+ **这些路径相对插件包根,不在本技能目录下。** 技能随包分发、装在 `$DSH_HOME/skills/dsh-module/`,
10
+ 而 `engine/`、`modules/`、`templates/` 在插件包里。包名 `dsh-plugin-prompt-tool`,定位用环境变量
11
+ `$env:DSH_PROFILE_DIR`(bash 里读 `$DSH_PROFILE_DIR`)——包就在它的 `node_modules/` 下。读包内文件用
12
+ **文件读取工具**:Desktop 部署下包可能落在 `app.asar` 里,shell、glob、grep、node 都打不开它。
13
+ 找不到包时用本摘要说明边界;需要确认未列出的能力时读取实际安装契约,不猜测支持。
14
+
15
+ ## 一、条件谓词(`if` 里能写什么)
16
+
17
+ `if` 是**单键节点**:要么组合算子,要么一个谓词。缺省即无条件。
18
+
19
+ 组合算子:`all` / `any`(非空数组)、`not`(单节点)、`notAny`(非空数组)。
20
+
21
+ | 谓词 | 字段 | 语义与边界 |
22
+ |---|---|---|
23
+ | `text` | `keys` / `secondaryKeys`,或单独 `minChars` / `maxChars`(含端点的非负安全整数);`logic`(any/all/not/notAny);`mode`(scan/prefix);`caseSensitive`;`wholeWords`;`useRegex`;`wordBoundary`;`subject` | 关键词与长度同时声明时取交集,minChars 不得大于 maxChars;userMessage 读取本批全部真实用户文本。动作级条件必须声明本通道可用的 subject;缺事实不执行 |
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
+ | `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` | 消息类信号按可见历史;tool-call/turn 按完整日志,冷启动按相同视图重建 |
27
+ | `names` | `allow` / `deny`;`caseSensitive`(缺省 true) | 名称名单:工具名(工具通道)、子代理 provider(`subagent/start`、`subagent/end`) |
28
+ | `session` | `type`(事件类型,如 `user/message`);`present`(缺省 `false`=该事件还没有);`delegated` | 会话态。判「首轮」用 `{type: user/message, present: false}` |
29
+ | `preset` | `presetId` | 当前**挂载**的官方会话预设;取不到时返回 `UNAVAILABLE`(不乐观放行) |
30
+ | `scope` | `audience`(`main`/`subagent`);`modelScope`(`all` 缺省 / `pro` / `flash`) | 受众与模型范围。这是**唯一**该写这些门的地方 |
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
+
33
+ 拿不到必要事实时谓词返回 `UNAVAILABLE`:只有严格 `true` 才执行;`any` 遇已知 `true`、`all` 遇已知
34
+ `false` 仍可决断。
35
+
36
+ ## 二、动作(`then` / `else` 里能写什么)
37
+
38
+ `then` 是非空数组;每个动作要有唯一非空 `id` 与合法 `kind`。动作级分支写成 `{ if, then, else }`
39
+ 节点嵌在数组里,可嵌套。else 必须有对应 if;必要事实未知时两支都不执行。
40
+
41
+ | 动作 | 执行点 | 主要字段 | 失败时 |
42
+ |---|---|---|---|
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
+ | `request-params` | `agent/request` 下游 | `patch`(浅合并)、`unset`(`{键: 期望值}`)、`replace`(整体替换) | 保持原请求配置 |
50
+ | `stream-output` | llm/stream | mode(pass 缺省 / replace)、text(替代正文) | 保持原流 |
51
+ | `inbox-prepend` | `agent/inbox/inserted`(emit,无 next) | `target`(`next-turn` 缺省 / `next-step`)、`text` | 不命中即什么都不做 |
52
+ | `pre-step-filter` | `agent/pre-step` 下游 | `sources` **或** `keepKinds`(互斥,未声明即不过滤)、`blockPlugins`(正交,空=关闭) | 异常时保留全部消息 |
53
+
54
+ 通用规则:
55
+
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` 上;它数的是「本动作本轮生效几次」,
60
+ 与 `count` 谓词(数持久事件)是两回事。
61
+ - `complete` 与 `suppressRuntimeContext` 是**固定注册效果**:所在规则不带 `if`(注册期即生效)。
62
+
63
+ ### 禁用或收窄某个工具
64
+
65
+ 工具的装配面由**会话原有预设**与各模块共同决定,所以「禁用」必须同时落到呈现与执行两层——只做一层会留下可见痕迹:
66
+
67
+ ```yaml
68
+ rules:
69
+ - id: no-web
70
+ then:
71
+ - id: hide-web
72
+ kind: tool-visibility
73
+ deny: [web_search, web_fetch]
74
+ reason: 本模块不开放联网工具
75
+ ```
76
+
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` 拒绝。未知动作引用保存前拒绝,发现适配器不可用则跳过提示并告警。
92
+
93
+ ## 三、九层与字段
94
+
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`) |
111
+
112
+ 三条边界:
113
+
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 段。
121
+
122
+ 策略 × 层:static 在六个可注入层;placeholder 在 pre-step、runtime-context;
123
+ context-activation 在 pre-step。分类与正文用通用条件和分支组合(模板15),动态内容策略使用既有 resolver。
124
+
125
+ ### 确认后注入
126
+
127
+ 先用普通 `inject-text` 动作投递自定义锚句,再在嵌套分支写 `if: { anchor: { keys: [已确认], after: { action: seed } } }`,then 使用另一个普通注入动作声明正文与位置。完整示例见包内 `templates/16-custom-fallback.yml`,运行边界见 [引擎指南](../../docs/engine-reuse.md#字词句确认与动作关联)。不要把等待条件放在锚句动作的父级,否则锚句也无法投递。
128
+
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-墨.jsonl
147
+ kind: jsonl
148
+ maxBytes: 8388608
149
+ ```
150
+
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。官方工具、规划、压缩与普通委派由会话原有预设提供,空模块不自动获得这些能力。
155
+
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`,插件不提供。
157
+
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 |
178
+
179
+ 未开 selective 或无副键只要求 P>0;空主键不自动常驻。求值为空的副键仍占一项。activation 还拥有 scanVariables、概率、selectionGroup、评分、sticky/cooldown/delay、递归排除与延迟层级;它的候选组与规则 group/exclusive 不同。模块递归用 contextActivationRecursive,默认 false,池跨模块共享。
180
+
181
+ 原生模板显式设置 params.templateEvaluation:true。module/global 的 set/get/add/inc/dec 在暂存变更集求值;同卡读到先前写入,单卡只写一个域,所有读取域都参与 CAS。扫描/预览只读。真实执行提交后跨出口和重挂不重放;跨进程崩溃不保证 exactly-once。
182
+
183
+ ## 六、退役输入的显式转换
184
+
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: "" # 简单任务引导