dsh-plugin-prompt-tool 1.0.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/README.md +38 -29
  2. package/engine/actions/append-context.mjs +49 -0
  3. package/engine/actions/assembly.mjs +150 -0
  4. package/engine/actions/catalog.mjs +92 -0
  5. package/engine/actions/content.mjs +205 -0
  6. package/engine/actions/decision.mjs +54 -0
  7. package/engine/actions/examples.mjs +11 -0
  8. package/engine/actions/guard.mjs +80 -0
  9. package/engine/actions/inbox-prepend.mjs +37 -0
  10. package/engine/actions/index.mjs +100 -0
  11. package/engine/actions/inject-text.mjs +22 -0
  12. package/engine/actions/pre-step-filter.mjs +55 -0
  13. package/engine/actions/registration.mjs +168 -0
  14. package/engine/actions/request-params.mjs +32 -0
  15. package/engine/actions/sdk-strip.mjs +30 -0
  16. package/engine/actions/shared.mjs +71 -0
  17. package/engine/actions.mjs +2 -931
  18. package/engine/branch.mjs +44 -0
  19. package/engine/compaction-epoch.mjs +31 -13
  20. package/engine/compositions/source/local/dev-tool-search.yml +11 -0
  21. package/engine/compositions/source/local/instruction-hint.yml +22 -1
  22. package/engine/compositions/source/local/rule-engine.yml +6 -0
  23. package/engine/condition.mjs +16 -3
  24. package/engine/conditions/anchor.mjs +32 -0
  25. package/engine/conditions/availability.mjs +47 -0
  26. package/engine/conditions/composite.mjs +83 -0
  27. package/engine/conditions/count.mjs +140 -0
  28. package/engine/conditions/evaluation.mjs +41 -0
  29. package/engine/conditions/examples.mjs +11 -0
  30. package/engine/conditions/index.mjs +85 -0
  31. package/engine/conditions/names.mjs +21 -0
  32. package/engine/conditions/phase.mjs +54 -0
  33. package/engine/conditions/preset.mjs +94 -0
  34. package/engine/conditions/scope.mjs +18 -0
  35. package/engine/conditions/session.mjs +22 -0
  36. package/engine/conditions/source.mjs +63 -0
  37. package/engine/conditions/subject.mjs +121 -0
  38. package/engine/conditions/text.mjs +44 -0
  39. package/engine/conditions/values.mjs +32 -0
  40. package/engine/dev-tool-search.mjs +213 -0
  41. package/engine/executor.mjs +55 -6
  42. package/engine/fillers.mjs +23 -16
  43. package/engine/instruction-hint.mjs +34 -22
  44. package/engine/layers.mjs +135 -49
  45. package/engine/order.mjs +4 -1
  46. package/engine/predicates.mjs +2 -753
  47. package/engine/rule-engine.mjs +40 -0
  48. package/engine/rule-runtime.mjs +110 -0
  49. package/engine/rule-spec.mjs +187 -0
  50. package/engine/schema.mjs +16 -5
  51. package/engine/shared.mjs +1 -1
  52. package/engine/strategies.mjs +2 -235
  53. package/engine/subagent-tool-policy-core.mjs +7 -7
  54. package/engine/subagent-tool-policy.mjs +20 -10
  55. package/engine/tool-config-engine.mjs +53 -32
  56. package/engine/trigger-editor-meta.mjs +2 -21
  57. package/engine/trigger-spec.mjs +49 -133
  58. package/lib/client.js +10446 -10820
  59. package/lib/client.js.map +1 -1
  60. package/lib/index.d.mts +82 -139
  61. package/lib/index.mjs +826 -1087
  62. package/lib/migrate-rules.d.mts +1 -0
  63. package/lib/migrate-rules.mjs +39 -0
  64. package/lib/module-package-CHPFweqK.mjs +2 -0
  65. package/lib/module-package-Cnd1_mwx.mjs +2872 -0
  66. package/lib/{paths-BgL42sSM.d.mts → paths-CyP0IkaM.d.mts} +223 -108
  67. package/lib/preset-transfer.d.mts +2 -2
  68. package/lib/preset-transfer.mjs +3 -2
  69. package/lib/{module-package-Cm3fHHlp.mjs → rules-migration-DJ6vASB5.mjs} +13696 -15557
  70. package/modules/ponytail/module.yml +381 -147
  71. package/modules/skill-surface/module.yml +74 -0
  72. package/modules/tool-surface/module.yml +67 -0
  73. package/package.json +5 -1
  74. package/templates/10-pre-step.yml +26 -22
  75. package/templates/14-first-turn-anchor.yml +25 -21
  76. package/templates/15-guide-auto.yml +34 -19
  77. package/templates/16-custom-fallback.yml +27 -15
  78. package/templates/18-placeholder-env-facts.yml +23 -14
  79. package/templates/20-system-section.yml +16 -10
  80. package/templates/30-runtime-context.yml +13 -7
  81. package/templates/40-agent-request.yml +11 -8
  82. package/templates/50-llm-stream.yml +14 -6
  83. package/templates/60-tool-pipeline.yml +15 -9
  84. package/templates/65-turn-stop.yml +19 -12
  85. package/templates/66-subagent-start.yml +12 -7
  86. package/templates/70-subagent-maintenance.yml +35 -29
  87. package/templates/75-subagent-end.yml +10 -5
  88. package/templates/80-tool-surface.yml +66 -0
  89. package/templates/policies/legacy-defaults.yml +34 -0
  90. package/engine/compositions/source/local/prompt-config-engine.yml +0 -7
  91. package/engine/prompt-config-engine.mjs +0 -104
  92. package/modules/ponytail/configs/0000-ponytail-rules.yml +0 -102
  93. package/modules/ponytail/configs/0010-ponytail-level-full.yml +0 -19
  94. package/modules/ponytail/configs/0020-ponytail-level-lite.yml +0 -19
  95. package/modules/ponytail/configs/0030-ponytail-level-ultra.yml +0 -19
