dsh-plugin-prompt-tool 0.8.1 → 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 (139) hide show
  1. package/README.md +84 -67
  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/character-tools.mjs +3 -6
  20. package/engine/compaction-epoch.mjs +31 -13
  21. package/engine/compositions/library/agent-instructions.yml +1 -1
  22. package/engine/compositions/library/command-goal.yml +1 -1
  23. package/engine/compositions/library/compaction.yml +1 -1
  24. package/engine/compositions/library/delegation-ptc.yml +1 -1
  25. package/engine/compositions/library/delegation.yml +1 -1
  26. package/engine/compositions/library/persistent-shell.yml +1 -1
  27. package/engine/compositions/library/planning.yml +1 -1
  28. package/engine/compositions/library/skill-filesystem-cordis.yml +1 -1
  29. package/engine/compositions/library/skill-filesystem.yml +1 -1
  30. package/engine/compositions/library/tool-ask-user.yml +1 -1
  31. package/engine/compositions/library/tool-bash.yml +1 -1
  32. package/engine/compositions/library/tool-cordis.yml +1 -1
  33. package/engine/compositions/library/tool-fs-search.yml +1 -1
  34. package/engine/compositions/library/tool-fs.yml +1 -1
  35. package/engine/compositions/library/tool-goal.yml +1 -1
  36. package/engine/compositions/library/tool-jobs.yml +1 -1
  37. package/engine/compositions/library/tool-plugin-manager-disabled.yml +1 -1
  38. package/engine/compositions/library/tool-plugin-manager.yml +1 -1
  39. package/engine/compositions/library/tool-present.yml +1 -1
  40. package/engine/compositions/library/tool-presentation.yml +1 -1
  41. package/engine/compositions/library/tool-pwsh.yml +1 -1
  42. package/engine/compositions/library/tool-skill.yml +1 -1
  43. package/engine/compositions/library/tool-todo.yml +1 -1
  44. package/engine/compositions/library/tool-web.yml +1 -1
  45. package/engine/compositions/source/local/dev-tool-search.yml +11 -0
  46. package/engine/compositions/source/local/instruction-hint.yml +22 -1
  47. package/engine/compositions/source/local/rule-engine.yml +6 -0
  48. package/engine/condition.mjs +16 -3
  49. package/engine/conditions/anchor.mjs +32 -0
  50. package/engine/conditions/availability.mjs +47 -0
  51. package/engine/conditions/composite.mjs +83 -0
  52. package/engine/conditions/count.mjs +140 -0
  53. package/engine/conditions/evaluation.mjs +41 -0
  54. package/engine/conditions/examples.mjs +11 -0
  55. package/engine/conditions/index.mjs +85 -0
  56. package/engine/conditions/names.mjs +21 -0
  57. package/engine/conditions/phase.mjs +54 -0
  58. package/engine/conditions/preset.mjs +94 -0
  59. package/engine/conditions/scope.mjs +18 -0
  60. package/engine/conditions/session.mjs +22 -0
  61. package/engine/conditions/source.mjs +63 -0
  62. package/engine/conditions/subject.mjs +121 -0
  63. package/engine/conditions/text.mjs +44 -0
  64. package/engine/conditions/values.mjs +32 -0
  65. package/engine/dev-tool-search.mjs +213 -0
  66. package/engine/executor.mjs +93 -31
  67. package/engine/fillers.mjs +23 -16
  68. package/engine/instruction-hint.mjs +39 -23
  69. package/engine/layers.mjs +171 -77
  70. package/engine/order.mjs +20 -0
  71. package/engine/predicates.mjs +2 -753
  72. package/engine/rule-engine.mjs +40 -0
  73. package/engine/rule-runtime.mjs +110 -0
  74. package/engine/rule-spec.mjs +187 -0
  75. package/engine/schema.mjs +32 -11
  76. package/engine/session-var-tools.mjs +3 -6
  77. package/engine/shared.mjs +1 -1
  78. package/engine/st-render.mjs +8 -4
  79. package/engine/strategies.mjs +2 -235
  80. package/engine/subagent-tool-policy-core.mjs +7 -7
  81. package/engine/subagent-tool-policy.mjs +45 -20
  82. package/engine/tool-config-engine.mjs +53 -32
  83. package/engine/trigger-editor-meta.mjs +2 -21
  84. package/engine/trigger-spec.mjs +49 -133
  85. package/engine/world-book-tools.mjs +3 -6
  86. package/lib/client.js +10444 -10886
  87. package/lib/client.js.map +1 -1
  88. package/lib/index.d.mts +265 -361
  89. package/lib/index.mjs +1559 -2026
  90. package/lib/migrate-rules.d.mts +1 -0
  91. package/lib/migrate-rules.mjs +39 -0
  92. package/lib/module-package-CHPFweqK.mjs +2 -0
  93. package/lib/module-package-Cnd1_mwx.mjs +2872 -0
  94. package/lib/{paths-CY5psBqE.d.mts → paths-CyP0IkaM.d.mts} +388 -231
  95. package/lib/preset-transfer.d.mts +2 -2
  96. package/lib/preset-transfer.mjs +3 -2
  97. package/lib/{preset-package-BnJqrU4R.mjs → rules-migration-DJ6vASB5.mjs} +13825 -15283
  98. package/modules/ponytail/module.yml +406 -0
  99. package/modules/skill-surface/module.yml +74 -0
  100. package/modules/tool-surface/module.yml +67 -0
  101. package/package.json +50 -80
  102. package/templates/10-pre-step.yml +26 -22
  103. package/templates/14-first-turn-anchor.yml +25 -21
  104. package/templates/15-guide-auto.yml +34 -19
  105. package/templates/16-custom-fallback.yml +27 -15
  106. package/templates/18-placeholder-env-facts.yml +23 -14
  107. package/templates/20-system-section.yml +20 -11
  108. package/templates/30-runtime-context.yml +13 -7
  109. package/templates/40-agent-request.yml +11 -8
  110. package/templates/50-llm-stream.yml +14 -6
  111. package/templates/60-tool-pipeline.yml +15 -9
  112. package/templates/65-turn-stop.yml +19 -12
  113. package/templates/66-subagent-start.yml +12 -7
  114. package/templates/70-subagent-maintenance.yml +35 -29
  115. package/templates/75-subagent-end.yml +10 -5
  116. package/templates/80-tool-surface.yml +66 -0
  117. package/templates/policies/legacy-defaults.yml +34 -0
  118. package/templates/tools/50-delegate-worldbook.yml +1 -1
  119. package/engine/compositions/source/local/prompt-config-engine.yml +0 -7
  120. package/engine/prompt-config-engine.mjs +0 -104
  121. package/preset/pt-cordis/preset.yml +0 -43
  122. package/preset/pt-cordis/skills/cordis-composition-reference/SKILL.md +0 -29
  123. package/preset/pt-cordis/skills/cordis-composition-reference/references/packages.md +0 -501
  124. package/preset/pt-cordis/skills/cordis-plugin-development/SKILL.md +0 -38
  125. package/preset/pt-cordis/skills/cordis-plugin-development/references/host-plugin.md +0 -60
  126. package/preset/pt-cordis/skills/cordis-plugin-development/references/mcp-bundle.md +0 -5
  127. package/preset/pt-cordis/skills/cordis-plugin-development/references/ui-plugin.md +0 -13
  128. package/preset/pt-cordis/skills/cordis-plugin-development/references/verification.md +0 -5
  129. package/preset/pt-cordis/skills/cordis-plugin-development/templates/decoration/client.js +0 -22
  130. package/preset/pt-cordis/skills/cordis-plugin-development/templates/decoration/cordis.patch.yml +0 -3
  131. package/preset/pt-cordis/skills/cordis-plugin-development/templates/decoration/index.js +0 -2
  132. package/preset/pt-cordis/skills/cordis-plugin-development/templates/decoration/package.json +0 -15
  133. package/preset/pt-cordis/skills/cordis-plugin-development/templates/mcp/cordis.patch.yml +0 -8
  134. package/preset/pt-cordis/skills/cordis-plugin-development/templates/mcp/package.json +0 -7
  135. package/preset/pt-cordis/skills/editing-cordis-compositions/SKILL.md +0 -84
  136. package/preset/pt-custom/preset.yml +0 -15
  137. package/preset/pt-minimal/preset.yml +0 -27
  138. package/preset/pt-ptc/preset.yml +0 -45
  139. package/preset/pt-standard/preset.yml +0 -43
