From 4fb45b4ce2bdb7bfd86af139e14a318af7b04bba Mon Sep 17 00:00:00 2001 From: Youzini-afk <13153778771cx@gmail.com> Date: Tue, 7 Apr 2026 01:43:08 +0800 Subject: [PATCH] Clarify regex preview stage vs semantics --- panel.js | 6 ++++++ task-regex.js | 10 +++++++++- tests/task-regex.mjs | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/panel.js b/panel.js index 5452848..01008ac 100644 --- a/panel.js +++ b/panel.js @@ -3928,6 +3928,12 @@ function _renderRegexReuseBadges(rule = {}) { text: "仅 Prompt", }); } + if (rule.promptStageMode !== "skip" && rule.promptStageApplies === false) { + badges.push({ + className: "is-skip", + text: "当前任务未启用", + }); + } return badges .map( (badge) => `${_escHtml(badge.text)}`, diff --git a/task-regex.js b/task-regex.js index 3a08e94..33a23fa 100644 --- a/task-regex.js +++ b/task-regex.js @@ -437,6 +437,12 @@ function summarizeRule(rule, reason = "") { function summarizeRuleForPromptPreview(rule, stageConfig = {}, reason = "") { const summary = summarizeRule(rule, reason); + const promptSemanticApplies = + summary.sourceType === "local" + ? summary.sourceFlags.system !== false && + rule?.destinationFlags?.prompt !== false + : summary.promptReplaceAsEmpty || + (summary.promptOnly === true && rule?.destinationFlags?.prompt !== false); const promptStageApplies = shouldApplyRuleForStage( rule, "input.finalPrompt", @@ -444,8 +450,10 @@ function summarizeRuleForPromptPreview(rule, stageConfig = {}, reason = "") { ); return { ...summary, + promptSemanticApplies, promptStageApplies, - promptStageMode: promptStageApplies + promptStageEnabled: isTaskRegexStageEnabled(stageConfig, "input.finalPrompt"), + promptStageMode: promptSemanticApplies ? summary.promptReplaceAsEmpty ? "clear" : "replace" diff --git a/tests/task-regex.mjs b/tests/task-regex.mjs index 90a5869..293ff5d 100644 --- a/tests/task-regex.mjs +++ b/tests/task-regex.mjs @@ -588,6 +588,38 @@ try { beautifyFinalDebug.entries[0].appliedRules.map((item) => item.id), ["beautify-final-strip"], ); + const beautifyFinalPromptStageOffSettings = buildSettings({ + stages: { + input: true, + output: true, + "input.userMessage": true, + "input.recentMessages": true, + "input.candidateText": true, + "input.finalPrompt": false, + "output.rawResponse": true, + "output.beforeParse": true, + }, + }); + const beautifyStageOffInspect = inspectTaskRegexReuse( + beautifyFinalPromptStageOffSettings, + "extract", + ); + const beautifyStageOffRule = beautifyStageOffInspect.activeRules.find( + (rule) => rule.id === "beautify-final-strip", + ); + assert.equal(beautifyStageOffRule?.promptStageMode, "clear"); + assert.equal(beautifyStageOffRule?.promptStageApplies, false); + assert.equal( + applyTaskRegex( + beautifyFinalPromptStageOffSettings, + "extract", + "input.finalPrompt", + "Decor", + { entries: [] }, + "user", + ), + "Decor", + ); const destinationBeautifySettings = buildSettings({ sources: { global: true,