package/lib/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as AssetFile, A as resolveModuleFacts, B as MAX_BRIDGE_BODY_BYTES, C as loadModuleSpec, D as removeUserPreset, E as removePresetModule, F as BRIDGE_ENDPOINTS, G as SkillInvocation, H as SETTINGS_BRIDGE_PREFIX, I as BridgeEndpoint, J as SkillSourceKind, K as SkillPolicyChange, L as BridgeErrorPayload, M as saveModuleParams, N as savePresetPersona, O as renderComposition, P as userModulesDir, Q as scopeOfInvocation, R as BridgeRequestMap, S as listModules, T as removeEngineCapabilityFromPreset, U as SkillCatalogEntry, V as MAX_CHARACTER_CARD_STREAM_BYTES, W as SkillContentSnapshot, X as SkillsState, Y as SkillsCatalogSnapshot, Z as invocationForScope, _ as buildModuleConfigsFromParams, a as installPresetPackage, at as MAX_INSTRUCTION_FILE_BYTES, b as ensurePresetSeed, c as convertStToPreset, ct as EngineCapability, d as stPresetId, dt as engineCapability, et as ImportChoices, f as EngineCapabilityCreateRequest, ft as engineRecipe, g as applyModuleConfigs, h as ModuleSpec, i as exportPresetPackage, it as InstructionFileStatus, j as resolvePresetParams, k as resolveModuleDir, l as mergeStPresets, lt as ModuleFacts, m as EngineCapabilityRemoveResult, mt as validateCustomToolIdentities, n as USER_SKILLS_DIR, nt as InstructionContextView, o as presetImportPreview, ot as ENGINE_CAPABILITIES, p as EngineCapabilityCreateResult, pt as isEngineCapabilityPresent, q as SkillPolicyScope, r as expandPresetSource, rt as InstructionFileSnapshot, s as StConversionOptions, st as ENGINE_RECIPES, tt as INSTRUCTION_FILE_STATUSES, u as processStText, ut as ModuleSourceMode, v as cloneBuiltinPreset, w as moduleDirExists, x as listBuiltinTemplates, y as createEngineCapabilityInPreset, z as BridgeValueMap } from "./paths-BgL42sSM.mjs";
1
+ import { $ as SkillSourceKind, A as removeUserModule, B as BridgeEndpoint, C as ensureModuleSeed, Ct as moduleCapability, D as moduleDirExists, E as loadModuleSpec, F as saveModuleParams, G as MAX_CHARACTER_CARD_STREAM_BYTES, H as BridgeRequestMap, I as saveModulePersona, J as SkillCatalogEntry, K as ModuleSummary, L as userModulesDir, M as resolveModuleDir, N as resolveModuleFacts, O as removeModuleCapability, P as resolveModuleParams, Q as SkillPolicyScope, R as withModuleDefinition, S as createModuleCapability, St as isModuleCapabilityPresent, T as listModules, U as BridgeValueMap, V as BridgeErrorPayload, W as MAX_BRIDGE_BODY_BYTES, X as SkillInvocation, Y as SkillContentSnapshot, Z as SkillPolicyChange, _ as ModuleSpec, _t as MODULE_CAPABILITIES, a as installModulePackage, at as ImportChoices, b as buildModuleConfigsFromParams, bt as ModuleSourceMode, c as convertStToModule, ct as RuleDefinition, d as mergeStModulesWithReport, dt as InstructionFileSnapshot, et as SkillsCatalogSnapshot, f as processStText, ft as InstructionFileStatus, g as ModuleCapabilityRemoveResult, gt as InjectionPoint, h as ModuleCapabilityCreateResult, ht as INJECTION_POINT_ORDER, i as exportModulePackage, it as AssetFile, j as renderComposition, k as removeModuleCapabilityDeclaration, l as convertStToModuleWithReport, lt as INSTRUCTION_FILE_STATUSES, m as ModuleCapabilityCreateRequest, mt as ENGINE_RECIPES, n as USER_SKILLS_DIR, nt as invocationForScope, o as moduleImportPreview, ot as ModuleExportRequest, p as stModuleId, pt as MAX_INSTRUCTION_FILE_BYTES, q as SETTINGS_BRIDGE_PREFIX, r as expandModuleSource, rt as scopeOfInvocation, s as StConversionOptions, st as ModuleExportResult, tt as SkillsState, u as mergeStModules, ut as InstructionContextView, v as appendModuleCapabilities, vt as ModuleCapability, w as listBuiltinTemplates, wt as validateCustomToolIdentities, x as cloneBuiltinModule, xt as engineRecipe, y as applyModuleConfigs, yt as ModuleFacts, z as BRIDGE_ENDPOINTS } from "./paths-CyP0IkaM.mjs";
2
2
  import { parseDocument } from "yaml";
3
3
  import z from "@deepseek-ai/schemastery";
4
4
  import { ToolExecution } from "@deepseek-ai/dsh-tools";
@@ -11,18 +11,21 @@ declare const PARAM_KEYS: ReadonlySet<string>;
11
11
  //#endregion
12
12
  //#region src/config.d.ts
13
13
  interface Config {
14
- /** 模块运行总闸;保留既有持久键,关闭只撤回运行贡献。 */
15
- writePreset: Volatile<boolean>;
14
+ modulesEnabled: Volatile<boolean | undefined>;
15
+ /** 已部署配置的输入兼容;只在读取与显式保存边界归一。 */
16
+ writePreset?: Volatile<boolean | undefined>;
16
17
  }