@@ -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
@@ -0,0 +1,66 @@
1
+ # 模板:工具面收窄(核心文件与任务集)+ 按需解锁
2
+ #
3
+ # 为什么:工具面实测 **156 个工具、描述合计 46894 字符(≈12K token)**,每个请求都付。
4
+ # 收窄到核心集后只剩约 10 个工具,其余按需解锁。
5
+ #
6
+ # 与 test/engine/declarations/tool-bootstrap.yml 的关键差别:那份原型**只在受控相位收窄**
7
+ # (`promoted: false`),晋升后原样放开;本模板**覆盖全部相位**——晋升后放开等于白省,
8
+ # 而工具描述是每请求的固定开销。若要旧语义,给 `phase` 加 `promoted: false` 并把
9
+ # `compacted` 拆成两条即可。
10
+ #
11
+ # 配套两件(缺一不可):
12
+ # 1. `dev_tool_search` 工具(组合源 engine/compositions/source/local/dev-tool-search.yml)
13
+ # ——唯一发现入口,模型靠它搜索并解锁。
14
+ # 2. `allowFrom`(engine/actions/assembly.mjs)——从历史 `tool/call` 参数回收解锁名单。
15
+ # 只挂插件不配 allowFrom 的话,解锁是**一次性的**(当次请求用完即被裁)。
16
+ #
17
+ # 工具名必须与**实际装配名**一致。本项目 harness 是 `pwsh`(不是 `bash`)、
18
+ # `edit` + `write`(不是 `str_replace_editor`)。写错名字有两个后果,都很隐蔽:
19
+ # - 写进 allow 的名字不存在 → `requireMatch` 触发 fail-open,**静默暴露完整目录**;
20
+ # - 该在的没写进去 → 该工具被裁掉,模型只能用别的方式硬凑。
21
+ #
22
+ # `requireMatch: true` 是刻意的:任一 allow 工具缺失(或模型解锁了一个不存在的名字)
23
+ # 就放弃裁剪、暴露完整目录。宁可多给上下文,也不静默裁成空目录——收窄错了会让当前
24
+ # 工作流调不到工具,那是比多花 token 严重得多的故障。
25
+ #
26
+ # **本模板走规则路径,不能声明 `waterfallPosition`**(那是声明 `triggers` 路径的字段,
27
+ # `compileRules` 会以 unknown fields 拒绝)。`assembly` 的改写发生在通道下游结算之后,
28
+ # 与相邻动作的先后由规则顺序与模块顺序决定。若确实需要 `outermost`(`prepend: true`,
29
+ # 保证本动作在普通注册之外先看到装配),改用声明路径(同 test/engine/declarations/
30
+ # tool-bootstrap.yml 的格式)而不是本模板。
31
+ id: tool-surface-resident
32
+ name: 工具面收窄(核心文件与任务集)
33
+ enabled: true
34
+ if:
35
+ # 覆盖全部相位。为什么不能只写 `phase: { promoteOn, includeSubagents }`:
36
+ # `promoted` 的缺省是 **true**(= 只匹配已晋升),不是「任意」;而 `compacted` 未声明才是
37
+ # 「不判该维度」(engine/conditions/phase.mjs:27-48)。更麻烦的是 `promoted: 'ignore'`
38
+ # 要求同时声明 `compacted`,而 `compacted` 只接受布尔值——**没有任何单节点组合能表达
39
+ # 「两个相位都命中」**,必须用 `any` 拼两支(phase.mjs:30-35 的注释正是在讲这个表达力边界)。
40
+ # 支 1 `promoted: true` → 已晋升(不论压缩与否)
41
+ # 支 2 `{compacted: true, promoted: false}` → 压缩后未晋升(受控相位的压缩回退)
42
+ # 未晋升且未压缩的**首轮不收窄**:与「首轮保全文」同一取舍——先让模型看到完整目录,
43
+ # 再随相位推进收窄。收窄的价值在于工具描述是**每请求固定开销**(实测 46894 字符),
44
+ # 而长会话必然进入上面两支,所以省下的正是大头。
45
+ any:
46
+ - phase: { promoteOn: either, includeSubagents: true, promoted: true }
47
+ - phase: { promoteOn: either, includeSubagents: true, compacted: true, promoted: false }
48
+ then:
49
+ - id: narrow-tools
50
+ kind: assembly
51
+ target:
52
+ tools:
53
+ allow:
54
+ - pwsh
55
+ - read
56
+ - write
57
+ - edit
58
+ - glob
59
+ - grep
60
+ - todo_write
61
+ - skill_search
62
+ - skill_load
63
+ - dev_tool_search
64
+ # 解锁项从 dev_tool_search 的持久调用参数回收({ tool, key } 精确匹配)。
65
+ allowFrom: { tool: dev_tool_search, key: toolNames }
66
+ requireMatch: true
@@ -0,0 +1,34 @@
1
+ #旧业务默认的精确数据快照,仅供模板生成和显式离线迁移读取。引擎运行时不得读取此文件。
2
+
3
+ version: 1
4
+ fillers:
5
+ envFacts:
6
+ text: |-
7
+ Environment facts:
8
+ {{ENV_FACTS}}
9
+ skillCatalog:
10
+ text: |-
11
+ Available skills ({{SKILL_COUNT}}):
12
+ {{SKILLS_TEXT}}
13
+ params:
14
+ limit: 20
15
+ fields: name,description
16
+ whenToUseLabel: 适用:
17
+ unnamedLabel: (unnamed)
18
+ instructionHint:
19
+ projectTemplate: "Reference documents exist: {{FILES}} (project root: {{ROOT}})."
20
+ globalTemplate: "A user reference document exists: {{FILES}}."
21
+ suffixTemplate: They are reference documents about the user's environment and
22
+ workspace conventions, not task instructions. Reading the relevant file
23
+ before workspace tasks is recommended, but consult them only when you need
24
+ those details; the task itself never depends on them.
25
+ messageTemplate: |-
26
+ <system-reminder>
27
+ Reference documents exist: {{FILES}}. {{SUFFIX}}
28
+ </system-reminder>
29
+ promotionGate:
30
+ reasoningPattern: \bwe\b
31
+ reasoningNegativePattern: \blet me\b
32
+ reasoningFlags: gi
33
+ customFallback:
34
+ fallbackAfter: 1
@@ -2,7 +2,7 @@
2
2
  # 保存该模板时自动装配 world-book-tools,原工具仍可用)。
