feat: 优化默认提示词(HARD GATE约束) + 扩展prompt变量(Phase1+2)

Phase 1: 重写 DEFAULT_TASK_BLOCKS 全部6个任务的 role/format/rules
- 统一应用 HARD GATE 约束段 + 常见错误负例
- compress/synopsis 增加自检清单
- 增强 JSON 稳定性约束

Phase 2: 扩展 prompt 内置变量
- 新建 st-context.js: 统一读取 ST 上下文
- 新增变量: charName/userName/charDescription/userPersona/currentTime
- 更新 extractor/retriever/compressor/consolidator 共6处调用端
- 更新 BUILTIN_BLOCK_DEFINITIONS 帮助文案(多轮对话指引)
This commit is contained in:
Youzini-afk
2026-03-26 10:30:26 +08:00
parent 0e590a6256
commit 2f9524d993
6 changed files with 232 additions and 46 deletions

View File

@@ -19,6 +19,7 @@ import { ensureEventTitle, getNodeDisplayName } from "./node-labels.js";
import { buildTaskPrompt } from "./prompt-builder.js";
import { RELATION_TYPES } from "./schema.js";
import { applyTaskRegex } from "./task-regex.js";
import { getSTContextForPrompt } from "./st-context.js";
import { buildNodeVectorText, isDirectVectorConfig } from "./vector-index.js";
function createAbortError(message = "操作已终止") {
@@ -117,6 +118,7 @@ export async function extractMemories({
graphStats: graphOverview,
graphOverview,
currentRange,
...getSTContextForPrompt(),
});
// 系统提示词
@@ -633,6 +635,7 @@ export async function generateSynopsis({
characterSummary: charSummary || "(无)",
threadSummary: threadSummary || "(无)",
graphStats: `event=${eventNodes.length}, character=${characterNodes.length}, thread=${threadNodes.length}`,
...getSTContextForPrompt(),
});
const synopsisSystemPrompt = applyTaskRegex(
settings,
@@ -746,6 +749,7 @@ export async function generateReflection({
threadSummary: threadSummary || "(无)",
contradictionSummary: contradictionSummary || "(无)",
graphStats: `event=${recentEvents.length}, character=${recentCharacters.length}, thread=${recentThreads.length}`,
...getSTContextForPrompt(),
});
const reflectionSystemPrompt = applyTaskRegex(
settings,