17
18
  declare const Config: z<Schemastery.ObjectS<NoInfer<{
18
- writePreset: z<boolean, boolean, "volatile-defined">;
19
+ modulesEnabled: z<boolean, boolean, "volatile">;
20
+ writePreset: z<boolean, boolean, "volatile">;
19
21
  }>>, Schemastery.ObjectT<NoInfer<{
20
- writePreset: z<boolean, boolean, "volatile-defined">;
22
+ modulesEnabled: z<boolean, boolean, "volatile">;
23
+ writePreset: z<boolean, boolean, "volatile">;
21
24
  }>>, "plain">;
22
25
  interface PromptSettings {
23
26
  /** 运行时检测:是否检测到任何模型服务商(不写入 settings)。 */
24
27
  modelsAvailable: boolean;
25
- writePreset: boolean;
28
+ modulesEnabled: boolean;
26
29
  }
27
30
  //#endregion
28
31
  //#region src/shared/legacy-prompt-params.d.ts
@@ -125,11 +128,11 @@ interface EngineParams {
125
128
  }
126
129
  type EngineParamKey = keyof EngineParams;
127
130
  /**
128
- * writePreset.runtimeOf 实际透传进运行时 params 的引擎参数子集。
129
- * RuntimeOptions(装配态)与 WritePresetOptions(写入态)都从这里派生,
130
- * 防止「加参数只改一处、writePreset 忘透传」的静默漂移(如 stageAdvanceDescription 历史事故)。
131
+ * writeModule 实际透传进运行时 params 的引擎参数子集。
132
+ * RuntimeOptions(装配态)与 WriteModuleOptions(写入态)都从这里派生,
133
+ * 防止「加参数只改一处、模块写者忘透传」的静默漂移(如 stageAdvanceDescription 历史事故)。
131
134
  */
132
- type PresetWriterParams = Partial<EngineParams & LegacyPromptParams>;
135
+ type ModuleWriterParams = Partial<EngineParams & LegacyPromptParams>;
133
136
  /**
134
137
  * 数值型引擎参数保存前校验(与 write-preset.modelRequestConfigs 消费规则同源)。
135
138
  * 保存层响亮失败(400 逐字段错误),渲染层保持宽容(never-brick):
@@ -148,8 +151,8 @@ interface EngineParamValueError {
148
151
  message: string;
149
152
  }
150
153
  declare const ENGINE_PARAM_KEYS: EngineParamKey[];
151
- /** writePreset.runtimeOf 实际透传键:全部引擎参数可直接进入 writer。 */
152
- declare const WRITER_PARAM_KEYS: ("firstTurnAnchor" | "firstTurnText" | "firstTurnCustom" | "guideText" | "guideCustom" | "guideEnabled" | "injectPrompt" | "firstTurnWord" | "buildPattern" | "complexPattern" | "firstTurnBuild" | "firstTurnInspect" | "firstTurnDeep" | "guideWeak" | "guideDeep" | keyof EngineParams)[];
154
+ /** writeModule 实际透传键:全部引擎参数可直接进入 writer。 */
155
+ declare const WRITER_PARAM_KEYS: (keyof EngineParams | "firstTurnAnchor" | "firstTurnText" | "firstTurnCustom" | "guideText" | "guideCustom" | "guideEnabled" | "injectPrompt" | "firstTurnWord" | "buildPattern" | "complexPattern" | "firstTurnBuild" | "firstTurnInspect" | "firstTurnDeep" | "guideWeak" | "guideDeep")[];
153
156
  /**
154
157
  * 校验参数键值(键集合合法性由调用方白名单先行校验,本函数同样拒绝未知键)。
155
158
  * 返回逐字段错误;空数组 = 通过。类型收窄:布尔/字符串/数值/列表各按 canonical
@@ -229,12 +232,6 @@ interface PromptConfigSpec {
229
232
  declare function assertSafeConfigId(id: string): void;
230
233
  /** 生成文件名统一 4 位零填充前缀(0000-…),超过 10 条后字典序仍稳定。 */
231
234
  declare function configFileName(index: number, id: string): string;