3
3
  id: delegate-worldbook-list
4
4
  name: my_worldbook_list
5
- description: 查看当前预设的世界书条目(委托内置工具)
5
+ description: 查看当前模块的世界书条目(委托内置工具)
6
6
  output:
7
7
  schema:
8
8
  type: object
@@ -1,7 +0,0 @@
1
- # module: prompt-config-engine
2
- # source: engine/compositions/source/local/prompt-config-engine.yml (本地附加,非官方模块)
3
-
4
- - id: prompt-config-engine
5
- name: ./engine/prompt-config-engine.mjs
6
- config:
7
- configsDir: ../prompt-configs
@@ -1,104 +0,0 @@
1
- /**
2
- * prompt-config-engine — prompt-tool 的唯一提示词注入执行器(装配入口)。
3
- *
4
- * 本文件只做装配:
5
- * - schema.mjs 提示词配置加载/归一化/权威校验
6
- * - strategies.mjs 内置策略绑定 + 模板专属策略懒加载(strategyDir)
7
- * - fillers.mjs placeholder 动态填充器(instruction-hint / env-facts / skill-catalog)
8
- * - instruction-hint.mjs 通用指令文件提示实现(策略与 context-gate 共用)
9
- * - layers.mjs 非 pre-step 五个官方层级接线
10
- * - executor.mjs pre-step 消息批执行器(过滤/去重/合并/落位)
11
- *
12
- * agent.cordis.yml 引擎行:
13
- * - id: prompt-config-engine
14
- * name: ./engine/prompt-config-engine.mjs
15
- * config:
16
- * configsDir: ../prompt-configs # 提示词配置模块目录(相对本文件)
17
- * strategyDir: ../strategies # 模板专属策略目录(可选,相对本文件)
18
- *
19
- * 铁律:任一提示词配置失败只跳过该提示词配置并 warnOnce;配置错误挂载时 fail loud。
20
- */
21
-
22
- import { readFileSync } from 'node:fs'
23
- import { basename } from 'node:path'
24
- import { fileURLToPath } from 'node:url'
25
- import { createPromptConfigs, loadPromptConfigFiles, parsePromptConfigYaml } from './schema.mjs'
26
- import { applyPromptConfigs } from './executor.mjs'
27
- import { defineConfig, passthrough } from './fields.mjs'
28
-
29
- /** Cordis plugin name used by loader diagnostics. */
30
- export const name = 'prompt-config-engine'
31
-
32
- /**
33
- * 等待全部可注入层级的宿主服务。preset 行在 agent 组合内解析这些服务
34
- * (persona 依赖 systemPrompt,工具行依赖 tools,agent loop 依赖 llm)。
35
- */
36
- export const inject = ['systemPrompt', 'tools', 'llm']
37
-
38
- export { parsePromptConfigYaml, loadPromptConfigFiles, createPromptConfigs, applyPromptConfigs }
39
-
40
- /** 物化清单里是否仍挂着官方指令加载行(负责人冲突事实)。 */
41
- const OFFICIAL_INSTRUCTIONS_ROW = /dsh-agent-instructions|(^|\s)id:\s*agent-instructions\b/m
42
-
43
- /**
44
- * 本 mount 的装配事实:来源 id(协调器注册键,取预设目录名)+ 是否仍挂着官方
45
- * 指令行。协调器据此拒绝在官方负责人仍在时同时注入插件指令文件正文。
46
- * 引擎直接以源码方式被引用(无物化组合文件)时按未知处理,不声明冲突。
47
- */
48
- function compositionFacts(dirUrl) {
49
- try {
50
- const dir = new URL('..', dirUrl)
51
- return {
52
- sourceId: `preset:${basename(fileURLToPath(dir))}`,
53
- officialInstructions: OFFICIAL_INSTRUCTIONS_ROW.test(readFileSync(new URL('../agent.cordis.yml', dirUrl), 'utf8')),
54
- }
55
- } catch {
56
- return { sourceId: undefined, officialInstructions: false }
57
- }
58
- }
59
-
60
- /**
61
- * 引擎插件入口:config.configsDir 为提示词配置模块目录(相对本文件的 URL),
62
- * config.strategyDir 为模板专属策略目录(可选)。引擎扫描目录内每个
63
- * *.yml / *.yaml / *.json 并装配为提示词配置。
64
- */
65
- /**
66
- * 配置契约:白名单由字段声明派生(此前没有白名单,未知键被静默忽略)。
67
- * 三个键都刻意用 passthrough 保住既有语义——迁移前它们对**非字符串或空串**是静默取默认值
68
- * (`typeof x === 'string' && x.length > 0 ? x : 默认`),换成 text() 会把静默降级变成挂载期
69
- * 报错,那是 B2 未授权的行为变更。归一化结果与迁移前逐字段一致,唯一新增的是「未知键报错」。
70
- *
71
- * `presetRoot` 是可选的预设根基准(绝对 file URL):引擎由插件包提供、不再位于
72
- * `<预设根>/.engine/` 时,`templateFile` 的越界校验无法再从引擎位置推导,改由装配期注入。
73
- */
74
- export const configContract = defineConfig({
75
- configsDir: passthrough((value) => (typeof value === 'string' && value.length > 0 ? value : './prompt-configs')),
76
- strategyDir: passthrough((value) => (typeof value === 'string' && value.length > 0 ? value : undefined)),
77
- presetRoot: passthrough((value) => (typeof value === 'string' && value.length > 0 ? value : undefined)),
78
- })
79
-
80
- export function apply(ctx, config) {
81
- const { configsDir: dirName, strategyDir: rawStrategyDir, presetRoot: rawPresetRoot } = configContract.parse(config, name)
82
- const dirUrl = new URL(dirName.endsWith('/') ? dirName : `${dirName}/`, import.meta.url)
83
- // strategyDir 在入口统一解析成绝对 URL:bindResolver 用 `new URL(x.mjs, strategyDir)`
84
- // 懒加载,相对写法的 base 不是合法绝对 URL(ERR_INVALID_URL),会让整行挂载失败。
85
- const strategyDir = rawStrategyDir === undefined
86
- ? undefined
87
- : new URL(rawStrategyDir.endsWith('/') ? rawStrategyDir : `${rawStrategyDir}/`, import.meta.url).href
88
- // 预设根基准(可选):装配期注入绝对 file URL;缺省时由 schema 按「引擎上一级目录」推导。
89
- const templatePresetRoot = rawPresetRoot === undefined
90
- ? undefined
91
- : new URL(rawPresetRoot.endsWith('/') ? rawPresetRoot : `${rawPresetRoot}/`)
92
- const facts = compositionFacts(dirUrl)
93
- applyPromptConfigs(ctx, createPromptConfigs(loadPromptConfigFiles(dirUrl), {
94
- strategyDir,
95
- // 注入预设根时(引擎由插件包提供):相对 templateFile 仍按**历史引擎位置**
96
- // `<预设根>/.engine/` 解析,用户预设与提示词配置零改写;越界校验基准则是预设根本身。
97
- ...(templatePresetRoot === undefined
98
- ? {}
99
- : { templateBaseUrl: new URL('.engine/prompt-config-engine.mjs', templatePresetRoot), templatePresetRoot }),
100
- }), {
101
- prepend: true,
102
- ...facts,
103
- })
104
- }
@@ -1,43 +0,0 @@
1
- id: pt-cordis
2
- name: 创造模式
3
- description: 用于创建自定义 Agent preset:具备标准模式的全部能力,并提供运行时检查、持久化插件管理和 preset 创作指导。
4
- version: 1.0.0
5
- engineCompat: ">=0.4.2"
6
- modules:
7
- - agent-instructions
8
- - tool-bash
9
- - tool-pwsh
10
- - tool-fs
11
- - tool-fs-search
12
- - tool-jobs
13
- - command-goal
14
- - tool-goal
15
- - planning
16
- - compaction
17
- - delegation
18
- - tool-ask-user
19
- - tool-todo
20
- - tool-web
21
- - skill-filesystem-cordis
22
- - tool-skill
23
- - tool-present
24
- - tool-plugin-manager
25
- - prompt-config-engine
26
- persona:
27
- suffix: Your working directory is {{cwd}}.
28
- prefix: You are a coding agent powered by the {{model}} model.
29
- promptConfigs: []
30
- layerSettings:
31
- agent-request:
32
- modelProvider: ""
33
- modelName: ""
34
- modelReasoningEffort: ""
35
- modelTemperature: ""
36
- modelMaxTokens: ""
37
- subagent-start:
38
- subagentModelProvider: ""
39
- subagentModelName: ""
40
- subagentReasoningEffort: ""
41
- subagentTemperature: ""
42
- subagentMaxTokens: ""
43
- maxDepth: ""
@@ -1,29 +0,0 @@
1
- ---
2
- name: cordis-composition-reference
3
- description: Use when writing or reading a Cordis bundle patch or agent preset for this harness and you need the Loader YAML dialect (insert, override by id, group, disabled, isolate, !!js) or the list of installable Harness plugin packages and what each provides.
4
- ---
5
-
6
- # Cordis composition reference
7
-
8
- Reference material for bundle patches and preset plugin lists. Procedures live in `cordis-plugin-development` and `editing-cordis-compositions`.
9
-
10
- ## Loader patch dialect
11
-
12
- A profile composes an ordered list of patch layers over the bundle entry lists. Each patch is a mapping:
13
-
14
- - `insert: [rows]` appends rows; with an `id` naming an existing `group: true` row, the rows are appended inside that group's `config` list.
15
- - A patch with an `id` and no `insert` targets the existing row with that id. Supplied fields replace the row's fields; `config` is replaced wholesale, never deep-merged, so restate every field the row needs. A truthy `name` asserts the existing plugin name rather than renaming it.
16
- - Non-insert patches without a nonempty `id`, and targets that match no row, are warned about and skipped.
17
-
18
- A row has `id`, `name` (the plugin package specifier; inserted relative paths are anchored beside their patch file), optional `config`, and optional `disabled`, `inject`, `intercept`, and `isolate`.
19
-
20
- - `group: true` with `name: cordis:group` makes `config` a nested entry list and allows patches to insert into it by id. `cordis:include` loads a literal YAML or JSON entry list from `config.path`.
21
- - `disabled` accepts a boolean, null, or a `!!js` expression evaluated against the Loader context at every mount decision. A disabled row omits required `config` unless `group: true` forces activation.
22
- - `!!js` scalars are Loader expressions, never `!js`. Inside `config` they are evaluated after the row's declared injections activate, against that plugin's context (`ctx.<service>`), so `!!js dshHomePath('sessions')` and `!!js "!ctx.get('profileContext')"` are valid. Other row metadata stays literal.
23
- - `isolate` maps service names to `true` or a realm label; a preset plugin that provides a service isolates the provider and all consumers together. Scope controls contributions and event visibility; `isolate` controls service instances.
24
-
25
- `plugin_manager` `list_plugins` reports each row's `enabled` flag and `fiberPhase`; `set_plugin` and `set_bundle` answer `overridden` when a higher-priority layer wins.
26
-
27
- ## Installable plugin packages
28
-
29
- `references/packages.md` lists every workspace package that exports a Cordis plugin, grouped by package group, with whether its row takes `config`. Search it with `grep -n <keyword>` rather than reading it whole. Plugins outside this list come from installed bundles; `plugin_manager` `list_bundles` names them.