feat: 支持添加默认提示词(兼容块)

- prompt-profiles.js: 新增 createLegacyPromptBlock 导出
- panel.js: 新增 add-legacy-block 处理逻辑
- 工具栏新增 '+ 默认提示词' 按钮
This commit is contained in:
Youzini-afk
2026-03-25 22:37:47 +08:00
parent 4543900d68
commit 00486b88dc
2 changed files with 30 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ import {
cloneTaskProfile,
createBuiltinPromptBlock,
createCustomPromptBlock,
createLegacyPromptBlock,
createLocalRegexRule,
ensureTaskProfiles,
exportTaskProfile as serializeTaskProfile,
@@ -1680,6 +1681,15 @@ async function _handleTaskProfileWorkspaceClick(event) {
return { selectBlockId: nextBlock.id };
});
return;
case "add-legacy-block":
_updateCurrentTaskProfile((draft, context) => {
const nextBlock = createLegacyPromptBlock(context.taskType, {
order: draft.blocks.length,
});
draft.blocks.push(nextBlock);
return { selectBlockId: nextBlock.id };
});
return;
case "add-builtin-block": {
const select = document.getElementById("bme-task-builtin-select");
const sourceKey = String(select?.value || "").trim();
@@ -1947,6 +1957,9 @@ function _renderTaskPromptTab(state) {
<button class="bme-config-secondary-btn" data-task-action="add-custom-block" type="button">
+ 自定义块
</button>
<button class="bme-config-secondary-btn" data-task-action="add-legacy-block" type="button">
+ 默认提示词
</button>
<span class="bme-task-action-sep"></span>
<select id="bme-task-builtin-select" class="bme-config-input bme-task-builtin-select">
${state.builtinBlockDefinitions

View File

@@ -363,6 +363,23 @@ export function createBuiltinPromptBlock(taskType, sourceKey = "", overrides = {
});
}
export function createLegacyPromptBlock(taskType, overrides = {}) {
const legacyField = LEGACY_PROMPT_FIELD_MAP[taskType] || "";
return normalizePromptBlock(taskType, {
id: createPromptBlockId(taskType),
name: "默认提示词",
type: "legacyPrompt",
enabled: true,
role: "system",
sourceKey: "",
sourceField: legacyField,
content: "",
injectionMode: "append",
order: 0,
...overrides,
});
}
export function createLocalRegexRule(taskType, overrides = {}) {
return normalizeRegexLocalRule(
{