232
- interface PromptConfigFile {
233
- /** 模块文件夹内文件名(数字前缀决定引擎执行顺序)。 */
234
- file: string;
235
- /** yml 文件内容。 */
236
- content: string;
237
- }
238
235
  /**
239
236
  * 条件判定的键集合:与 `engine/anchor-match.mjs` 的匹配语义同构。
240
237
  * 键按字面文本匹配(正则元字符会被转义);要写正则须用 `/pattern/flags` 形态或 `useRegex: true`。
@@ -249,31 +246,38 @@ interface PromptConfigMatch {
249
246
  }
250
247
  //#endregion
251
248
  //#region src/host/write-preset.d.ts
252
- /**
253
- * 把任意单一参数模块模板物化到生成目录(writePreset)的写入态选项。
254
- * 引擎参数契约来自 shared/engine-params.ts(PresetWriterParams:runtimeOf 透传子集),
255
- * 此处只保留 writePreset 专属字段——加引擎参数只需改一处契约,漏透传变成编译错误。
256
- */
257
- interface WritePresetOptions extends PresetWriterParams {
258
- /** AGENTS.md 内容资产(写生成目录 agents.md):常驻层写盘的唯一来源,不再注入提示词。 */
249
+ interface WriteModuleOptions {
250
+ modulesRoot: string;
251
+ moduleId: string;
252
+ targetModuleId?: string;
253
+ sourceDir?: string;
254
+ /** 返回独立暂存根下的合法模块目录;安装方负责交换与清理暂存根。 */
255
+ stageOnly?: boolean;
259
256
  agentsInstructionText?: string;
257
+ warn?: (message: string) => void;
258
+ }
259
+ /** 旧入口只做名称适配;行为规则和参数必须已写入完整定义。 */
260
+ interface WritePresetOptions extends ModuleWriterParams {
260
261
  moduleDir: string;
261
- /** @deprecated 模块排序归模块定义;该旧输入已不再覆盖顶层 order。 */
262
- presetOrder?: number;
263
- /** settings 层用户自定义提示词配置(优先级最高)。 */
264
- promptConfigs: PromptConfigSpec[];
265
- /** 当前模块目录名;默认 pt-standard。 */
266
262
  presetTemplate?: string;
267
- /** 输出目录/模块 id 覆盖;缺省 = presetTemplate 同名输出。 */
268
263
  outputId?: string;
269
- /** 隔离的定义/资源来源;与最终 outputId 分离,不回退同名已安装模块。 */
270
264
  sourceDir?: string;
271
- /** 只生成并返回暂存目录;调用方负责安装或清理,不更新共享引擎及目标目录。 */
272
265
  materializeOnly?: boolean;
273
- /** 目录加载失败等非致命告警回调。 */
266
+ agentsInstructionText?: string;
267
+ presetOrder?: number;
268
+ promptConfigs?: PromptConfigSpec[];
274
269
  warn?: (message: string) => void;
275
270
  }
276
- /** 把任意单一参数模块模板物化到生成目录;全部失败 fail loud。 */
271
+ /** 按模块身份原地恢复切片;用户资产、正文与完整定义均不重写。 */
272
+ declare function ensureModuleReady(id: string, options: {
273
+ modulesRoot?: string;
274
+ moduleDir?: string;
275
+ presetOrder?: number;
276
+ warn?: (message: string) => void;
277
+ }): string;
278
+ /** 已有同一模块只恢复切片;导入/复制先完整生成合法身份候选,再交换目标。 */
279
+ declare function writeModule(prompt: string, options: WriteModuleOptions): string;
280
+ /** @deprecated 使用 writeModule;旧字段仅在此边界适配。 */
277
281
  declare function writePreset(prompt: string, options: WritePresetOptions): string;
278
282
  //#endregion
279
283
  //#region src/host/agents-cards.d.ts
@@ -372,6 +376,8 @@ interface PreStepPromptConfig {
372
376
  }
373
377
  interface PreStepSource {
374
378
  configs: readonly PreStepPromptConfig[];
379
+ /** 已编译的本地点规则动作;执行与配置叶子共享同一批次资格帧。 */
380
+ ruleActions?: readonly unknown[];
375
381
  officialInstructions?: boolean;
376
382
  }
377
383
  interface PreStepCoordinatorOptions {
@@ -509,9 +515,9 @@ interface SkillsBridgeState {
509
515
  * 生成目录里属于其他工作区的文件卡不再展示(写盘白名单也不含它们);
510
516
  * 当前工作区里没有对应生成卡的文件按默认文件卡补齐。
511
517
  */
512
- declare function mergeInstructionCards(presetCards: readonly unknown[], files: readonly InstructionFileSnapshot[]): unknown[];
518
+ declare function mergeInstructionCards(moduleCards: readonly unknown[], files: readonly InstructionFileSnapshot[]): unknown[];
513
519
  /** 自建 loopback settings bridge:替代 registerConfigurableProviders,避免模型设置区出现插件条目。 */
514
- declare function registerSettingsBridge(ctx: Context, ns: string, getModelsState: () => ModelDetection, getSkillsState: () => SkillsBridgeState, getEngineStrategyDir: () => string, afterSkillsChange?: () => void,
520
+ declare function registerSettingsBridge(ctx: Context, ns: string, getModelsState: () => ModelDetection, getSkillsState: () => SkillsBridgeState, _getEngineStrategyDir: () => string, afterSkillsChange?: () => void,
515
521
  /**
516
522
  * 生成目录(模块目录):读取/写入哪一份提示词配置。
517
523
  *
@@ -519,20 +525,28 @@ declare function registerSettingsBridge(ctx: Context, ns: string, getModelsState
519
525
  * 没给则由 host 回退启用表首项。编辑器因此不必依赖某个全局单选——配置卡自己的
520
526
  * 模块身份决定写哪里。
521
527
  */
522
- getPresetConfigsDir?: (moduleId?: string) => string,
528
+ getModuleDirectory?: (moduleId?: string) => string,
523
529
  /** 内容导入完成回调:批量 scope 只触发一次重建(更新运行时文本并重建模块)。 */
524
- afterPresetImport?: (scopes: Array<'preset' | 'agents'>, moduleId?: string) => void | Promise<void>,
530
+ afterModuleContentImport?: (scopes: Array<'preset' | 'agents'>, moduleId?: string) => void | Promise<void>,
525
531
  /** 参数写入后重建指定模块;省略身份表示启用表变化,刷新全部运行实例。 */
526
532
  afterOverridesChange?: (moduleId?: string) => void | Promise<void>,
527
533
  /** 模块已完整安装后的刷新回调;失败返回未生效诊断,不再物化或撤销安装。 */
528
- afterPresetPackageImport?: (id: string) => void | Promise<void>,
529
- /** 能力/recipe 原子创建后重建回调;抛错时调用方恢复 preset.yml。 */
534
+ afterModulePackageImport?: (id: string) => void | Promise<void>,
535
+ /** 能力/recipe 提交后刷新回调;失败保留已提交定义并明确报告。 */
530
536
  afterCapabilityChange?: (moduleId?: string) => void | Promise<void>,
531
537
  /** 新建、复制或删除模块后重建当前模块。 */
532
- afterPresetListChange?: (id: string) => void | Promise<void>): {
538
+ afterModuleListChange?: (id: string) => void | Promise<void>): {
533
539
  invalidateDescriptor: () => void;
534
540
  };
535
541
  //#endregion
542
+ //#region src/host/module-layer-settings.d.ts
543
+ declare class ModuleLayerSettingsError extends Error {
544
+ readonly code = "module-layer-settings-invalid";
545
+ constructor(message: string);
546
+ }
547
+ /** 仅消费当前 layerSettings;其余段作为未知字段留存,不投影为运行时参数。 */
548
+ declare function readModuleLayerSettings(source: unknown): Record<string, unknown>;
549
+ //#endregion
536
550
  //#region src/host/worldbook.d.ts
537
551
  type WorldBookEntry = Record<string, unknown>;
538
552
  /** buildWorldBookEntry 输入(两通道共用:ST 导入转换与模型 world_book_upsert 工具)。 */
@@ -597,32 +611,6 @@ type SkillsImportResult = {
597
611
  /** 浏览器上传:base64 文件列表;单技能包(无顶层目录)按 frontmatter.name 归类。 */
598
612
  declare function importSkillsPackage(root: string, files: SkillsImportFile[], overwrite?: readonly string[]): SkillsImportResult;
599
613
  //#endregion
600
- //#region src/runtime/configs-validate.d.ts
601
- interface PromptConfigValidationError {
602
- /** 数组下标;结构层整组错误为 -1。 */
603
- index: number;
604
- /** 该条配置的 id(缺失或非字符串时为空串)。 */
605
- id: string;
606
- /** 引擎或结构层错误消息(保留 configs[i] 前缀)。 */
607
- message: string;
608
- }
609
- interface PromptConfigValidationResult {
610
- valid: boolean;
611
- errors: PromptConfigValidationError[];
612
- /** valid=true 时回显归一化前的输入数组(调用方预览用)。 */
613
- configs?: PromptConfigSpec[];
614
- /** valid=true 时逐条渲染的 yml 模块预览(与生成目录同构)。 */
615
- files?: PromptConfigFile[];
616
- }
617
- /**
618
- * 逐条调用引擎权威校验并渲染预览文件。
619
- * 逐条(而非整组一次)校验保证一条坏配置不吞掉其余错误,且 index 可直接映射。
620
- */
621
- declare function validatePromptConfigs(value: unknown, options?: {
622
- strategyDir?: string;
623
- moduleDir?: string;
624
- }): Promise<PromptConfigValidationResult>;
625
- //#endregion
626
614
  //#region src/host/module-tool-target.d.ts
627
615
  interface ModuleToolTarget {
628
616
  id: string;
@@ -635,7 +623,6 @@ interface ModuleToolHost {
635
623
  }
636
624
  //#endregion
637
625
  //#region src/runtime/character-tools.d.ts
638
- /** 注册角色卡库模型工具;返回 disposer,随 character-tools 模块生命周期清理。 */
639
626
  declare function registerCharacterTools(ctx: Context, host: ModuleToolHost): () => void;
640
627
  //#endregion
641
628
  //#region src/runtime/world-book-tools.d.ts
@@ -643,44 +630,10 @@ declare function registerCharacterTools(ctx: Context, host: ModuleToolHost): ()
643
630
  declare function registerWorldBookTools(ctx: Context, host: ModuleToolHost): () => void;
644
631
  //#endregion
645
632
  //#region src/host/characters.d.ts
646
- /** meta 下记录「每张卡引入了哪些模块」的键;来源保留到模块不再被消费并完成回退。 */
647
- declare const CHARACTER_MODULES_KEY = "characterModules";
648
- /** 读取 preset.yml `meta.modules` 之外的模块来源记录;非法形状一律视为无记录(老卡与手改文件不报错)。 */
649
- declare function recordedCharacterModules(meta: unknown): Record<string, string[]>;
650
- /** 卡自身声明的模块(声明优先:ST 转换产物自带六件套声明,行为因此不变)。
651
- * 只丢弃非字符串与空串;模块名合法性仍由 appendPresetModules 校验(非法名 fail loud)。 */
652
- declare function declaredCharacterModules(spec: ModuleSpec): string[];
653
- /** 必需模块:`prompt-config-engine` 缺失会让 promptConfigs 静默失效,因此始终补齐;
654
- * 卡内含 world-book 策略配置时另需 `world-book-tools`(与旧实现同判据)。 */
655
- declare function requiredCharacterModules(configs: readonly unknown[]): string[];
656
- /** 移除一张卡之后,某个模块是否仍被模块内容或其他卡需要(需要则不回退)。 */
657
- interface CharacterModuleContext {
658
- /** 移除本卡前缀配置之后的提示词配置。 */
659
- configs: readonly Record<string, unknown>[];
660
- /** 移除本卡声明的 params 键之后的模块参数。 */
661
- params: Record<string, unknown>;
662
- /** 模块顶层是否仍有自定义工具。 */
663
- customTools: boolean;
664
- /** 移除本卡之后仍标记为已导入的角色卡 id。 */
665
- importedCharacters: readonly string[];
666
- }
667
- /** 模块的消费者判据。未知模块保守保留:宁可留一个无消费者的模块,也不误删用户或引擎要用的装配。 */
668
- declare function characterModuleStillNeeded(module: string, context: CharacterModuleContext): boolean;
669
- /** 角色卡记忆变更后同步已导入模块的 chara-<id>-memory 注入条目
670
- * (world_book note 写入卡记忆后调用;未导入当前模块的卡返回 synced=false)。 */
671
- declare function syncImportedCharacterMemory(moduleRoot: string, templateName: string, cardId: string): {
672
- ok: true;
673
- synced: boolean;
674
- } | {
675
- ok: false;
676
- message: string;
677
- };
678
- /** 追加角色卡本地记忆(.characters/<id>/memory.md,跟随角色卡跨模块)。 */
679
- declare function appendCharacterMemory(moduleRoot: string, cardId: string, note: string): void;
680
- /** 追加记忆文件(时间戳列表格式;header 标注文件类型)。世界书工具与角色卡共用。 */
681
- declare function appendMemoryFile(file: string, note: string, header?: string): void;
682
- /** 读角色卡本地记忆文本(无记忆返回空串)。 */
683
- declare function readCharacterMemory(moduleRoot: string, cardId: string): string;
633
+ /** 模块记忆与条目同归当前模块;来源和 id 前缀不改变位置。 */
634
+ declare function appendModuleMemory(moduleDir: string, note: string): void;
635
+ /** 每次显式读取最新字节;缺失为空,链接与读取失败原样报错。 */
636
+ declare function readModuleMemory(moduleDir: string): string;
684
637
  type CharacterImportOptions = StConversionOptions & ImportChoices;
685
638
  type CharacterImportResult = {
686
639
  ok: true;
@@ -691,30 +644,11 @@ type CharacterImportResult = {
691
644
  ok: false;
692
645
  message: string;
693
646
  };
694
- /** 角色卡入库:PNG 原图(可选)+ 角色卡 JSON → 转换参数存 converted.yml。 */
695
- declare function importCharacterCard(moduleRoot: string, files: AssetFile[], options?: CharacterImportOptions): CharacterImportResult;
696
- /** 原始文件流导入:识别 PNG 魔数后在 host 侧提取角色卡,避免客户端 base64 膨胀 JSON。 */
697
- declare function importCharacterCardFile(moduleRoot: string, filePath: string, fileName?: string, options?: CharacterImportOptions): CharacterImportResult;
698
- interface CharacterCardListItem {
699
- id: string;
700
- name: string;
701
- description?: string;
702
- hasAvatar: boolean;
703
- /** 是否已导入当前模块(激活模块 meta.importedCharacters 含该 id)。 */
704
- imported: boolean;
705
- }
706
- /** 角色卡库清单 + 各卡在当前模块的导入状态。 */
707
- declare function listCharacterCards(moduleRoot: string, activeTemplate: string | undefined): CharacterCardListItem[];
708
- /** 删除角色卡库条目。 */
709
- declare function deleteCharacterCard(moduleRoot: string, id: string): {
710
- ok: true;
711
- } | {
712
- ok: false;
713
- message: string;
714
- };
715
- /** 角色卡参数导入当前模块:promptConfigs 合并(chara-<id>- 前缀防冲突)、
716
- * params 合并(角色卡覆盖同键)、meta.importedCharacters 记录来源。 */
717
- declare function applyCharacterToPreset(moduleRoot: string, templateName: string, cardId: string): {
647
+ /** 复用普通模块候选校验、版本保护和目录交换,不生成角色专属存储。 */
648
+ declare function importCharacterCard(root: string, files: AssetFile[], options?: CharacterImportOptions): Promise<CharacterImportResult>;
649
+ declare function importCharacterCardFile(root: string, filePath: string, fileName?: string, options?: CharacterImportOptions): Promise<CharacterImportResult>;
650
+ /** 通用并入保留既有带前缀往返行为,不复制本地记忆。 */
651
+ declare function mergeModuleIntoModule(root: string, targetId: string, sourceId: string): {
718
652
  ok: true;
719
653
  count: number;
720
654
  personaOpened?: boolean;
@@ -722,9 +656,8 @@ declare function applyCharacterToPreset(moduleRoot: string, templateName: string
722
656
  ok: false;
723
657
  message: string;
724
658
  };
725
- /** 从当前模块移除角色卡参数:删前缀 promptConfigs、删该卡声明的 params 键、
726
- * meta.importedCharacters 除名。 */
727
- declare function removeCharacterFromPreset(moduleRoot: string, templateName: string, cardId: string): {
659
+ /** 撤销并入内容;旧 chara 前缀可撤销,能力归属只写一份登记。 */
660
+ declare function removeMergedModule(root: string, targetId: string, sourceId: string): {
728
661
  ok: true;
729
662
  count: number;
730
663
  } | {
@@ -739,7 +672,7 @@ interface PromptConfigTemplate {
739
672
  /** 模板原文(编辑器源码模式可直接展示)。 */
740
673
  content: string;
741
674
  /** 解析后的单条提示词配置。 */
742
- spec: PromptConfigSpec;
675
+ spec: RuleDefinition;
743
676
  }
744
677
  /** 自定义工具模板(templates/tools/*.yml;tool-config-engine 定义形态)。 */
745
678
  interface ToolTemplate {
@@ -758,15 +691,15 @@ type TuiSource = PromptSettings & {
758
691
  skillCatalog: SkillCatalogEntry[];
759
692
  activeSkillsDirs: string[];
760
693
  };
761
- /** 参数保存回调:写激活模块 preset.yml;失败必须抛给命令层渲染为错误。 */
762
- type SavePresetParam = (key: string, value: unknown) => void | Promise<void>;
694
+ /** 参数保存回调:写激活模块 module.yml;失败必须抛给命令层渲染为错误。 */
695
+ type SaveModuleParam = (key: string, value: unknown) => void | Promise<void>;
763
696
  /** 技能启停回调:切换受管实体的根链接。 */
764
697
  type ToggleSkillState = (folder: string, enabled: boolean) => {
765
698
  ok: boolean;
766
699
  message?: string;
767
700
  };
768
701
  /** 通过 DSH 命令注册表暴露 /prompt-tool,Web 与 dsh-tui 都能执行。 */
769
- declare function registerTuiCommand(ctx: Context, ns: 'prompt-tool', getSource: () => TuiSource, getModelsState: () => ModelDetection, getModelCatalog: () => Promise<Record<string, string[]>>, getPresetConfigsDir?: () => string, savePresetParam?: SavePresetParam, toggleSkillState?: ToggleSkillState): void;
702
+ declare function registerTuiCommand(ctx: Context, ns: 'prompt-tool', getSource: () => TuiSource, getModelsState: () => ModelDetection, getModelCatalog: () => Promise<Record<string, string[]>>, getModuleDirectory?: () => string, saveModuleParam?: SaveModuleParam, toggleSkillState?: ToggleSkillState, refreshModule?: (id: string) => Promise<void>): void;
770
703
  //#endregion
771
704
  //#region src/host/skills-refresh.d.ts
772
705
  interface SkillsReloaderDeps {
@@ -829,6 +762,16 @@ declare function scanRoot(root: ScanRoot): ScannedSkill[];
829
762
  declare function scanRoots(roots: readonly ScanRoot[]): ScannedSkill[];
830
763
  declare function catalogFromScan(skills: readonly ScannedSkill[]): SkillCatalogEntry[];
831
764
  //#endregion
765
+ //#region src/host/module-install.d.ts
766
+ declare function assertModuleId(id: unknown): asserts id is string;
767
+ /** ENOENT 才表示不存在;权限、占用与读取失败继续传播。 */
768
+ declare function modulePathExists(path: string): boolean;
769
+ declare function canonicalModulesRoot(root: string, allowMissing?: boolean): string;
770
+ /** 根与目标先解析真实路径,拒绝链接目录及定义身份不一致。 */
771
+ declare function assertModuleDirectory(root: string, id: string, allowMissing?: boolean): string;
772
+ /** 复制和物化只接受自有普通文件;不跟随任意层级链接读取根外数据。 */
773
+ declare function assertModuleTree(dir: string): void;
774
+ //#endregion
832
775
  //#region src/runtime/skills-parse.d.ts
833
776
  interface SkillFrontmatter {
834
777
  name?: string;
@@ -860,4 +803,4 @@ declare const name = "prompt-tool";
860
803
  declare const inject: string[];
861
804
  declare function apply(ctx: Context, configIn: Config): void;
862
805
  //#endregion
863
- export { BRIDGE_ENDPOINTS, type BridgeEndpoint, type BridgeErrorPayload, type BridgeRequestMap, type BridgeValueMap, CHARACTER_MODULES_KEY, type CharacterModuleContext, Config, DEFAULT_MODULE_ID, ENGINE_CAPABILITIES, ENGINE_PARAM_KEYS, ENGINE_RECIPES, type EngineCapability, type EngineCapabilityCreateRequest, type EngineCapabilityCreateResult, type EngineCapabilityRemoveResult, INSTRUCTION_FILE_STATUSES, type InstructionContextView, type InstructionFileSnapshot, type InstructionFileStatus, MAX_BRIDGE_BODY_BYTES, MAX_CHARACTER_CARD_STREAM_BYTES, MAX_INSTRUCTION_FILE_BYTES, type ModuleFacts, type ModuleSourceMode, type ModuleSpec, PARAM_KEYS, PRE_STEP_COORDINATOR_SERVICE, PRE_STEP_COORDINATOR_VERSION, type PluginSubagentSeam, type PreStepCoordinatorOptions, type PreStepCoordinatorService, type PreStepPromptConfig, type PreStepSource, type PromptConfigTemplate, type PromptConfigValidationError, type PromptConfigValidationResult, SETTINGS_BRIDGE_PREFIX, SKILL_NAME_PATTERN, type SkillCatalogEntry, type SkillFrontmatter, type SkillPolicyChange, type SkillPolicyRead, type SkillPolicyScope, type SkillPolicyWrite, type SkillsCatalogSnapshot, type SkillsRuntime, type SkillsState, type ToolTemplate, USER_SKILLS_DIR, WRITER_PARAM_KEYS, type WritePresetOptions, agentsFileCardSpecs, agentsFileId, appendCharacterMemory, appendMemoryFile, apply, applyCharacterToPreset, applyModuleConfigs, assertSafeConfigId, buildModuleConfigsFromParams, buildWorldBookEntry, catalogFromScan, characterModuleStillNeeded, cloneBuiltinPreset, configFileName, convertStToPreset, createEngineCapabilityInPreset, createSkillsReloader, createSkillsRuntime, declaredCharacterModules, deleteCharacterCard, deleteWorldBookEntry, detectAgentsFileSnapshots, detectAgentsFiles, detectModels, engineCapability, engineRecipe, ensurePresetSeed, ensureWebSurface, expandPresetSource, exportPresetPackage, importCharacterCard, importCharacterCardFile, importSkillsPackage, inject, installPreStepCoordinator, installPresetPackage, invalidateModelCatalog, invocationForScope, isEngineCapabilityPresent, listAdvertisedModels, listBuiltinTemplates, listCharacterCards, listModules, listWorldBookEntries, loadModuleSpec, loadPromptTemplates, loadToolTemplates, mergeInstructionCards, mergeStPresets, moduleDirExists, name, parseFrontmatter, peekModelCatalog, presetImportPreview, processStText, readAgentsFileSnapshot, readCharacterMemory, readSkillInvocation, readSkillsState, recordedCharacterModules, registerCharacterTools, registerSettingsBridge, registerTuiCommand, registerWorldBookTools, removeCharacterFromPreset, removeEngineCapabilityFromPreset, removePresetModule, removeUserPreset, renderComposition, requiredCharacterModules, resolveModuleDir, resolveModuleFacts, resolvePresetParams, resolveProfileDir, resolveProjectRoot, resolveSubagentStartOptions, saveModuleParams, savePresetPersona, scanRoot, scanRoots, scheduleWebSurfaceRepair, scopeOfInvocation, setSkillInvocation, skillRoots, skillsStatePath, stPresetId, syncImportedCharacterMemory, upsertWorldBookEntry, userModulesDir, validateCustomToolIdentities, validateEngineParamValues, validatePromptConfigs, writeAgentsFile, writeAgentsFileChecked, writePreset, writeSkillsState };
806
+ export { BRIDGE_ENDPOINTS, type BridgeEndpoint, type BridgeErrorPayload, type BridgeRequestMap, type BridgeValueMap, Config, DEFAULT_MODULE_ID, MODULE_CAPABILITIES as ENGINE_CAPABILITIES, MODULE_CAPABILITIES, ENGINE_PARAM_KEYS, ENGINE_RECIPES, type ModuleCapability as EngineCapability, type ModuleCapability, type ModuleCapabilityCreateRequest as EngineCapabilityCreateRequest, type ModuleCapabilityCreateRequest, type ModuleCapabilityCreateResult as EngineCapabilityCreateResult, type ModuleCapabilityCreateResult, type ModuleCapabilityRemoveResult as EngineCapabilityRemoveResult, type ModuleCapabilityRemoveResult, INJECTION_POINT_ORDER, INSTRUCTION_FILE_STATUSES, type InjectionPoint, type InstructionContextView, type InstructionFileSnapshot, type InstructionFileStatus, MAX_BRIDGE_BODY_BYTES, MAX_CHARACTER_CARD_STREAM_BYTES, MAX_INSTRUCTION_FILE_BYTES, type ModuleExportRequest, type ModuleExportResult, type ModuleFacts, ModuleLayerSettingsError, type ModuleSourceMode, type ModuleSpec, type ModuleSummary, type ModuleWriterParams, PARAM_KEYS, PRE_STEP_COORDINATOR_SERVICE, PRE_STEP_COORDINATOR_VERSION, type PluginSubagentSeam, type PreStepCoordinatorOptions, type PreStepCoordinatorService, type PreStepPromptConfig, type PreStepSource, type PromptConfigTemplate, SETTINGS_BRIDGE_PREFIX, SKILL_NAME_PATTERN, type SkillCatalogEntry, type SkillFrontmatter, type SkillPolicyChange, type SkillPolicyRead, type SkillPolicyScope, type SkillPolicyWrite, type SkillsCatalogSnapshot, type SkillsRuntime, type SkillsState, type ToolTemplate, USER_SKILLS_DIR, WRITER_PARAM_KEYS, type WriteModuleOptions, type WritePresetOptions, agentsFileCardSpecs, agentsFileId, appendModuleCapabilities, appendModuleMemory, apply, applyModuleConfigs, assertModuleDirectory, assertModuleId, assertModuleTree, assertSafeConfigId, buildModuleConfigsFromParams, buildWorldBookEntry, canonicalModulesRoot, catalogFromScan, cloneBuiltinModule, cloneBuiltinModule as cloneBuiltinPreset, configFileName, convertStToModule, convertStToModule as convertStToPreset, convertStToModuleWithReport, createModuleCapability as createEngineCapabilityInPreset, createModuleCapability, createSkillsReloader, createSkillsRuntime, deleteWorldBookEntry, detectAgentsFileSnapshots, detectAgentsFiles, detectModels, moduleCapability as engineCapability, moduleCapability, engineRecipe, ensureModuleReady, ensureModuleSeed, ensureModuleSeed as ensurePresetSeed, ensureWebSurface, expandModuleSource, expandModuleSource as expandPresetSource, exportModulePackage, exportModulePackage as exportPresetPackage, importCharacterCard, importCharacterCardFile, importSkillsPackage, inject, installModulePackage, installModulePackage as installPresetPackage, installPreStepCoordinator, invalidateModelCatalog, invocationForScope, isModuleCapabilityPresent as isEngineCapabilityPresent, isModuleCapabilityPresent, listAdvertisedModels, listBuiltinTemplates, listModules, listWorldBookEntries, loadModuleSpec, loadPromptTemplates, loadToolTemplates, mergeInstructionCards, mergeModuleIntoModule, mergeStModules, mergeStModules as mergeStPresets, mergeStModulesWithReport, moduleDirExists, moduleImportPreview, moduleImportPreview as presetImportPreview, modulePathExists, name, parseFrontmatter, peekModelCatalog, processStText, readAgentsFileSnapshot, readModuleLayerSettings, readModuleMemory, readSkillInvocation, readSkillsState, registerCharacterTools, registerSettingsBridge, registerTuiCommand, registerWorldBookTools, removeModuleCapability as removeEngineCapabilityFromPreset, removeModuleCapability, removeMergedModule, removeModuleCapabilityDeclaration, removeModuleCapabilityDeclaration as removePresetModule, removeUserModule, removeUserModule as removeUserPreset, renderComposition, resolveModuleDir, resolveModuleFacts, resolveModuleParams, resolveModuleParams as resolvePresetParams, resolveProfileDir, resolveProjectRoot, resolveSubagentStartOptions, saveModuleParams, saveModulePersona, saveModulePersona as savePresetPersona, scanRoot, scanRoots, scheduleWebSurfaceRepair, scopeOfInvocation, setSkillInvocation, skillRoots, skillsStatePath, stModuleId, stModuleId as stPresetId, upsertWorldBookEntry, userModulesDir, validateCustomToolIdentities, validateEngineParamValues, withModuleDefinition, writeAgentsFile, writeAgentsFileChecked, writeModule, writePreset, writeSkillsState };