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.
- package/README.md +100 -233
- package/engine/actions/append-context.mjs +3 -24
- package/engine/actions/assembly.mjs +70 -94
- package/engine/actions/catalog.mjs +65 -28
- package/engine/actions/content.mjs +8 -152
- package/engine/actions/examples.mjs +8 -4
- package/engine/actions/inbox-prepend.mjs +5 -7
- package/engine/actions/index.mjs +17 -9
- package/engine/actions/inject-text.mjs +24 -4
- package/engine/actions/pre-step-filter.mjs +3 -4
- package/engine/actions/registration.mjs +20 -28
- package/engine/actions/request-params.mjs +21 -1
- package/engine/actions/shared.mjs +23 -15
- package/engine/actions/stream-output.mjs +26 -0
- package/engine/actions/tool-gate.mjs +31 -0
- package/engine/actions/tool-result.mjs +36 -0
- package/engine/actions/tool-visibility.mjs +248 -0
- package/engine/agent-capability.mjs +67 -0
- package/engine/anchor-match.mjs +14 -21
- package/engine/audience.d.mts +2 -0
- package/engine/audience.mjs +102 -0
- package/engine/branch.d.mts +4 -0
- package/engine/branch.mjs +62 -19
- package/engine/compaction-epoch.d.mts +25 -0
- package/engine/compaction-epoch.mjs +27 -4
- package/engine/compositions/source/local/filesystem-editor.yml +3 -3
- package/engine/compositions/source/local/instruction-hint.yml +4 -7
- package/engine/compositions/source/local/module-file-tools.yml +2 -0
- package/engine/compositions/source/local/module-import-tools.yml +4 -0
- package/engine/compositions/source/local/module-manifest-tools.yml +2 -0
- package/engine/compositions/source/local/module-rule-tools.yml +5 -0
- package/engine/compositions/source/local/module-variable-tools.yml +5 -0
- package/engine/compositions/source/local/present-as.yml +26 -0
- package/engine/compositions/source/local/tool-config-engine.yml +2 -3
- package/engine/compositions/source/local/tool-search.yml +11 -0
- package/engine/condition-facts.mjs +84 -0
- package/engine/conditions/anchor.mjs +63 -23
- package/engine/conditions/availability.mjs +1 -1
- package/engine/conditions/composite.mjs +4 -4
- package/engine/conditions/count.mjs +43 -13
- package/engine/conditions/evaluation.mjs +74 -19
- package/engine/conditions/examples.mjs +2 -1
- package/engine/conditions/index.d.mts +15 -0
- package/engine/conditions/index.mjs +23 -9
- package/engine/conditions/operators.mjs +4 -0
- package/engine/conditions/phase.mjs +10 -5
- package/engine/conditions/preset.mjs +1 -1
- package/engine/conditions/session.mjs +8 -2
- package/engine/conditions/subject.mjs +144 -65
- package/engine/conditions/text.mjs +26 -8
- package/engine/conditions/variable.mjs +83 -0
- package/engine/context-activation.d.mts +11 -0
- package/engine/{st-world-book.mjs → context-activation.mjs} +104 -64
- package/engine/delivery.d.mts +2 -0
- package/engine/delivery.mjs +93 -0
- package/engine/discovery.d.mts +38 -0
- package/engine/discovery.mjs +146 -0
- package/engine/env-safety.mjs +14 -0
- package/engine/executor.d.mts +28 -0
- package/engine/executor.mjs +290 -205
- package/engine/fillers.mjs +39 -8
- package/engine/fixed-registration.mjs +12 -0
- package/engine/history.mjs +71 -0
- package/engine/instruction-blocks.d.mts +13 -0
- package/engine/instruction-blocks.mjs +21 -0
- package/engine/instruction-files.d.mts +5 -0
- package/engine/instruction-files.mjs +97 -0
- package/engine/instruction-hint.mjs +69 -103
- package/engine/interpolate.d.mts +7 -0
- package/engine/interpolate.mjs +44 -13
- package/engine/layers.mjs +165 -230
- package/engine/machine-paths.mjs +40 -0
- package/engine/module-file-tools.mjs +8 -0
- package/engine/module-import-tools.mjs +10 -0
- package/engine/module-manifest-tools.mjs +8 -0
- package/engine/module-rule-tools.mjs +10 -0
- package/engine/module-variable-tools.mjs +10 -0
- package/engine/order.d.mts +14 -0
- package/engine/order.mjs +0 -3
- package/engine/path-safety.d.mts +2 -0
- package/engine/path-safety.mjs +58 -0
- package/engine/pre-step-source.d.mts +69 -0
- package/engine/pre-step-source.mjs +103 -0
- package/engine/present-as.mjs +77 -0
- package/engine/promotion-pool.d.mts +9 -0
- package/engine/promotion-pool.mjs +69 -0
- package/engine/record.mjs +2 -0
- package/engine/rule-engine.mjs +3 -2
- package/engine/rule-facts.d.mts +11 -0
- package/engine/rule-facts.mjs +60 -0
- package/engine/rule-runtime.d.mts +46 -0
- package/engine/rule-runtime.mjs +98 -13
- package/engine/rule-spec.d.mts +106 -0
- package/engine/rule-spec.mjs +302 -28
- package/engine/run-code-env.mjs +73 -19
- package/engine/schema.mjs +165 -243
- package/engine/sdk-strip.mjs +2 -2
- package/engine/service-names.d.mts +10 -0
- package/engine/service-names.mjs +10 -0
- package/engine/shared.d.mts +21 -0
- package/engine/shared.mjs +47 -26
- package/engine/skill-search.mjs +125 -53
- package/engine/source-kind.d.mts +9 -0
- package/engine/source-kind.mjs +16 -0
- package/engine/strategy-ids.mjs +5 -0
- package/engine/template-evaluation.d.mts +16 -0
- package/engine/template-evaluation.mjs +178 -0
- package/engine/template-frame.d.mts +16 -0
- package/engine/template-frame.mjs +69 -0
- package/engine/tool-config-engine.mjs +39 -35
- package/engine/tool-definition.d.mts +4 -0
- package/engine/tool-definition.mjs +5 -1
- package/engine/tool-git-bash.mjs +5 -1
- package/engine/tool-scope.mjs +22 -0
- package/engine/{dev-tool-search.mjs → tool-search.mjs} +63 -65
- package/engine/trigger.mjs +15 -270
- package/engine/vendor/yaml/dist/compose/resolve-flow-scalar.js +19 -18
- package/engine/vendor/yaml/dist/nodes/Alias.js +25 -23
- package/engine/vendor/yaml/package.json +1 -1
- package/lib/client.js +8312 -6724
- package/lib/client.js.map +1 -1
- package/lib/index.d.mts +37 -762
- package/lib/index.mjs +26919 -5791
- package/modules/ponytail/module.yml +83 -203
- package/modules/ptc-mode/module.yml +45 -0
- package/modules/soul/assets/core-hard.md +6 -0
- package/modules/soul/assets/criteria.md +12 -0
- package/modules/soul/assets/echo.md +12 -0
- package/modules/soul/assets/layers.md +11 -0
- package/modules/soul/assets/ledger.md +9 -0
- package/modules/soul/assets/manifest.yml +20 -0
- package/modules/soul/assets/reference/00-layers.md +27 -0
- package/modules/soul/assets/reference/01-criteria.md +32 -0
- package/modules/soul/assets/reference/02-echo.md +158 -0
- package/modules/soul/assets/reference/03-vital.md +183 -0
- package/modules/soul/assets/reference/04-manifest.json +106 -0
- package/modules/soul/assets/reference/05-doctor.md +67 -0
- package/modules/soul/assets/reference/06-reference.md +189 -0
- package/modules/soul/assets/reference/07-bundle.json +431 -0
- package/modules/soul/assets/reference/08-/350/270/251/345/235/221/345/256/236/345/275/225.md +59 -0
- package/modules/soul/assets/reference/09-dev-workflow.md +109 -0
- package/modules/soul/assets/reference/10-echo-anatomy.md +100 -0
- package/modules/soul/assets/reference/11-self.md +80 -0
- package/modules/soul/assets/reference/12-ledger.md +159 -0
- package/modules/soul/assets/reference/README.md +10 -0
- package/modules/soul/assets/templates/agents-template.md +6 -0
- package/modules/soul/assets/vital.md +9 -0
- package/modules/soul/module.yml +311 -0
- package/modules/superpowers/module.yml +122 -0
- package/modules/tool-surface/module.yml +51 -47
- package/package.json +40 -41
- package/skills/dsh-module/SKILL.md +119 -0
- package/skills/dsh-module/reference.md +185 -0
- package/templates/10-pre-step.yml +2 -3
- package/templates/14-first-turn-anchor.yml +10 -14
- package/templates/15-guide-auto.yml +32 -28
- package/templates/16-custom-fallback.yml +33 -21
- package/templates/20-system-section.yml +1 -4
- package/templates/50-llm-stream.yml +4 -10
- package/templates/60-tool-pipeline.yml +12 -10
- package/templates/63-append-context.yml +20 -0
- package/templates/64-pre-step-filter.yml +23 -0
- package/templates/65-turn-stop.yml +2 -2
- package/templates/67-inbox-prepend.yml +22 -0
- package/templates/70-subagent-maintenance.yml +9 -10
- package/templates/75-subagent-end.yml +2 -2
- package/templates/80-tool-surface.yml +41 -57
- package/templates/tools/40-delegate-module-import.yml +22 -0
- package/templates/tools/50-delegate-module-rules.yml +14 -0
- package/templates/tools/60-delegate-module-variables.yml +17 -0
- package/templates/tools/70-delegate-module-rules-edit.yml +31 -0
- package/engine/actions/decision.mjs +0 -54
- package/engine/actions/guard.mjs +0 -80
- package/engine/actions/sdk-strip.mjs +0 -30
- package/engine/character-tools.mjs +0 -8
- package/engine/classify-task.mjs +0 -53
- package/engine/compositions/library/agent-instructions.yml +0 -9
- package/engine/compositions/library/command-goal.yml +0 -7
- package/engine/compositions/library/compaction.yml +0 -22
- package/engine/compositions/library/delegation-ptc.yml +0 -58
- package/engine/compositions/library/delegation.yml +0 -56
- package/engine/compositions/library/persistent-shell.yml +0 -50
- package/engine/compositions/library/planning.yml +0 -26
- package/engine/compositions/library/skill-filesystem-cordis.yml +0 -10
- package/engine/compositions/library/skill-filesystem.yml +0 -7
- package/engine/compositions/library/tool-ask-user.yml +0 -7
- package/engine/compositions/library/tool-bash.yml +0 -8
- package/engine/compositions/library/tool-cordis.yml +0 -7
- package/engine/compositions/library/tool-fs-search.yml +0 -9
- package/engine/compositions/library/tool-fs.yml +0 -7
- package/engine/compositions/library/tool-goal.yml +0 -7
- package/engine/compositions/library/tool-jobs.yml +0 -7
- package/engine/compositions/library/tool-plugin-manager-disabled.yml +0 -8
- package/engine/compositions/library/tool-plugin-manager.yml +0 -8
- package/engine/compositions/library/tool-present.yml +0 -7
- package/engine/compositions/library/tool-presentation.yml +0 -9
- package/engine/compositions/library/tool-pwsh.yml +0 -8
- package/engine/compositions/library/tool-skill.yml +0 -7
- package/engine/compositions/library/tool-todo.yml +0 -9
- package/engine/compositions/library/tool-web.yml +0 -10
- package/engine/compositions/source/local/character-tools.yml +0 -5
- package/engine/compositions/source/local/declared-triggers.yml +0 -12
- package/engine/compositions/source/local/dev-tool-search.yml +0 -11
- package/engine/compositions/source/local/session-var-tools.yml +0 -5
- package/engine/compositions/source/local/subagent-tool-policy.yml +0 -21
- package/engine/compositions/source/local/world-book-tools.yml +0 -5
- package/engine/condition.mjs +0 -96
- package/engine/declared-triggers.mjs +0 -93
- package/engine/session-var-tools.mjs +0 -8
- package/engine/session-vars.mjs +0 -54
- package/engine/st-macros.d.mts +0 -22
- package/engine/st-macros.mjs +0 -208
- package/engine/st-render.mjs +0 -109
- package/engine/st-world-book.d.mts +0 -10
- package/engine/subagent-tool-policy-core.mjs +0 -400
- package/engine/subagent-tool-policy.mjs +0 -352
- package/engine/trigger-spec.mjs +0 -173
- package/engine/world-book-tools.mjs +0 -8
- package/lib/migrate-rules.d.mts +0 -1
- package/lib/migrate-rules.mjs +0 -39
- package/lib/module-package-CHPFweqK.mjs +0 -2
- package/lib/module-package-Cnd1_mwx.mjs +0 -2872
- package/lib/paths-CyP0IkaM.d.mts +0 -1390
- package/lib/preset-transfer.d.mts +0 -2
- package/lib/preset-transfer.mjs +0 -3
- package/lib/rules-migration-DJ6vASB5.mjs +0 -15334
- package/templates/policies/legacy-defaults.yml +0 -34
- package/templates/tools/40-delegate-character.yml +0 -15
- package/templates/tools/50-delegate-worldbook.yml +0 -15
- package/templates/tools/60-delegate-session-var.yml +0 -15
- package/templates/tools/70-delegate-worldbook-upsert.yml +0 -36
package/lib/index.d.mts
CHANGED
|
@@ -1,670 +1,50 @@
|
|
|
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
|
-
import { parseDocument } from "yaml";
|
|
3
1
|
import z from "@deepseek-ai/schemastery";
|
|
4
|
-
import { ToolExecution } from "@deepseek-ai/dsh-tools";
|
|
5
2
|
import { Context, Volatile } from "@deepseek-ai/cordis";
|
|
6
|
-
import { SkillViewOptions } from "@deepseek-ai/dsh-skill";
|
|
7
|
-
import { AgentOptions } from "@deepseek-ai/dsh-agent";
|
|
8
|
-
import { SubagentRuntime } from "@deepseek-ai/dsh-subagent";
|
|
9
|
-
//#region src/shared/param-keys.d.ts
|
|
10
|
-
declare const PARAM_KEYS: ReadonlySet<string>;
|
|
11
|
-
//#endregion
|
|
12
3
|
//#region src/config.d.ts
|
|
13
4
|
interface Config {
|
|
14
5
|
modulesEnabled: Volatile<boolean | undefined>;
|
|
15
|
-
/** 已部署配置的输入兼容;只在读取与显式保存边界归一。 */
|
|
16
|
-
writePreset?: Volatile<boolean | undefined>;
|
|
17
6
|
}
|
|
18
7
|
declare const Config: z<Schemastery.ObjectS<NoInfer<{
|
|
19
8
|
modulesEnabled: z<boolean, boolean, "volatile">;
|
|
20
|
-
writePreset: z<boolean, boolean, "volatile">;
|
|
21
9
|
}>>, Schemastery.ObjectT<NoInfer<{
|
|
22
10
|
modulesEnabled: z<boolean, boolean, "volatile">;
|
|
23
|
-
writePreset: z<boolean, boolean, "volatile">;
|
|
24
11
|
}>>, "plain">;
|
|
25
|
-
interface PromptSettings {
|
|
26
|
-
/** 运行时检测:是否检测到任何模型服务商(不写入 settings)。 */
|
|
27
|
-
modelsAvailable: boolean;
|
|
28
|
-
modulesEnabled: boolean;
|
|
29
|
-
}
|
|
30
12
|
//#endregion
|
|
31
|
-
//#region src/shared/
|
|
32
|
-
/**
|
|
33
|
-
|
|
34
|
-
readonly firstTurnAnchor: {
|
|
35
|
-
readonly kind: "boolean";
|
|
36
|
-
readonly targets: readonly ["near-anchor"];
|
|
37
|
-
};
|
|
38
|
-
readonly firstTurnText: {
|
|
39
|
-
readonly kind: "string";
|
|
40
|
-
readonly targets: readonly ["near-anchor", "prompt-injector"];
|
|
41
|
-
};
|
|
42
|
-
readonly firstTurnCustom: {
|
|
43
|
-
readonly kind: "boolean";
|
|
44
|
-
readonly targets: readonly ["near-anchor"];
|
|
45
|
-
};
|
|
46
|
-
readonly guideText: {
|
|
47
|
-
readonly kind: "string";
|
|
48
|
-
readonly targets: readonly ["router-guide"];
|
|
49
|
-
};
|
|
50
|
-
readonly guideCustom: {
|
|
51
|
-
readonly kind: "boolean";
|
|
52
|
-
readonly targets: readonly ["router-guide"];
|
|
53
|
-
};
|
|
54
|
-
readonly guideEnabled: {
|
|
55
|
-
readonly kind: "boolean";
|
|
56
|
-
readonly targets: readonly ["router-guide"];
|
|
57
|
-
};
|
|
58
|
-
readonly injectPrompt: {
|
|
59
|
-
readonly kind: "boolean";
|
|
60
|
-
readonly targets: readonly ["prompt-injector"];
|
|
61
|
-
};
|
|
62
|
-
readonly firstTurnWord: {
|
|
63
|
-
readonly kind: "string";
|
|
64
|
-
readonly targets: readonly ["prompt-injector"];
|
|
65
|
-
};
|
|
66
|
-
readonly buildPattern: {
|
|
67
|
-
readonly kind: "pattern";
|
|
68
|
-
readonly targets: readonly ["near-anchor"];
|
|
69
|
-
};
|
|
70
|
-
readonly complexPattern: {
|
|
71
|
-
readonly kind: "pattern";
|
|
72
|
-
readonly targets: readonly ["near-anchor", "router-guide"];
|
|
73
|
-
};
|
|
74
|
-
readonly firstTurnBuild: {
|
|
75
|
-
readonly kind: "string";
|
|
76
|
-
readonly targets: readonly ["near-anchor", "prompt-injector"];
|
|
77
|
-
};
|
|
78
|
-
readonly firstTurnInspect: {
|
|
79
|
-
readonly kind: "string";
|
|
80
|
-
readonly targets: readonly ["near-anchor", "prompt-injector"];
|
|
81
|
-
};
|
|
82
|
-
readonly firstTurnDeep: {
|
|
83
|
-
readonly kind: "string";
|
|
84
|
-
readonly targets: readonly ["near-anchor", "prompt-injector"];
|
|
85
|
-
};
|
|
86
|
-
readonly guideWeak: {
|
|
87
|
-
readonly kind: "string";
|
|
88
|
-
readonly targets: readonly ["router-guide"];
|
|
89
|
-
};
|
|
90
|
-
readonly guideDeep: {
|
|
91
|
-
readonly kind: "string";
|
|
92
|
-
readonly targets: readonly ["router-guide"];
|
|
93
|
-
};
|
|
94
|
-
};
|
|
95
|
-
type LegacyPromptParamKey = keyof typeof LEGACY_PROMPT_PARAM_DEFINITIONS;
|
|
96
|
-
type LegacyPromptParams = { [K in LegacyPromptParamKey]?: typeof LEGACY_PROMPT_PARAM_DEFINITIONS[K]['kind'] extends 'boolean' ? boolean : string; };
|
|
13
|
+
//#region src/shared/engine-capabilities.d.ts
|
|
14
|
+
/** 官方九个注入层:与 engine/schema.mjs 的 LAYER_ORDER 同源,改一处必须同步另一处。 */
|
|
15
|
+
type InjectionPoint = 'pre-step' | 'system-section' | 'runtime-context' | 'agent-request' | 'llm-stream' | 'tool-pipeline' | 'turn-stop' | 'subagent-start' | 'subagent-end';
|
|
97
16
|
//#endregion
|
|
98
|
-
//#region src/shared/
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
subagentModelName?: string;
|
|
108
|
-
/** 主对话思维程度(agent-request patch reasoningEffort;''=不设置,官方档位 off/low/high/max)。 */
|
|
109
|
-
modelReasoningEffort?: string;
|
|
110
|
-
/** 主对话采样温度(agent-request patch temperature;''=不设置)。 */
|
|
111
|
-
modelTemperature?: string;
|
|
112
|
-
/** 主对话输出上限(agent-request patch maxTokens;''=不设置)。 */
|
|
113
|
-
modelMaxTokens?: string;
|
|
114
|
-
/** 子代理思维程度(agent-request patch,audience=subagent;''=不设置)。 */
|
|
115
|
-
subagentReasoningEffort?: string;
|
|
116
|
-
/** 子代理采样温度(agent-request patch,audience=subagent;''=不设置)。 */
|
|
117
|
-
subagentTemperature?: string;
|
|
118
|
-
/** 子代理输出上限(agent-request patch,audience=subagent;''=不设置)。 */
|
|
119
|
-
subagentMaxTokens?: string;
|
|
120
|
-
/** 已启用子代理工具策略的递归深度上限;普通官方委派由宿主管理。 */
|
|
121
|
-
maxDepth?: number | 'provider-managed' | string;
|
|
122
|
-
/** 晋升后 agent-instructions 全文 → 一次性 hint。 */
|
|
123
|
-
instructionHint?: boolean;
|
|
124
|
-
/** tool-git-bash 行的能力开关(B2 T3 补;此前该行只能靠「在不在组合里」决定启停)。 */
|
|
125
|
-
toolGitBashEnabled?: boolean;
|
|
126
|
-
/** 自定义模型工具在执行前需用户批准的执行器种类。 */
|
|
127
|
-
customToolRequireApproval?: string[] | string;
|
|
128
|
-
}
|
|
129
|
-
type EngineParamKey = keyof EngineParams;
|
|
130
|
-
/**
|
|
131
|
-
* writeModule 实际透传进运行时 params 的引擎参数子集。
|
|
132
|
-
* RuntimeOptions(装配态)与 WriteModuleOptions(写入态)都从这里派生,
|
|
133
|
-
* 防止「加参数只改一处、模块写者忘透传」的静默漂移(如 stageAdvanceDescription 历史事故)。
|
|
134
|
-
*/
|
|
135
|
-
type ModuleWriterParams = Partial<EngineParams & LegacyPromptParams>;
|
|
136
|
-
/**
|
|
137
|
-
* 数值型引擎参数保存前校验(与 write-preset.modelRequestConfigs 消费规则同源)。
|
|
138
|
-
* 保存层响亮失败(400 逐字段错误),渲染层保持宽容(never-brick):
|
|
139
|
-
* - 布尔键:必须是 boolean;
|
|
140
|
-
* - 数值键(temperature / maxTokens / 字符数):'' = 合法(删键回落默认);
|
|
141
|
-
* 非空必须可解析为数字并满足各自约束(有限数 / 正整数);
|
|
142
|
-
* - 字符串键:必须是 string('' = 删键回落默认);
|
|
143
|
-
* - 列表键(执行器种类等):必须是 string 或 string[];
|
|
144
|
-
* - maxDepth:'' / 'provider-managed' / 非负安全整数及其数字字符串。
|
|
145
|
-
* 未知键(旧内容别名等不兼容键)在保存期响亮失败,不做运行时自动兼容。
|
|
146
|
-
* 注意:内容占位变量(variables)的空字符串是合理设计(世界书动态引用),
|
|
147
|
-
* 本函数只校验引擎行为参数,绝不碰 variables 通道。
|
|
148
|
-
*/
|
|
149
|
-
interface EngineParamValueError {
|
|
150
|
-
key: string;
|
|
151
|
-
message: string;
|
|
17
|
+
//#region src/shared/rules.d.ts
|
|
18
|
+
/** 一张独立配置卡的判断树;原语与组合的合法形状由引擎唯一校验。 */
|
|
19
|
+
type RuleCondition = Record<string, unknown>;
|
|
20
|
+
/** 动作拥有稳定身份;其执行点由动作目录推导,不能任意指定宿主事件。 */
|
|
21
|
+
interface RuleAction extends Record<string, unknown> {
|
|
22
|
+
id: string;
|
|
23
|
+
kind: string;
|
|
24
|
+
channelOrder?: number;
|
|
25
|
+
waterfallPosition?: 'default' | 'outermost';
|
|
152
26
|
}
|
|
153
|
-
declare const ENGINE_PARAM_KEYS: EngineParamKey[];
|
|
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")[];
|
|
156
27
|
/**
|
|
157
|
-
*
|
|
158
|
-
* 返回逐字段错误;空数组 = 通过。类型收窄:布尔/字符串/数值/列表各按 canonical
|
|
159
|
-
* 规则校验;'' 是合法删键值,其余非法类型与越界值在保存层响亮失败。
|
|
160
|
-
*/
|
|
161
|
-
declare function validateEngineParamValues(overrides: Record<string, unknown>): EngineParamValueError[];
|
|
162
|
-
//#endregion
|
|
163
|
-
//#region src/host/prompt-configs.d.ts
|
|
164
|
-
/**
|
|
165
|
-
* `PromptConfigSpec` 各枚举字段的**运行期值清单**。
|
|
166
|
-
*
|
|
167
|
-
* 类型由它派生(`(typeof X)[number]`),守卫测试也读它——于是「类型允许的值」与
|
|
168
|
-
* 「守卫断言的值」是同一份,不可能各自漂移;而这两个值集合都必须与 `engine/schema.mjs`
|
|
169
|
-
* 的对应 `KNOWN_*` 一致(守卫见 `test/shared/prompt-config-spec-enums.test.mjs`)。
|
|
28
|
+
* module.yml.rules 的单一规则定义;层是动作未声明 `config.layer` 时的缺省注入层,其余用于展示,不建立跨层执行顺序。
|
|
170
29
|
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
30
|
+
* **旧名 `when`/`do` 已随引擎重构退役**(不再作为兼容输入),全链路只有 `if`/`then`/`else`。
|
|
31
|
+
* 定义迁移由 YAML Document API 改键名完成,注释与未知字段原地保留。
|
|
173
32
|
*/
|
|
174
|
-
|
|
175
|
-
readonly configKind: readonly ["ordered", "anchor"];
|
|
176
|
-
readonly role: readonly ["user"];
|
|
177
|
-
readonly position: readonly ["after-user", "before-all", "after-all"];
|
|
178
|
-
readonly dedupe: readonly ["session", "batch", "none"];
|
|
179
|
-
readonly promotion: readonly ["none", "main", "include-subagents"];
|
|
180
|
-
readonly audience: readonly ["main", "subagent"];
|
|
181
|
-
readonly subject: readonly ["toolArgs", "toolResult", "userMessage", "assistantText", "subagentInfo"];
|
|
182
|
-
readonly modelScope: readonly ["all", "pro", "flash"];
|
|
183
|
-
readonly mergeMode: readonly ["separate", "merged"];
|
|
184
|
-
};
|
|
185
|
-
/** 取上面某一条枚举的值联合。 */
|
|
186
|
-
type SpecEnum<K extends keyof typeof PROMPT_CONFIG_SPEC_ENUMS> = (typeof PROMPT_CONFIG_SPEC_ENUMS[K])[number];
|
|
187
|
-
interface PromptConfigSpec {
|
|
33
|
+
interface RuleDefinition {
|
|
188
34
|
id: string;
|
|
189
35
|
name?: string;
|
|
190
36
|
enabled?: boolean;
|
|
191
|
-
|
|
192
|
-
layer?: string;
|
|
193
|
-
configKind?: SpecEnum<'configKind'>;
|
|
194
|
-
order?: number;
|
|
195
|
-
role?: SpecEnum<'role'>;
|
|
37
|
+
layer?: InjectionPoint;
|
|
196
38
|
group?: string;
|
|
197
39
|
exclusive?: boolean;
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
subject?: SpecEnum<'subject'>;
|
|
205
|
-
/** 条件判定的键集合;省略 = 无条件(旧行为)。 */
|
|
206
|
-
match?: PromptConfigMatch;
|
|
207
|
-
modelScope?: SpecEnum<'modelScope'>;
|
|
208
|
-
sourceKind?: string;
|
|
209
|
-
form?: string;
|
|
210
|
-
summary?: string;
|
|
211
|
-
identity?: {
|
|
212
|
-
field: 'plugin';
|
|
213
|
-
value: string;
|
|
214
|
-
};
|
|
215
|
-
text?: string;
|
|
216
|
-
/** 单条提示词配置的多段文本:注入为一条消息的多个 text 内容块。 */
|
|
217
|
-
texts?: string[];
|
|
218
|
-
/** 同位置多条提示词配置的插入方式:separate=先后插入独立消息(默认);merged=拼接为一条消息。 */
|
|
219
|
-
mergeMode?: SpecEnum<'mergeMode'>;
|
|
220
|
-
templateFile?: string;
|
|
221
|
-
fill?: string;
|
|
222
|
-
variables?: Record<string, string>;
|
|
223
|
-
params?: Record<string, unknown>;
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* 提示词配置 / 自定义工具 ID 的安全文件名段校验:ID 直接拼进生成文件名
|
|
227
|
-
* (prompt-configs/<n>-<id>.yml / custom-tools/<n>-<id>.yml),含路径分隔符
|
|
228
|
-
* 或 Windows 非法字符会越出生成目录或写盘失败,保存/物化前 fail loud 拒绝。
|
|
229
|
-
* 允许 [a-zA-Z0-9._-] 与常见中文/多字节字符(ST 导入 id 含中文),
|
|
230
|
-
* 仅拒绝分隔符、控制字符、点目录与 Windows 保留字符。
|
|
231
|
-
*/
|
|
232
|
-
declare function assertSafeConfigId(id: string): void;
|
|
233
|
-
/** 生成文件名统一 4 位零填充前缀(0000-…),超过 10 条后字典序仍稳定。 */
|
|
234
|
-
declare function configFileName(index: number, id: string): string;
|
|
235
|
-
/**
|
|
236
|
-
* 条件判定的键集合:与 `engine/anchor-match.mjs` 的匹配语义同构。
|
|
237
|
-
* 键按字面文本匹配(正则元字符会被转义);要写正则须用 `/pattern/flags` 形态或 `useRegex: true`。
|
|
238
|
-
*/
|
|
239
|
-
interface PromptConfigMatch {
|
|
240
|
-
keys?: string[];
|
|
241
|
-
secondaryKeys?: string[];
|
|
242
|
-
logic?: 'any' | 'all' | 'not' | 'notAny';
|
|
243
|
-
caseSensitive?: boolean;
|
|
244
|
-
wholeWords?: boolean;
|
|
245
|
-
useRegex?: boolean;
|
|
246
|
-
}
|
|
247
|
-
//#endregion
|
|
248
|
-
//#region src/host/write-preset.d.ts
|
|
249
|
-
interface WriteModuleOptions {
|
|
250
|
-
modulesRoot: string;
|
|
251
|
-
moduleId: string;
|
|
252
|
-
targetModuleId?: string;
|
|
253
|
-
sourceDir?: string;
|
|
254
|
-
/** 返回独立暂存根下的合法模块目录;安装方负责交换与清理暂存根。 */
|
|
255
|
-
stageOnly?: boolean;
|
|
256
|
-
agentsInstructionText?: string;
|
|
257
|
-
warn?: (message: string) => void;
|
|
258
|
-
}
|
|
259
|
-
/** 旧入口只做名称适配;行为规则和参数必须已写入完整定义。 */
|
|
260
|
-
interface WritePresetOptions extends ModuleWriterParams {
|
|
261
|
-
moduleDir: string;
|
|
262
|
-
presetTemplate?: string;
|
|
263
|
-
outputId?: string;
|
|
264
|
-
sourceDir?: string;
|
|
265
|
-
materializeOnly?: boolean;
|
|
266
|
-
agentsInstructionText?: string;
|
|
267
|
-
presetOrder?: number;
|
|
268
|
-
promptConfigs?: PromptConfigSpec[];
|
|
269
|
-
warn?: (message: string) => void;
|
|
270
|
-
}
|
|
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;旧字段仅在此边界适配。 */
|
|
281
|
-
declare function writePreset(prompt: string, options: WritePresetOptions): string;
|
|
282
|
-
//#endregion
|
|
283
|
-
//#region src/host/agents-cards.d.ts
|
|
284
|
-
/** 文件身份(fileId + 路径 + 展示路径):生成卡与读取快照共用的最小形状。 */
|
|
285
|
-
interface AgentsFileIdentity {
|
|
286
|
-
/** 稳定文件 id(规范化真实路径哈希;bridge 写白名单与卡 id 共用)。 */
|
|
287
|
-
fileId: string;
|
|
288
|
-
/** 探测到的路径(普通文件;符号链接在 realPath 解析)。 */
|
|
289
|
-
path: string;
|
|
290
|
-
displayPath: string;
|
|
291
|
-
scope: 'global' | 'project';
|
|
292
|
-
}
|
|
293
|
-
interface AgentsFileCard extends AgentsFileIdentity {
|
|
294
|
-
/** 解析后的真实路径:同一实际文件去重与身份校验用。 */
|
|
295
|
-
realPath: string;
|
|
296
|
-
}
|
|
297
|
-
declare function agentsFileId(path: string): string;
|
|
298
|
-
/**
|
|
299
|
-
* 探测当前可见的 AGENTS 指令文件:用户级 `$DSH_HOME/AGENTS.md` + cwd→项目根链的全部候选。
|
|
300
|
-
* 只返回已存在的文件——探测不到就不生成卡。
|
|
301
|
-
*/
|
|
302
|
-
declare function detectAgentsFiles(options?: {
|
|
303
|
-
cwd?: string;
|
|
304
|
-
home?: string;
|
|
305
|
-
projects?: boolean;
|
|
306
|
-
}): AgentsFileCard[];
|
|
307
|
-
/**
|
|
308
|
-
* 探测结果 → pre-step 提示卡(每个文件一张,不落 preset.yml)。
|
|
309
|
-
* 插入点对齐官方 `@deepseek-ai/dsh-agent-instructions`:pre-step 层、紧随真实用户消息;
|
|
310
|
-
* 注入内容 = 该文件当前正文(`fill=instruction-file` 运行时读取,params.file 精确到单个文件)。
|
|
311
|
-
*/
|
|
312
|
-
declare function agentsFileCardSpecs(files?: readonly AgentsFileIdentity[]): PromptConfigSpec[];
|
|
313
|
-
/**
|
|
314
|
-
* 单次读取形成一致快照:正文、revision、身份、读取状态来自同一次读取。
|
|
315
|
-
* 只支持可正确解码的 UTF-8;有 BOM 的文件保留 BOM 字符,不让无关保存悄悄改写字节。
|
|
316
|
-
*/
|
|
317
|
-
declare function readAgentsFileSnapshot(file: AgentsFileCard): InstructionFileSnapshot;
|
|
318
|
-
/** 探测 + 读取:同一套探测规则下每个文件一份快照。 */
|
|
319
|
-
declare function detectAgentsFileSnapshots(options?: {
|
|
320
|
-
cwd?: string;
|
|
321
|
-
home?: string;
|
|
322
|
-
projects?: boolean;
|
|
323
|
-
}): InstructionFileSnapshot[];
|
|
324
|
-
type AgentsFileWriteOutcome = {
|
|
325
|
-
ok: true;
|
|
326
|
-
fileId: string;
|
|
327
|
-
revision: string;
|
|
328
|
-
} | {
|
|
329
|
-
ok: false;
|
|
330
|
-
status: 400 | 404 | 409 | 413;
|
|
331
|
-
code: string;
|
|
332
|
-
message: string;
|
|
333
|
-
};
|
|
334
|
-
/** 原子写指令文件(tmp + rename);调用方必须先用 detectAgentsFiles() 校验路径白名单。 */
|
|
335
|
-
declare function writeAgentsFile(path: string, content: string): void;
|
|
336
|
-
/**
|
|
337
|
-
* 带版本校验的单文件写:
|
|
338
|
-
* 1. 写前在同一段内重读文件,expectedRevision 不一致 = 409(不做「猜到用户意图」的重试);
|
|
339
|
-
* 2. 目标消失 = 404,不自动重建用户文件;
|
|
340
|
-
* 3. 正文超限 = 413,不截断保存;
|
|
341
|
-
* 4. 替换前复查目标身份(真实路径未变),失败保留原文件并清理临时文件。
|
|
342
|
-
*/
|
|
343
|
-
declare function writeAgentsFileChecked(options: {
|
|
344
|
-
file: AgentsFileCard;
|
|
345
|
-
content: string;
|
|
346
|
-
expectedRevision: string | null;
|
|
347
|
-
}): Promise<AgentsFileWriteOutcome>;
|
|
348
|
-
//#endregion
|
|
349
|
-
//#region src/runtime/pre-step-coordinator.d.ts
|
|
350
|
-
declare const PRE_STEP_COORDINATOR_SERVICE = "promptToolPreStep";
|
|
351
|
-
declare const PRE_STEP_COORDINATOR_VERSION = 1;
|
|
352
|
-
interface PreStepPromptConfig {
|
|
353
|
-
id: string;
|
|
354
|
-
layer: string;
|
|
355
|
-
enabled?: boolean;
|
|
356
|
-
order: number;
|
|
357
|
-
sequence?: number;
|
|
358
|
-
sourceModuleId?: string;
|
|
359
|
-
position: string;
|
|
360
|
-
promotion: string;
|
|
361
|
-
audience: string | null;
|
|
362
|
-
modelScope: string;
|
|
363
|
-
role: string;
|
|
364
|
-
dedupe: string;
|
|
365
|
-
mergeMode: string;
|
|
366
|
-
sourceKind: string;
|
|
367
|
-
form?: string;
|
|
368
|
-
texts: string[];
|
|
369
|
-
params: Record<string, unknown>;
|
|
370
|
-
variables: Record<string, unknown>;
|
|
371
|
-
identity: {
|
|
372
|
-
field: 'plugin';
|
|
373
|
-
value: string;
|
|
374
|
-
};
|
|
375
|
-
resolve: (input: Record<string, unknown>) => unknown;
|
|
376
|
-
}
|
|
377
|
-
interface PreStepSource {
|
|
378
|
-
configs: readonly PreStepPromptConfig[];
|
|
379
|
-
/** 已编译的本地点规则动作;执行与配置叶子共享同一批次资格帧。 */
|
|
380
|
-
ruleActions?: readonly unknown[];
|
|
381
|
-
officialInstructions?: boolean;
|
|
382
|
-
}
|
|
383
|
-
interface PreStepCoordinatorOptions {
|
|
384
|
-
policyFile?: string;
|
|
385
|
-
home?: string;
|
|
386
|
-
}
|
|
387
|
-
interface PreStepCoordinatorService {
|
|
388
|
-
readonly version: number;
|
|
389
|
-
registerPreset(sourceCtx: Context, sourceId: string, source: PreStepSource): () => void;
|
|
390
|
-
officialOwnerOf(sessionId: string): boolean | undefined;
|
|
391
|
-
/** hint 转换前也调用同一过滤器,保证监听器重挂顺序不让已关闭正文变成 hint。 */
|
|
392
|
-
filterInstructions(agent: unknown, messages: unknown[]): unknown[];
|
|
393
|
-
}
|
|
394
|
-
declare function installPreStepCoordinator(ctx: Context, options?: PreStepCoordinatorOptions): PreStepCoordinatorService;
|
|
395
|
-
//#endregion
|
|
396
|
-
//#region src/runtime/models.d.ts
|
|
397
|
-
/**
|
|
398
|
-
* 官方子代理 seam 的类型锚点:本插件只读 `list()` / `getProvider()` 并显式传参,
|
|
399
|
-
* 不替换 {@link SubagentRuntime.start} 或 `startContinuable`;这里保留类型引用是为了
|
|
400
|
-
* 让「不碰 registry 方法」这条边界在类型层随 rc.2 契约一起编译校验。
|
|
401
|
-
*/
|
|
402
|
-
type PluginSubagentSeam = Pick<SubagentRuntime, 'list' | 'getProvider'>;
|
|
403
|
-
/** 模型服务商检测结果(含诊断信息,供 Web/TUI 展示)。 */
|
|
404
|
-
interface ModelDetection {
|
|
405
|
-
/** 是否检测到任何已注册/可配置的服务商路由。 */
|
|
406
|
-
available: boolean;
|
|
407
|
-
/** 已检测到(live 注册)的模型服务商 id——状态提示用。 */
|
|
408
|
-
providers: string[];
|
|
409
|
-
error?: string;
|
|
410
|
-
}
|
|
411
|
-
/** 检测模型服务商:只统计 live 注册路由(状态提示与下拉共用同一来源)。 */
|
|
412
|
-
declare function detectModels(ctx: Context): ModelDetection;
|
|
413
|
-
/**
|
|
414
|
-
* 目录失效:provider 注册/移除(官方 `llm/adapters-updated`)、服务重挂或显式刷新时
|
|
415
|
-
* 调用。代次前进让已在飞的旧查询回来后不再写缓存(M-11:变更必须让相关缓存失效)。
|
|
416
|
-
* 只清目录,不碰 provider 单点失败的既有语义。
|
|
417
|
-
*/
|
|
418
|
-
declare function invalidateModelCatalog(ctx: Context): void;
|
|
419
|
-
/** 同步读模型目录缓存(命中返回,未命中/过期返回空):/describe 不触发查询。 */
|
|
420
|
-
declare function peekModelCatalog(ctx: Context): Record<string, string[]>;
|
|
421
|
-
/**
|
|
422
|
-
* 查询各已注册服务商公布的模型 id(对齐官方 web 选择器 buildModelCatalog:只遍历
|
|
423
|
-
* listProviders() live 路由,单点失败/超时不拖垮整体;仅作展示,不构成路由白名单)。
|
|
424
|
-
* 并行查询 + 10min 缓存 + 单点超时;同 Context 的并发刷新合并为一次查询,
|
|
425
|
-
* 失败只影响该次刷新(不写空缓存),旧代次结果不回写新数据。
|
|
426
|
-
*/
|
|
427
|
-
declare function listAdvertisedModels(ctx: Context): Promise<Record<string, string[]>>;
|
|
428
|
-
/**
|
|
429
|
-
* 本插件子代理入口的显式模型路由(subagentModelProvider + subagentModelName 同时非空时生效)。
|
|
430
|
-
*
|
|
431
|
-
* 只产出要传给 {@link SubagentRuntime.start} 的 `agentOptions`,由调用方显式传入;
|
|
432
|
-
* 不修改 registry 上的 `start` / `startContinuable` 方法,也不在根 scope 强加默认值——
|
|
433
|
-
* 官方 API 的替换会让第三方直派调用也带上本插件的模型,超出插件授权范围。
|
|
434
|
-
*/
|
|
435
|
-
declare function resolveSubagentStartOptions(isEnabled: () => boolean, provider: () => string, model: () => string, getReasoningEffort?: () => string): AgentOptions | undefined;
|
|
436
|
-
//#endregion
|
|
437
|
-
//#region src/host/skills-actions.d.ts
|
|
438
|
-
type SkillActionResult = {
|
|
439
|
-
ok: true;
|
|
440
|
-
id: string;
|
|
441
|
-
path: string;
|
|
442
|
-
} | {
|
|
443
|
-
ok: false;
|
|
444
|
-
message: string;
|
|
445
|
-
};
|
|
446
|
-
//#endregion
|
|
447
|
-
//#region src/host/skills-policy.d.ts
|
|
448
|
-
type SkillPolicyRead = {
|
|
449
|
-
ok: true;
|
|
450
|
-
invocation: SkillInvocation;
|
|
451
|
-
frontmatter?: string;
|
|
452
|
-
body?: string;
|
|
453
|
-
} | {
|
|
454
|
-
ok: false;
|
|
455
|
-
message: string;
|
|
456
|
-
};
|
|
457
|
-
type SkillPolicyWrite = {
|
|
458
|
-
ok: true;
|
|
459
|
-
changed: boolean;
|
|
460
|
-
invocation: SkillInvocation;
|
|
461
|
-
} | {
|
|
462
|
-
ok: false;
|
|
463
|
-
message: string;
|
|
464
|
-
};
|
|
465
|
-
/** 读取技能文件当前的调用策略(缺省即可调用)。 */
|
|
466
|
-
declare function readSkillInvocation(file: string): SkillPolicyRead;
|
|
467
|
-
/** 把技能文件的调用策略写到目标范围;返回是否发生写入。 */
|
|
468
|
-
declare function setSkillInvocation(file: string, change: SkillPolicyChange | SkillPolicyScope): SkillPolicyWrite;
|
|
469
|
-
//#endregion
|
|
470
|
-
//#region src/host/skills-content.d.ts
|
|
471
|
-
type SkillContentResult = ({
|
|
472
|
-
ok: true;
|
|
473
|
-
changed?: boolean;
|
|
474
|
-
} & SkillContentSnapshot) | {
|
|
475
|
-
ok: false;
|
|
476
|
-
message: string;
|
|
477
|
-
};
|
|
478
|
-
//#endregion
|
|
479
|
-
//#region src/host/skills-config.d.ts
|
|
480
|
-
/** 与官方 `SKILL_NAME` 同规则;技能目录名、引用校验与调用策略写入共用。 */
|
|
481
|
-
declare const SKILL_NAME_PATTERN: RegExp;
|
|
482
|
-
type SkillsStateRead = {
|
|
483
|
-
ok: true;
|
|
484
|
-
state: SkillsState;
|
|
485
|
-
exists: boolean;
|
|
486
|
-
} | {
|
|
487
|
-
ok: false;
|
|
488
|
-
state: SkillsState;
|
|
489
|
-
message: string;
|
|
490
|
-
};
|
|
491
|
-
declare function skillsStatePath(dshHome?: string): string;
|
|
492
|
-
declare function readSkillsState(file?: string): SkillsStateRead;
|
|
493
|
-
/** 写状态:Document API 保留注释与未知字段;内容无变化时不落盘;提交前核对本次读取的原文,失败清理暂存文件。 */
|
|
494
|
-
declare function writeSkillsState(patch: Partial<Pick<SkillsState, 'folders'>>, file?: string): SkillsStateRead;
|
|
495
|
-
//#endregion
|
|
496
|
-
//#region src/runtime/settings-bridge.d.ts
|
|
497
|
-
interface SkillsBridgeState {
|
|
498
|
-
/** 用户技能根(技能实体的落点)。 */
|
|
499
|
-
skillsRoot: string;
|
|
500
|
-
/** 用户添加的技能文件夹(只引用,不复制)。 */
|
|
501
|
-
folders: string[];
|
|
502
|
-
/** 技能清单:按会话工作区扫描官方六类技能根,调用策略取自各技能文件的 frontmatter。 */
|
|
503
|
-
listSkills: (cwd?: string) => SkillCatalogEntry[];
|
|
504
|
-
snapshot?: (options: SkillViewOptions) => Promise<SkillsCatalogSnapshot>;
|
|
505
|
-
/** 单端写入只提交本端意图;路径必须命中当前来源白名单。 */
|
|
506
|
-
setSkillPolicy: (name: string, path: string, change: SkillPolicyChange, cwd?: string) => SkillPolicyWrite;
|
|
507
|
-
readSkillContent: (name: string, path: string, cwd?: string) => SkillContentResult;
|
|
508
|
-
writeSkillContent: (name: string, path: string, content: string, description: string, expectedRevision: string, cwd?: string) => SkillContentResult;
|
|
509
|
-
deleteSkill: (name: string, path: string, cwd?: string) => SkillActionResult;
|
|
510
|
-
/** 添加 / 移除引用的技能文件夹。 */
|
|
511
|
-
patchSkillFolders: (folders: string[]) => SkillsStateRead | Promise<SkillsStateRead>;
|
|
512
|
-
}
|
|
513
|
-
/**
|
|
514
|
-
* 两类卡合并:模块卡原样保留,文件卡换成本次工作区的文件快照。
|
|
515
|
-
* 生成目录里属于其他工作区的文件卡不再展示(写盘白名单也不含它们);
|
|
516
|
-
* 当前工作区里没有对应生成卡的文件按默认文件卡补齐。
|
|
517
|
-
*/
|
|
518
|
-
declare function mergeInstructionCards(moduleCards: readonly unknown[], files: readonly InstructionFileSnapshot[]): unknown[];
|
|
519
|
-
/** 自建 loopback settings bridge:替代 registerConfigurableProviders,避免模型设置区出现插件条目。 */
|
|
520
|
-
declare function registerSettingsBridge(ctx: Context, ns: string, getModelsState: () => ModelDetection, getSkillsState: () => SkillsBridgeState, _getEngineStrategyDir: () => string, afterSkillsChange?: () => void,
|
|
521
|
-
/**
|
|
522
|
-
* 生成目录(模块目录):读取/写入哪一份提示词配置。
|
|
523
|
-
*
|
|
524
|
-
* 参数是**请求声明的编辑目标**(`x-module-id` 头解析而来):给了就定位那个模块,
|
|
525
|
-
* 没给则由 host 回退启用表首项。编辑器因此不必依赖某个全局单选——配置卡自己的
|
|
526
|
-
* 模块身份决定写哪里。
|
|
527
|
-
*/
|
|
528
|
-
getModuleDirectory?: (moduleId?: string) => string,
|
|
529
|
-
/** 内容导入完成回调:批量 scope 只触发一次重建(更新运行时文本并重建模块)。 */
|
|
530
|
-
afterModuleContentImport?: (scopes: Array<'preset' | 'agents'>, moduleId?: string) => void | Promise<void>,
|
|
531
|
-
/** 参数写入后重建指定模块;省略身份表示启用表变化,刷新全部运行实例。 */
|
|
532
|
-
afterOverridesChange?: (moduleId?: string) => void | Promise<void>,
|
|
533
|
-
/** 模块已完整安装后的刷新回调;失败返回未生效诊断,不再物化或撤销安装。 */
|
|
534
|
-
afterModulePackageImport?: (id: string) => void | Promise<void>,
|
|
535
|
-
/** 能力/recipe 提交后刷新回调;失败保留已提交定义并明确报告。 */
|
|
536
|
-
afterCapabilityChange?: (moduleId?: string) => void | Promise<void>,
|
|
537
|
-
/** 新建、复制或删除模块后重建当前模块。 */
|
|
538
|
-
afterModuleListChange?: (id: string) => void | Promise<void>): {
|
|
539
|
-
invalidateDescriptor: () => void;
|
|
540
|
-
};
|
|
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
|
|
550
|
-
//#region src/host/worldbook.d.ts
|
|
551
|
-
type WorldBookEntry = Record<string, unknown>;
|
|
552
|
-
/** buildWorldBookEntry 输入(两通道共用:ST 导入转换与模型 world_book_upsert 工具)。 */
|
|
553
|
-
interface WorldBookEntryInput {
|
|
554
|
-
/** 条目 id;缺省不写(调用方自行加前缀时用,如角色卡 chara-<卡>- 前缀)。 */
|
|
555
|
-
id?: string;
|
|
556
|
-
name: string;
|
|
557
|
-
text: string;
|
|
558
|
-
/** 注入顺序(层内升序);缺省 100。 */
|
|
559
|
-
order?: number;
|
|
560
|
-
/** 启用状态;缺省不写(引擎默认启用)。 */
|
|
561
|
-
enabled?: boolean;
|
|
562
|
-
/** 常驻注入(不依赖关键字)。 */
|
|
563
|
-
constant: boolean;
|
|
564
|
-
keys?: string[];
|
|
565
|
-
secondaryKeys?: string[];
|
|
566
|
-
caseSensitive?: boolean;
|
|
567
|
-
wholeWords?: boolean;
|
|
568
|
-
/** ST selectiveLogic(0/1/2/3 → anchor-match any/all/not/notAny)。 */
|
|
569
|
-
selectiveLogic?: number;
|
|
570
|
-
}
|
|
571
|
-
/**
|
|
572
|
-
* 世界书条目结构工厂(能力归一)。
|
|
573
|
-
* strategy/layer/position 固定值与 params 键集单一权威——ST 导入(sillytavern.ts)
|
|
574
|
-
* 与模型工具(world_book_upsert)共用,不再各自手写条目结构。
|
|
575
|
-
*/
|
|
576
|
-
declare function buildWorldBookEntry(input: WorldBookEntryInput): WorldBookEntry;
|
|
577
|
-
/** 当前模块全部世界书条目(保持文件顺序)。 */
|
|
578
|
-
declare function listWorldBookEntries(moduleDir: string): WorldBookEntry[];
|
|
579
|
-
/** 新增或更新一条世界书条目(按 id 定位;不存在则追加)。返回写入后条目总数。 */
|
|
580
|
-
declare function upsertWorldBookEntry(moduleDir: string, entry: WorldBookEntry): number;
|
|
581
|
-
/** 删除一条世界书条目;不存在抛错。返回删除后条目总数。 */
|
|
582
|
-
declare function deleteWorldBookEntry(moduleDir: string, id: string): number;
|
|
583
|
-
//#endregion
|
|
584
|
-
//#region src/web-surface.d.ts
|
|
585
|
-
/** 从 loader 根 Include 的 baseUrl 推导 profile 目录。 */
|
|
586
|
-
declare function resolveProfileDir(ctx: Context): string | undefined;
|
|
587
|
-
/** 只读诊断;安装与 profile 变更交给官方 plugin_manager。 */
|
|
588
|
-
declare function ensureWebSurface(ctx: Context, warn: (message: string) => void): void;
|
|
589
|
-
/**
|
|
590
|
-
* 延迟到本轮装配结束后诊断;插件卸载取消尚未执行的任务。
|
|
591
|
-
*/
|
|
592
|
-
declare function scheduleWebSurfaceRepair(ctx: Context, warn: (message: string) => void): void;
|
|
593
|
-
//#endregion
|
|
594
|
-
//#region src/host/skills-import.d.ts
|
|
595
|
-
interface SkillsImportFile {
|
|
596
|
-
path?: unknown;
|
|
597
|
-
content?: unknown;
|
|
598
|
-
}
|
|
599
|
-
type SkillsImportResult = {
|
|
600
|
-
ok: true;
|
|
601
|
-
path: string;
|
|
602
|
-
count: number;
|
|
603
|
-
overwritten: number;
|
|
604
|
-
warning?: string;
|
|
605
|
-
} | {
|
|
606
|
-
ok: false;
|
|
607
|
-
message: string;
|
|
608
|
-
code?: 'skills-overwrite-required';
|
|
609
|
-
conflicts?: string[];
|
|
610
|
-
};
|
|
611
|
-
/** 浏览器上传:base64 文件列表;单技能包(无顶层目录)按 frontmatter.name 归类。 */
|
|
612
|
-
declare function importSkillsPackage(root: string, files: SkillsImportFile[], overwrite?: readonly string[]): SkillsImportResult;
|
|
613
|
-
//#endregion
|
|
614
|
-
//#region src/host/module-tool-target.d.ts
|
|
615
|
-
interface ModuleToolTarget {
|
|
616
|
-
id: string;
|
|
617
|
-
root: string;
|
|
618
|
-
dir: string;
|
|
619
|
-
}
|
|
620
|
-
interface ModuleToolHost {
|
|
621
|
-
target: (exec: ToolExecution) => ModuleToolTarget;
|
|
622
|
-
rebuild: (id: string) => Promise<void>;
|
|
40
|
+
/** 分支条件;缺省 = 无条件。 */
|
|
41
|
+
if?: RuleCondition;
|
|
42
|
+
/** 动作列表。 */
|
|
43
|
+
then: RuleAction[];
|
|
44
|
+
/** `if` 不命中时执行;与 `then` 结构互斥(编译期按 `not(if)` 展开)。 */
|
|
45
|
+
else?: RuleAction[];
|
|
623
46
|
}
|
|
624
47
|
//#endregion
|
|
625
|
-
//#region src/runtime/character-tools.d.ts
|
|
626
|
-
declare function registerCharacterTools(ctx: Context, host: ModuleToolHost): () => void;
|
|
627
|
-
//#endregion
|
|
628
|
-
//#region src/runtime/world-book-tools.d.ts
|
|
629
|
-
/** 注册世界书条目级模型工具;返回 disposer,随 world-book-tools 模块生命周期清理。 */
|
|
630
|
-
declare function registerWorldBookTools(ctx: Context, host: ModuleToolHost): () => void;
|
|
631
|
-
//#endregion
|
|
632
|
-
//#region src/host/characters.d.ts
|
|
633
|
-
/** 模块记忆与条目同归当前模块;来源和 id 前缀不改变位置。 */
|
|
634
|
-
declare function appendModuleMemory(moduleDir: string, note: string): void;
|
|
635
|
-
/** 每次显式读取最新字节;缺失为空,链接与读取失败原样报错。 */
|
|
636
|
-
declare function readModuleMemory(moduleDir: string): string;
|
|
637
|
-
type CharacterImportOptions = StConversionOptions & ImportChoices;
|
|
638
|
-
type CharacterImportResult = {
|
|
639
|
-
ok: true;
|
|
640
|
-
id: string;
|
|
641
|
-
name: string;
|
|
642
|
-
warning?: string;
|
|
643
|
-
} | {
|
|
644
|
-
ok: false;
|
|
645
|
-
message: string;
|
|
646
|
-
};
|
|
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): {
|
|
652
|
-
ok: true;
|
|
653
|
-
count: number;
|
|
654
|
-
personaOpened?: boolean;
|
|
655
|
-
} | {
|
|
656
|
-
ok: false;
|
|
657
|
-
message: string;
|
|
658
|
-
};
|
|
659
|
-
/** 撤销并入内容;旧 chara 前缀可撤销,能力归属只写一份登记。 */
|
|
660
|
-
declare function removeMergedModule(root: string, targetId: string, sourceId: string): {
|
|
661
|
-
ok: true;
|
|
662
|
-
count: number;
|
|
663
|
-
} | {
|
|
664
|
-
ok: false;
|
|
665
|
-
message: string;
|
|
666
|
-
};
|
|
667
|
-
//#endregion
|
|
668
48
|
//#region src/host/templates.d.ts
|
|
669
49
|
interface PromptConfigTemplate {
|
|
670
50
|
/** 模板文件名(数字前缀决定展示顺序)。 */
|
|
@@ -674,133 +54,28 @@ interface PromptConfigTemplate {
|
|
|
674
54
|
/** 解析后的单条提示词配置。 */
|
|
675
55
|
spec: RuleDefinition;
|
|
676
56
|
}
|
|
677
|
-
/** 自定义工具模板(templates/tools/*.yml;tool-config-engine 定义形态)。 */
|
|
678
|
-
interface ToolTemplate {
|
|
679
|
-
file: string;
|
|
680
|
-
content: string;
|
|
681
|
-
/** 解析后的工具定义(含 id/name/execute.kind)。 */
|
|
682
|
-
spec: Record<string, unknown>;
|
|
683
|
-
}
|
|
684
57
|
/** 扫描包内 templates/*.yml,按文件名排序返回(文件损坏时抛出,由调用方决定呈现)。 */
|
|
685
58
|
declare function loadPromptTemplates(): PromptConfigTemplate[];
|
|
686
|
-
/** 工具模板库扫描(templates/tools/*.yml;损坏 fail loud——包内模板属于发布 bug)。 */
|
|
687
|
-
declare function loadToolTemplates(): ToolTemplate[];
|
|
688
|
-
//#endregion
|
|
689
|
-
//#region src/runtime/tui.d.ts
|
|
690
|
-
type TuiSource = PromptSettings & {
|
|
691
|
-
skillCatalog: SkillCatalogEntry[];
|
|
692
|
-
activeSkillsDirs: string[];
|
|
693
|
-
};
|
|
694
|
-
/** 参数保存回调:写激活模块 module.yml;失败必须抛给命令层渲染为错误。 */
|
|
695
|
-
type SaveModuleParam = (key: string, value: unknown) => void | Promise<void>;
|
|
696
|
-
/** 技能启停回调:切换受管实体的根链接。 */
|
|
697
|
-
type ToggleSkillState = (folder: string, enabled: boolean) => {
|
|
698
|
-
ok: boolean;
|
|
699
|
-
message?: string;
|
|
700
|
-
};
|
|
701
|
-
/** 通过 DSH 命令注册表暴露 /prompt-tool,Web 与 dsh-tui 都能执行。 */
|
|
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;
|
|
703
|
-
//#endregion
|
|
704
|
-
//#region src/host/skills-refresh.d.ts
|
|
705
|
-
interface SkillsReloaderDeps {
|
|
706
|
-
stateFile: string;
|
|
707
|
-
currentSnapshot: () => string;
|
|
708
|
-
accept: (state: SkillsState, snapshot: string) => void;
|
|
709
|
-
warn: (message: string) => void;
|
|
710
|
-
}
|
|
711
|
-
declare function createSkillsReloader(deps: SkillsReloaderDeps): {
|
|
712
|
-
reload: () => void;
|
|
713
|
-
};
|
|
714
|
-
//#endregion
|
|
715
|
-
//#region src/host/skills-runtime.d.ts
|
|
716
|
-
interface SkillsRuntime {
|
|
717
|
-
readonly skillsRoot: string;
|
|
718
|
-
readonly folders: string[];
|
|
719
|
-
listSkills: (cwd?: string) => SkillCatalogEntry[];
|
|
720
|
-
snapshot: (options?: SkillViewOptions) => Promise<SkillsCatalogSnapshot>;
|
|
721
|
-
setPolicy: (name: string, path: string, change: SkillPolicyChange, cwd?: string) => SkillPolicyWrite;
|
|
722
|
-
readContent: (name: string, path: string, cwd?: string) => SkillContentResult;
|
|
723
|
-
writeContent: (name: string, path: string, content: string, description: string, expectedRevision: string, cwd?: string) => SkillContentResult;
|
|
724
|
-
deleteSkill: (name: string, path: string, cwd?: string) => SkillActionResult;
|
|
725
|
-
setFolders: (folders: string[]) => SkillsStateRead;
|
|
726
|
-
invalidate: () => void;
|
|
727
|
-
}
|
|
728
|
-
declare function createSkillsRuntime(ctx: Context, options?: {
|
|
729
|
-
dshHome?: string;
|
|
730
|
-
}): SkillsRuntime;
|
|
731
|
-
//#endregion
|
|
732
|
-
//#region src/host/skills-scan.d.ts
|
|
733
|
-
interface ScanRoot {
|
|
734
|
-
kind: SkillSourceKind;
|
|
735
|
-
path: string;
|
|
736
|
-
}
|
|
737
|
-
interface ScannedSkill {
|
|
738
|
-
id: string;
|
|
739
|
-
source: SkillSourceKind;
|
|
740
|
-
rank: number;
|
|
741
|
-
dir: string;
|
|
742
|
-
folder: string;
|
|
743
|
-
file: string;
|
|
744
|
-
name: string;
|
|
745
|
-
description: string;
|
|
746
|
-
whenToUse?: string;
|
|
747
|
-
metadata?: Record<string, unknown>;
|
|
748
|
-
body: string;
|
|
749
|
-
valid: boolean;
|
|
750
|
-
issue?: string;
|
|
751
|
-
modelInvocable: boolean;
|
|
752
|
-
userInvocable: boolean;
|
|
753
|
-
}
|
|
754
|
-
declare function resolveProjectRoot(cwd: string): string;
|
|
755
|
-
declare function skillRoots(options: {
|
|
756
|
-
cwd?: string;
|
|
757
|
-
dshHome: string;
|
|
758
|
-
folders: readonly string[];
|
|
759
|
-
}): ScanRoot[];
|
|
760
|
-
/** 只扫描普通目录包和直属 Markdown 文件;链接技能由 registry 补充为只读条目。 */
|
|
761
|
-
declare function scanRoot(root: ScanRoot): ScannedSkill[];
|
|
762
|
-
declare function scanRoots(roots: readonly ScanRoot[]): ScannedSkill[];
|
|
763
|
-
declare function catalogFromScan(skills: readonly ScannedSkill[]): SkillCatalogEntry[];
|
|
764
59
|
//#endregion
|
|
765
|
-
//#region src/host/module
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
declare function assertModuleTree(dir: string): void;
|
|
774
|
-
//#endregion
|
|
775
|
-
//#region src/runtime/skills-parse.d.ts
|
|
776
|
-
interface SkillFrontmatter {
|
|
777
|
-
name?: string;
|
|
778
|
-
description?: string;
|
|
779
|
-
whenToUse?: string;
|
|
780
|
-
metadata?: Record<string, unknown>;
|
|
781
|
-
/** 官方调用策略:true 时模型不可发现/不可加载(默认 false = 可调用)。 */
|
|
782
|
-
disableModelInvocation?: boolean;
|
|
783
|
-
/** 官方调用策略:false 时用户命令不可加载(默认 true)。 */
|
|
784
|
-
userInvocable?: boolean;
|
|
60
|
+
//#region src/host/write-module.d.ts
|
|
61
|
+
interface WriteModuleOptions {
|
|
62
|
+
modulesRoot: string;
|
|
63
|
+
moduleId: string;
|
|
64
|
+
targetModuleId?: string;
|
|
65
|
+
sourceDir?: string;
|
|
66
|
+
agentsInstructionText?: string;
|
|
67
|
+
warn?: (message: string) => void;
|
|
785
68
|
}
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
body: string;
|
|
789
|
-
issue?: string;
|
|
790
|
-
};
|
|
69
|
+
/** 已有同一模块只恢复切片;导入/复制先完整生成合法身份候选,再交换目标。 */
|
|
70
|
+
declare function writeModule(options: WriteModuleOptions): string;
|
|
791
71
|
//#endregion
|
|
792
|
-
//#region src/
|
|
793
|
-
/**
|
|
794
|
-
|
|
795
|
-
*
|
|
796
|
-
* 内置模块随包分发在仓库根的 `modules/`。旧的内置预设 `pt-*` 已整体退场——它们是官方
|
|
797
|
-
* 预设形态的遗留,重构后不再读取也不再维护;这里指向当前随包分发的内置模块作为兜底。
|
|
798
|
-
*/
|
|
799
|
-
declare const DEFAULT_MODULE_ID = "ponytail";
|
|
72
|
+
//#region src/host/module-dirs.d.ts
|
|
73
|
+
/** 模块根:本插件的存储根(~/.dsh/.prompt-tool),导入/新建/种子化的模块都放这里。 */
|
|
74
|
+
declare function userModulesDir(): string;
|
|
800
75
|
//#endregion
|
|
801
76
|
//#region src/index.d.ts
|
|
802
77
|
declare const name = "prompt-tool";
|
|
803
78
|
declare const inject: string[];
|
|
804
79
|
declare function apply(ctx: Context, configIn: Config): void;
|
|
805
80
|
//#endregion
|
|
806
|
-
export {
|
|
81
|
+
export { Config, apply, inject, loadPromptTemplates, name, userModulesDir, writeModule };
|