From c8fc81c3b7595693f06fe9d895b261d2586cb0bb Mon Sep 17 00:00:00 2001 From: Hao19911125 <99091644+Hao19911125@users.noreply.github.com> Date: Wed, 25 Feb 2026 10:28:45 +0800 Subject: [PATCH] Update ena-planner.js for vector log and sequence --- modules/ena-planner/ena-planner.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/ena-planner/ena-planner.js b/modules/ena-planner/ena-planner.js index d578ae9..6daa72c 100644 --- a/modules/ena-planner/ena-planner.js +++ b/modules/ena-planner/ena-planner.js @@ -1086,6 +1086,7 @@ async function buildPlannerMessages(rawUserInput) { // --- Story memory: try fresh recall with current user input --- let cachedSummary = ''; + let _recallSource = 'none'; // ← 新增 try { const vectorCfg = getVectorConfig(); if (vectorCfg?.enabled) { @@ -1093,6 +1094,7 @@ async function buildPlannerMessages(rawUserInput) { pendingUserMessage: rawUserInput, }); cachedSummary = r?.text?.trim() || ''; + if (cachedSummary) _recallSource = 'fresh'; // ← 新增 } } catch (e) { console.warn('[Ena] Fresh vector recall failed, falling back to cached data:', e); @@ -1100,7 +1102,9 @@ async function buildPlannerMessages(rawUserInput) { // Fallback: use stale cache from previous generation if (!cachedSummary) { cachedSummary = getCachedStorySummary(); + if (cachedSummary) _recallSource = 'stale'; // ← 新增 } + console.log(`[Ena] Story memory source: ${_recallSource}`); // ← 新增 // --- Chat history: last 2 AI messages (floors N-1 & N-3) --- // Two messages instead of one to avoid cross-device cache miss: @@ -1140,14 +1144,14 @@ async function buildPlannerMessages(rawUserInput) { // 3) Worldbook if (String(worldbook).trim()) messages.push({ role: 'system', content: worldbook }); - // 3.5) Story memory (小白X <剧情记忆> — fresh recall when available, stale cache as fallback) + // 4) Chat history (last 2 AI responses — floors N-1 & N-3) + if (String(recentChat).trim()) messages.push({ role: 'system', content: recentChat }); + + // 4.5) Story memory (小白X <剧情记忆> — after chat context, before plots) if (storySummary.trim()) { messages.push({ role: 'system', content: `\n${storySummary}\n` }); } - // 4) Chat history (last 2 AI responses — floors N-1 & N-3) - if (String(recentChat).trim()) messages.push({ role: 'system', content: recentChat }); - // 5) Vector recall — now merged into story_summary above, kept for compatibility // (vectorRaw is empty; this block intentionally does nothing) if (String(vector).trim()) messages.push({ role: 'system', content: vector });