dsh-plugin-prompt-tool 0.7.2 → 0.8.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.
- package/README.md +185 -46
- package/engine/THIRD_PARTY_LICENSES +25 -0
- package/engine/actions.mjs +931 -0
- package/engine/anchor-match.mjs +6 -3
- package/engine/character-tools.mjs +11 -0
- package/engine/classify-task.mjs +18 -0
- package/engine/compaction-epoch.mjs +41 -20
- package/engine/compositions/library/agent-instructions.yml +9 -0
- package/engine/compositions/library/command-goal.yml +2 -6
- package/engine/compositions/library/compaction.yml +2 -32
- package/engine/compositions/library/delegation-ptc.yml +58 -0
- package/engine/compositions/library/delegation.yml +5 -38
- package/engine/compositions/library/persistent-shell.yml +4 -13
- package/engine/compositions/library/planning.yml +8 -23
- package/engine/compositions/library/skill-filesystem-cordis.yml +10 -0
- package/engine/compositions/library/skill-filesystem.yml +2 -8
- package/engine/compositions/library/tool-ask-user.yml +2 -3
- package/engine/compositions/library/tool-bash.yml +4 -12
- package/engine/compositions/library/tool-cordis.yml +7 -0
- package/engine/compositions/library/tool-fs-search.yml +2 -11
- package/engine/compositions/library/tool-fs.yml +2 -5
- package/engine/compositions/library/tool-goal.yml +2 -6
- package/engine/compositions/library/tool-jobs.yml +2 -18
- package/engine/compositions/library/tool-plugin-manager-disabled.yml +8 -0
- package/engine/compositions/library/tool-plugin-manager.yml +8 -0
- package/engine/compositions/library/tool-present.yml +7 -0
- package/engine/compositions/library/tool-presentation.yml +9 -0
- package/engine/compositions/library/tool-pwsh.yml +2 -6
- package/engine/compositions/library/tool-skill.yml +7 -0
- package/engine/compositions/library/tool-todo.yml +2 -4
- package/engine/compositions/library/tool-web.yml +2 -1
- package/engine/compositions/source/local/character-tools.yml +5 -0
- package/engine/compositions/source/local/declared-triggers.yml +12 -0
- package/engine/compositions/source/local/filesystem-editor.yml +30 -0
- package/engine/compositions/source/local/instruction-hint.yml +15 -0
- package/engine/compositions/{library/official-persistent-shell.yml → source/local/persistent-shell-posix.yml} +10 -8
- package/engine/compositions/source/local/prompt-config-engine.yml +3 -9
- package/engine/compositions/source/local/run-code-env.yml +4 -7
- package/engine/compositions/source/local/session-var-tools.yml +5 -0
- package/engine/compositions/source/local/skill-search.yml +3 -9
- package/engine/compositions/source/local/subagent-tool-policy.yml +21 -0
- package/engine/compositions/source/local/tool-bash-disabled.yml +9 -0
- package/engine/compositions/source/local/tool-config-engine.yml +8 -0
- package/engine/compositions/source/local/tool-git-bash.yml +15 -0
- package/engine/compositions/source/local/world-book-tools.yml +5 -0
- package/engine/condition.mjs +83 -0
- package/engine/declared-triggers.mjs +93 -0
- package/engine/executor.mjs +364 -185
- package/engine/fields.mjs +219 -0
- package/engine/fillers.mjs +12 -141
- package/engine/host-package.mjs +51 -0
- package/engine/instruction-hint.mjs +285 -0
- package/engine/interpolate.mjs +157 -29
- package/engine/layers.mjs +495 -75
- package/engine/predicates.mjs +753 -0
- package/engine/prompt-config-engine.mjs +63 -8
- package/engine/run-code-env.mjs +48 -31
- package/engine/schema.mjs +444 -103
- package/engine/sdk-strip.mjs +365 -0
- package/engine/session-var-tools.mjs +11 -0
- package/engine/session-vars.mjs +8 -6
- package/engine/shared.mjs +137 -0
- package/engine/skill-search.mjs +34 -21
- package/engine/st-macros.d.mts +22 -0
- package/engine/st-macros.mjs +208 -0
- package/engine/st-render.mjs +105 -0
- package/engine/st-world-book.d.mts +10 -0
- package/engine/st-world-book.mjs +259 -0
- package/engine/strategies.mjs +31 -20
- package/engine/subagent-tool-policy-core.mjs +400 -0
- package/engine/subagent-tool-policy.mjs +327 -0
- package/engine/tool-config-engine.mjs +207 -145
- package/engine/tool-definition.mjs +143 -0
- package/engine/{custom-bash.mjs → tool-git-bash.mjs} +38 -13
- package/engine/trigger-editor-meta.mjs +48 -0
- package/engine/trigger-spec.mjs +257 -0
- package/engine/trigger.mjs +304 -0
- package/engine/world-book-tools.mjs +11 -0
- package/lib/client.js +16495 -5456
- package/lib/client.js.map +1 -1
- package/lib/index.d.mts +628 -382
- package/lib/index.mjs +5391 -2942
- package/lib/paths-CY5psBqE.d.mts +1233 -0
- package/lib/preset-package-BnJqrU4R.mjs +16792 -0
- package/lib/preset-transfer.d.mts +2 -0
- package/lib/preset-transfer.mjs +2 -0
- package/package.json +91 -49
- package/preset/pt-cordis/preset.yml +43 -0
- package/preset/pt-cordis/skills/cordis-composition-reference/SKILL.md +29 -0
- package/preset/pt-cordis/skills/cordis-composition-reference/references/packages.md +501 -0
- package/preset/pt-cordis/skills/cordis-plugin-development/SKILL.md +38 -0
- package/preset/pt-cordis/skills/cordis-plugin-development/references/host-plugin.md +60 -0
- package/preset/pt-cordis/skills/cordis-plugin-development/references/mcp-bundle.md +5 -0
- package/preset/pt-cordis/skills/cordis-plugin-development/references/ui-plugin.md +13 -0
- package/preset/pt-cordis/skills/cordis-plugin-development/references/verification.md +5 -0
- package/preset/pt-cordis/skills/cordis-plugin-development/templates/decoration/client.js +22 -0
- package/preset/pt-cordis/skills/cordis-plugin-development/templates/decoration/cordis.patch.yml +3 -0
- package/preset/pt-cordis/skills/cordis-plugin-development/templates/decoration/index.js +2 -0
- package/preset/pt-cordis/skills/cordis-plugin-development/templates/decoration/package.json +15 -0
- package/preset/pt-cordis/skills/cordis-plugin-development/templates/mcp/cordis.patch.yml +8 -0
- package/preset/pt-cordis/skills/cordis-plugin-development/templates/mcp/package.json +7 -0
- package/preset/pt-cordis/skills/editing-cordis-compositions/SKILL.md +84 -0
- package/preset/pt-custom/preset.yml +15 -0
- package/preset/pt-minimal/preset.yml +27 -0
- package/preset/pt-ptc/preset.yml +45 -0
- package/preset/pt-standard/preset.yml +43 -0
- package/templates/14-first-turn-anchor.yml +4 -4
- package/templates/15-guide-auto.yml +3 -3
- package/templates/16-custom-fallback.yml +1 -0
- package/templates/18-placeholder-env-facts.yml +3 -3
- package/templates/20-system-section.yml +3 -2
- package/templates/65-turn-stop.yml +18 -0
- package/templates/66-subagent-start.yml +14 -0
- package/templates/75-subagent-end.yml +15 -0
- package/templates/tools/10-shell-command.yml +1 -1
- package/templates/tools/40-delegate-character.yml +1 -1
- package/templates/tools/50-delegate-worldbook.yml +1 -1
- package/templates/tools/60-delegate-session-var.yml +1 -1
- package/templates/tools/70-delegate-worldbook-upsert.yml +1 -1
- package/engine/anchor-turn.mjs +0 -68
- package/engine/code-presentation.mjs +0 -103
- package/engine/compositions/library/anchor-turn.yml +0 -10
- package/engine/compositions/library/bootstrap-filesystem.yml +0 -19
- package/engine/compositions/library/code-presentation.yml +0 -8
- package/engine/compositions/library/context-gate.yml +0 -39
- package/engine/compositions/library/cot-drip.yml +0 -11
- package/engine/compositions/library/custom-bash.yml +0 -14
- package/engine/compositions/library/deliberation-gate.yml +0 -11
- package/engine/compositions/library/official-agent-instructions.yml +0 -17
- package/engine/compositions/library/official-skill-filesystem-cordis.yml +0 -10
- package/engine/compositions/library/official-tool-bash.yml +0 -6
- package/engine/compositions/library/official-tool-cordis.yml +0 -13
- package/engine/compositions/library/official-tool-presentation.yml +0 -7
- package/engine/compositions/library/official-tool-skill.yml +0 -14
- package/engine/compositions/library/persona.yml +0 -13
- package/engine/compositions/library/prompt-config-engine.yml +0 -16
- package/engine/compositions/library/run-code-env.yml +0 -15
- package/engine/compositions/library/skill-search.yml +0 -14
- package/engine/compositions/library/str-replace-editor.yml +0 -10
- package/engine/compositions/library/tool-bootstrap.yml +0 -14
- package/engine/compositions/library/tool-config-engine.yml +0 -9
- package/engine/compositions/library/tool-filter.yml +0 -8
- package/engine/compositions/source/local/code-presentation.yml +0 -8
- package/engine/compositions/source/local/context-gate.yml +0 -36
- package/engine/compositions/source/local/custom-bash.yml +0 -11
- package/engine/compositions/source/local/str-replace-editor.yml +0 -10
- package/engine/compositions/source/local/tool-bootstrap.yml +0 -11
- package/engine/compositions/source/local/tool-filter.yml +0 -8
- package/engine/context-gate.mjs +0 -305
- package/engine/cot-drip.mjs +0 -137
- package/engine/deliberation-gate.mjs +0 -127
- package/engine/tool-bootstrap.mjs +0 -476
- package/engine/tool-filter.mjs +0 -80
- package/lib/preset-core.d.mts +0 -10
- package/lib/preset-core.mjs +0 -77
- package/lib/prompt-configs-BnQKRHVb.mjs +0 -884
- package/lib/prompt-configs-CN0sJTUL.d.mts +0 -193
- package/preset/anchored/preset.yml +0 -296
- package/preset/creative/preset.yml +0 -67
- package/preset/creative/skills/cordis-plugin-development/SKILL.md +0 -420
- package/preset/creative/skills/editing-cordis-compositions/SKILL.md +0 -165
- package/preset/custom/preset.yml +0 -12
- package/preset/liangshen/preset.yml +0 -75
- package/preset/minimal/preset.yml +0 -45
- package/preset/ptc/preset.yml +0 -58
- package/preset/standard/preset.yml +0 -57
- package/skills/manifest.json +0 -7
- package/skills/sandboxmod/SKILL.md +0 -49
- package/skills/web ui/SKILL.md +0 -42
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* 本文件只做装配:
|
|
5
5
|
* - schema.mjs 提示词配置加载/归一化/权威校验
|
|
6
6
|
* - strategies.mjs 内置策略绑定 + 模板专属策略懒加载(strategyDir)
|
|
7
|
-
* - fillers.mjs placeholder
|
|
7
|
+
* - fillers.mjs placeholder 动态填充器(instruction-hint / env-facts / skill-catalog)
|
|
8
|
+
* - instruction-hint.mjs 通用指令文件提示实现(策略与 context-gate 共用)
|
|
8
9
|
* - layers.mjs 非 pre-step 五个官方层级接线
|
|
9
10
|
* - executor.mjs pre-step 消息批执行器(过滤/去重/合并/落位)
|
|
10
11
|
*
|
|
@@ -18,8 +19,12 @@
|
|
|
18
19
|
* 铁律:任一提示词配置失败只跳过该提示词配置并 warnOnce;配置错误挂载时 fail loud。
|
|
19
20
|
*/
|
|
20
21
|
|
|
22
|
+
import { readFileSync } from 'node:fs'
|
|
23
|
+
import { basename } from 'node:path'
|
|
24
|
+
import { fileURLToPath } from 'node:url'
|
|
21
25
|
import { createPromptConfigs, loadPromptConfigFiles, parsePromptConfigYaml } from './schema.mjs'
|
|
22
26
|
import { applyPromptConfigs } from './executor.mjs'
|
|
27
|
+
import { defineConfig, passthrough } from './fields.mjs'
|
|
23
28
|
|
|
24
29
|
/** Cordis plugin name used by loader diagnostics. */
|
|
25
30
|
export const name = 'prompt-config-engine'
|
|
@@ -32,18 +37,68 @@ export const inject = ['systemPrompt', 'tools', 'llm']
|
|
|
32
37
|
|
|
33
38
|
export { parsePromptConfigYaml, loadPromptConfigFiles, createPromptConfigs, applyPromptConfigs }
|
|
34
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
|
+
|
|
35
60
|
/**
|
|
36
61
|
* 引擎插件入口:config.configsDir 为提示词配置模块目录(相对本文件的 URL),
|
|
37
62
|
* config.strategyDir 为模板专属策略目录(可选)。引擎扫描目录内每个
|
|
38
63
|
* *.yml / *.yaml / *.json 并装配为提示词配置。
|
|
39
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
|
+
|
|
40
80
|
export function apply(ctx, config) {
|
|
41
|
-
const dirName
|
|
42
|
-
? config.configsDir
|
|
43
|
-
: './prompt-configs'
|
|
81
|
+
const { configsDir: dirName, strategyDir: rawStrategyDir, presetRoot: rawPresetRoot } = configContract.parse(config, name)
|
|
44
82
|
const dirUrl = new URL(dirName.endsWith('/') ? dirName : `${dirName}/`, import.meta.url)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
+
})
|
|
49
104
|
}
|
package/engine/run-code-env.mjs
CHANGED
|
@@ -18,35 +18,14 @@
|
|
|
18
18
|
* native 模式自动空转。
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
import {
|
|
21
|
+
import { bool, defineConfig, stringList } from './fields.mjs'
|
|
22
22
|
|
|
23
23
|
/** Cordis 插件名,供 loader 诊断使用。 */
|
|
24
24
|
export const name = 'run-code-env'
|
|
25
25
|
|
|
26
|
-
/** Every config key this plugin accepts — anything else is a typo. */
|
|
27
|
-
const ALLOWED_KEYS = new Set(['enabled', 'envKeys'])
|
|
28
|
-
|
|
29
26
|
/** 需要 tools 视图与 systemPrompt 段。shellEnv 为机会型读取,不写进 inject。 */
|
|
30
27
|
export const inject = ['tools', 'systemPrompt']
|
|
31
28
|
|
|
32
|
-
/** 默认暴露的系统环境变量(无凭据形态)。 */
|
|
33
|
-
export const DEFAULT_ENV_KEYS = [
|
|
34
|
-
'PATH',
|
|
35
|
-
'PATHEXT',
|
|
36
|
-
'HOME',
|
|
37
|
-
'USERPROFILE',
|
|
38
|
-
'USERNAME',
|
|
39
|
-
'COMPUTERNAME',
|
|
40
|
-
'OS',
|
|
41
|
-
'TEMP',
|
|
42
|
-
'TMP',
|
|
43
|
-
'SystemRoot',
|
|
44
|
-
'ProgramFiles',
|
|
45
|
-
'ProgramFiles(x86)',
|
|
46
|
-
'LOCALAPPDATA',
|
|
47
|
-
'APPDATA',
|
|
48
|
-
]
|
|
49
|
-
|
|
50
29
|
/** 任何疑似凭据的名字一律不放行。 */
|
|
51
30
|
export const SENSITIVE_ENV_RE = /KEY|PASSWORD|SECRET|TOKEN/i
|
|
52
31
|
|
|
@@ -54,15 +33,52 @@ export const SENSITIVE_ENV_RE = /KEY|PASSWORD|SECRET|TOKEN/i
|
|
|
54
33
|
const PATCHED = new WeakSet()
|
|
55
34
|
|
|
56
35
|
/**
|
|
57
|
-
*
|
|
36
|
+
* envKeys 字段:非空字符串数组,逐项 trim 后去重。
|
|
37
|
+
* 两条消息与迁移前逐字一致:空数组/缺键 → 消息 A(白名单缺失),trim 后为空 → 消息 B。
|
|
38
|
+
* `allowEmpty: false` 是显式取值——迁移前 `!Array.isArray(value) || value.length === 0`
|
|
39
|
+
* 一律抛消息 A,空数组不得通过。
|
|
40
|
+
*/
|
|
41
|
+
const ENV_KEYS = stringList({
|
|
42
|
+
required: true,
|
|
43
|
+
trim: true,
|
|
44
|
+
dedupe: true,
|
|
45
|
+
allowEmpty: false,
|
|
46
|
+
message: `${name}: envKeys must be a non-empty array of env var names — 白名单归模板/预设,请在本预设或组合源提供`,
|
|
47
|
+
emptyMessage: `${name}: envKeys must contain at least one non-empty env var name`,
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* envKeys 声明的 parse 包一层「非字符串项降级为空串」:迁移前的 normalizeEnvKeys 对
|
|
52
|
+
* `[1, 'PATH']` 是**宽容**的(数字映射成空串后过滤掉,返回 ['PATH']),而 stringList 默认
|
|
53
|
+
* 对非字符串项 fail loud。B2 硬约束是「除 enabled 外逐字段结果与消息逐字一致」,故保留旧语义。
|
|
54
|
+
*/
|
|
55
|
+
const envKeysField = {
|
|
56
|
+
kind: 'stringList',
|
|
57
|
+
parse: (value, plugin, field) => ENV_KEYS.parse(
|
|
58
|
+
Array.isArray(value) ? value.map((item) => (typeof item === 'string' ? item : '')) : value,
|
|
59
|
+
plugin,
|
|
60
|
+
field,
|
|
61
|
+
),
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* 配置契约:字段声明是白名单与逐字段归一化的单一来源(导出供契约对拍测试使用)。
|
|
66
|
+
* `enabled` 走 fail loud 的布尔开关:未声明 = 关闭(组合源 run-code-env.yml 显式 enabled: true),
|
|
67
|
+
* 非布尔在挂载期抛 `enabled must be a boolean`。
|
|
68
|
+
*/
|
|
69
|
+
export const configContract = defineConfig({
|
|
70
|
+
enabled: bool({ default: false }),
|
|
71
|
+
envKeys: envKeysField,
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* 校验 envKeys:非空字符串数组;缺失或全空一律 fail loud——暴露哪些变量
|
|
76
|
+
* 归组合源 / 预设(见 engine/compositions/source/local/run-code-env.yml)。
|
|
58
77
|
* 单个键为敏感名时在 buildEnv 阶段过滤,这里只校验形状。
|
|
78
|
+
* 导出供测试直接调用;归一化规则归 configContract 的 envKeys 字段(此处不重复实现)。
|
|
59
79
|
*/
|
|
60
80
|
export function normalizeEnvKeys(value) {
|
|
61
|
-
|
|
62
|
-
if (!Array.isArray(value) || value.length === 0) return [...DEFAULT_ENV_KEYS]
|
|
63
|
-
const keys = value.map((key) => (typeof key === 'string' ? key.trim() : ''))
|
|
64
|
-
.filter((key) => key.length > 0)
|
|
65
|
-
return keys.length > 0 ? [...new Set(keys)] : [...DEFAULT_ENV_KEYS]
|
|
81
|
+
return envKeysField.parse(value, name, 'envKeys')
|
|
66
82
|
}
|
|
67
83
|
|
|
68
84
|
/**
|
|
@@ -171,9 +187,10 @@ export function patchRunCodeTool(tool, ctx, keys) {
|
|
|
171
187
|
|
|
172
188
|
/** 注册 PTC env 注入:只在目标 scope 出现 run_code 时生效。 */
|
|
173
189
|
export function apply(ctx, config) {
|
|
174
|
-
|
|
175
|
-
const
|
|
176
|
-
|
|
190
|
+
// 校验入口:未知键 / enabled 非布尔 / envKeys 缺失或全空都在挂载期 fail loud。
|
|
191
|
+
const source = configContract.parse(config, name)
|
|
192
|
+
// 开关语义:未声明 = 关闭(组合源为本模块显式写 enabled: true)。
|
|
193
|
+
const { enabled, envKeys: keys } = source
|
|
177
194
|
|
|
178
195
|
const tryPatch = (scope) => {
|
|
179
196
|
if (!enabled) return
|