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

@@ -12,6 +12,7 @@ import {
} from "./graph.js";
import { callLLMForJSON } from "./llm.js";
import { buildTaskPrompt } from "./prompt-builder.js";
import { getSTContextForPrompt } from "./st-context.js";
import { applyTaskRegex } from "./task-regex.js";
import { isDirectVectorConfig } from "./vector-index.js";
@@ -234,6 +235,7 @@ async function summarizeBatch(
candidateNodes: nodeDescriptions,
currentRange: `${nodes[0]?.seq ?? "?"} ~ ${nodes[nodes.length - 1]?.seq ?? "?"}`,
graphStats: `node_count=${nodes.length}, node_type=${typeDef.id}`,
...getSTContextForPrompt(),
});
const systemPrompt = applyTaskRegex(
settings,